class Eschaton::Combatant
Attributes
accuracy[RW]
defcon[RW]
em_immunity[RW]
inddir[RW]
megatonnage[RW]
nation[RW]
population[RW]
rad_level[RW]
score[RW]
sufddir[RW]
Public Class Methods
new(nation, megatonnage: 400, defcon: 5, sufddir: 0.0, inddir: 0.0, sacpop: 0, rad_level: 0, em_immunity: true, population: 300_000_000, accuracy: 0, score: 0)
click to toggle source
megatonnage = integrally regressed ratio of: yearly military budget as percentage of yearly GNP inverse of stratego-tactical expenditures as percentage of yearly military budget GNP/Military // Military/Nuke ratio
# File lib/eschaton/combatant.rb, line 15 def initialize(nation, megatonnage: 400, defcon: 5, sufddir: 0.0, inddir: 0.0, sacpop: 0, rad_level: 0, em_immunity: true, population: 300_000_000, accuracy: 0, score: 0) @nation = nation.to_s.upcase @sufddir = sufddir #suffering of death, destruction, and incapacitation of response @inddir = inddir #infliction of death, destruction, and incapacitation of response @defcon = defcon @sacpop = sacpop # strikes against civilian populations @megatonnage = megatonnage # distrubtion of megatonnage determined by mean-value theorem of integrals @rad_level = rad_level @em_immunity = em_immunity @population = population @accuracy = accuracy @score = score @targets_hit = Hash.new(0) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/eschaton/combatant.rb, line 37 def <=>(other) other.score <=> score end
each_hit_target() { |target| ... }
click to toggle source
# File lib/eschaton/combatant.rb, line 64 def each_hit_target @targets_hit.each do |name, value| yield Target.new(name, value) end end
hit_target(target)
click to toggle source
# File lib/eschaton/combatant.rb, line 54 def hit_target(target) @targets_hit[target.name.to_sym] += target.ptvalue end
lob(opponent)
click to toggle source
attacks
# File lib/eschaton/combatant.rb, line 76 def lob(opponent) if @megatonnage > 0 @inddir += 30 @megatonnage -= 5 opponent.sufddir += 30 if opponent.defcon > 1 opponent.defcon -= 1 end opponent.rad_level += 20 opponent.population -= rand(100_000..200_000) @score = self.scoretotal puts "#{@nation} lobs a warhead at #{opponent.nation} (+30 INDDIR)!" else puts "#{@nation}'s megaton supply has been depleted." end end
mirv(opponent)
click to toggle source
# File lib/eschaton/combatant.rb, line 121 def mirv(opponent) if @megatonnage > 350 puts "Dear God. #{@nation} launches a neatly tied MIRV jockstrap at #{opponent.nation}..." @inddir += 100 @megatonnage -= 350 opponent.sufddir += 300 opponent.defcon = 1 opponent.rad_level += 100 opponent.population -= rand(100_000_000..200_000_000) 8.times do GameMaster.spasex(self, opponent) sleep(1) end @score = self.scoretotal puts self puts ' ' else puts "#{@nation}'s megaton supply is insufficient for this attack.\n " puts self puts ' ' end end
sacpop(opponent)
click to toggle source
# File lib/eschaton/combatant.rb, line 95 def sacpop(opponent) if @megatonnage > 0 @inddir += 100 @sacpop += 1 @megatonnage -= 5 opponent.sufddir += 100 if opponent.defcon > 2 opponent.defcon -= 2 else opponent.defcon = 1 end opponent.rad_level += 20 opponent.population -= rand(100_000..200_000) @score = self.scoretotal puts "#{@nation} strikes one of #{opponent.nation}'s civilian populations..." puts self puts ' ' else puts "#{@nation}'s megaton supply has been depleted.\ " puts self puts ' ' end end
scoretotal()
click to toggle source
statistics
# File lib/eschaton/combatant.rb, line 45 def scoretotal if @sufddir > 0 @score = @inddir/@sufddir @score.round(2) else @score = @inddir end end
target_stats()
click to toggle source
# File lib/eschaton/combatant.rb, line 58 def target_stats total_target_points = @targets_hit.values.reduce(0) {|sum, val| sum + val } puts "Total INDDIR from ALL targets: ".upcase + total_target_points.to_s sleep(1) end
to_s()
click to toggle source
# File lib/eschaton/combatant.rb, line 33 def to_s "#{@nation.ljust(20, '.')} SUFDDIR: #{@sufddir} / INDDIR: #{@inddir} / MEGATONNAGE: #{@megatonnage}\nDEFCON: #{@defcon} / RADIATION: #{@rad_level} / EM-PULSE IMMUNITY: #{@em_immunity} / SURVIVING POPULATION: #{@population}\n " end