Module: ApiBomb::Strategy::Naive

Included in:
Commander
Defined in:
lib/api_bomb/strategy.rb

Instance Method Summary collapse

Instance Method Details

#attackObject



3
4
5
6
7
8
9
# File 'lib/api_bomb/strategy.rb', line 3

def attack
  if requests
    attack_in_requests
  else
    attack_in_time
  end
end

#attack_in_requestsObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/api_bomb/strategy.rb', line 24

def attack_in_requests
  requests.times do |i|
    @fighters << @army.send_fighter
  end

  while (@fighters.length > 0) do
    signaler.report(@fighters[0])
    @fighters.shift
  end
end

#attack_in_timeObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/api_bomb/strategy.rb', line 11

def attack_in_time
  fronts.times do |i|
    @fighters << @army.send_fighter
  end

  while (@fighters.length > 0) do
    signaler.report(@fighters[0])
    @fighters.shift

    @fighters << @army.send_new_fighter
  end
end