diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2023-10-24 13:18:51 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2023-10-24 13:18:51 +0200 |
commit | 3011fbf0561570c0962e169a2d62d327edf19771 (patch) | |
tree | a3ddadfb9f6c514535df672b64f9141961c776bd /spec | |
parent | 15298b7b3bc8facb1f350b7ab4ce9ec2fae50599 (diff) | |
download | colonial-twilight-3011fbf0561570c0962e169a2d62d327edf19771.zip colonial-twilight-3011fbf0561570c0962e169a2d62d327edf19771.tar.gz |
FLNBotRules : add #place_guerrillas_in, fix rally_7
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fln_bot_rules_spec.rb | 55 | ||||
-rw-r--r-- | spec/mock_board.rb | 18 |
2 files changed, 54 insertions, 19 deletions
diff --git a/spec/fln_bot_rules_spec.rb b/spec/fln_bot_rules_spec.rb index a841b67..8667a11 100644 --- a/spec/fln_bot_rules_spec.rb +++ b/spec/fln_bot_rules_spec.rb @@ -9,7 +9,7 @@ class FLNRulesImpl attr_writer :limited_op_only, :first_eligible, :will_be_next_first_eligible def initialize - @debug = 0 + @debug = 666 @board = Board.new @limited_op_only = true @first_eligible = true @@ -305,31 +305,42 @@ describe ColonialTwilight::FLNBotRules do expect(@rules.may_rally_7_in?(a)).to be false end - it 'rally_7_priority_after city?' do - a = Sector.new({ name: 'city' }) - b = Sector.new - expect(@rules.rally_7_priority_after([a, b])[0]).to be a + it 'rally_7_priority population' do + a = Sector.new({ pop: 2 }) + b = Sector.new({ pop: 1 }) + c = Sector.new({ pop: 1 }) + expect(@rules.rally_7_priority([a, b, c])[0]).to be a end - it 'rally_7_priority_after least terror' do - a = Sector.new - b = Sector.new({ name: 'city', terror: 1 }) - c = Sector.new({ name: 'city', terror: 2 }) - expect(@rules.rally_7_priority_after([a, b, c])[0]).to be b + it 'rally_7_priority gain FLN control' do + a = Sector.new({ gov_cubes: 2 }) + b = Sector.new({ gov_cubes: 1, fln_active: 1 }) + c = Sector.new({ gov_cubes: 1 }) + @board.available_fln_underground = 1 + expect(@rules.rally_7_priority([a, b, c])[0]).to be b end - it 'rally_7_priority population' do - a = Sector.new({ pop: 2 }) - b = Sector.new({ pop: 1 }) - expect(@rules.rally_7_priority([a, b])[0]).to be a + it 'rally_7_priority remove GOV control' do + a = Sector.new({ gov_cubes: 3 }) + b = Sector.new({ gov_cubes: 1 }) + c = Sector.new({ gov_cubes: 2 }) + @board.available_fln_underground = 1 + expect(@rules.rally_7_priority([a, b, c])[0]).to be b end - it 'rally_7_priority population' do - a = Sector.new({ pop: 2 }) - b = Sector.new({ pop: 1 }) + it 'rally_7_priority city?' do + a = Sector.new({ name: 'city' }) + b = Sector.new expect(@rules.rally_7_priority([a, b])[0]).to be a end + it 'rally_7_priority least terror' do + a = Sector.new + b = Sector.new({ name: 'city', terror: 1 }) + c = Sector.new({ name: 'city', terror: 2 }) + expect(@rules.rally_7_priority([a, b, c])[0]).to be b + end + it 'may_rally_8_in? no fln guerrillas' do a = Sector.new expect(@rules.may_rally_8_in?(a)).to be false @@ -417,6 +428,16 @@ describe ColonialTwilight::FLNBotRules do expect(@rules.max_placable_guerrillas_in?(a)).to eq(1) end + it 'place_guerrillas_in' do + a = Sector.new({ pop: 2, fln_bases: 1 }) + @board.available_fln_underground = 1 + @board.spaces << Sector.new({ name: 'a', fln_bases: 1, fln_active: 2, fln_underground: 1 }) + h = @rules.place_guerrillas_in(a) + expect(@rules.max_placable_guerrillas_in?(a)).to eq(3) + expect(h[:available]).to eq(1) + expect(h[@board.spaces[0]]).to eq(1) + end + it 'removable_guerrillas active' do a = Sector.new({ fln_active: 2, fln_underground: 3 }) expect(@rules.removable_guerrillas(a)).to eq(2) diff --git a/spec/mock_board.rb b/spec/mock_board.rb index e75ba73..34c5272 100644 --- a/spec/mock_board.rb +++ b/spec/mock_board.rb @@ -57,19 +57,33 @@ class Sector @data[:fln_underground] || 0 end + def fln + fln_active + fln_underground + fln_bases + end + def gov_cubes @data[:gov_cubes] || 0 end + + def gov_bases + @data[:gov_bases] || 0 + end + + def gov + gov_cubes + gov_bases + end end class Board - attr_reader :sector - attr_accessor :fln_resources, :available_fln_bases + attr_reader :sector, :spaces + attr_accessor :fln_resources, :available_fln_underground, :available_fln_bases def initialize @fln_resources = 0 @available_fln_bases = 1 + @available_fln_underground = 0 @sector = Sector.new + @spaces = [] end def has(&block) |