diff options
-rw-r--r-- | lib/colonial_twilight/fln_rules.rb | 16 | ||||
-rw-r--r-- | spec/fln_rules_spec.rb | 138 |
2 files changed, 79 insertions, 75 deletions
diff --git a/lib/colonial_twilight/fln_rules.rb b/lib/colonial_twilight/fln_rules.rb index dac834b..3df2c32 100644 --- a/lib/colonial_twilight/fln_rules.rb +++ b/lib/colonial_twilight/fln_rules.rb @@ -7,7 +7,7 @@ module ColonialTwilight module FLNRules # Rally 3.3.1 + France Track def may_rally_in?(space) - (space.sector? || (space.city? && !space.support?) || (space.country? && space.independent?)) + space.sector? || (space.city? && !space.support?) || (space.country? && space.independent?) end def rally_spaces(board) @@ -15,7 +15,7 @@ module ColonialTwilight end def may_agitate_in?(space) - (!space.country? && (space.fln_control? || space.fln_bases.positive?)) + !space.country? && (space.fln_control? || space.fln_bases.positive?) end def agitate_spaces(spaces) @@ -26,7 +26,7 @@ module ColonialTwilight # Attack 3.3.3 def may_attack_in?(space) - (space.fln_cubes.positive? && space.gov.positive?) + space.fln_cubes.positive? && space.gov.positive? end def attack_spaces(board) @@ -35,7 +35,7 @@ module ColonialTwilight # Terror 3.3.4 def may_terror_in?(space) - (!space.country? && !space.pop.zero? && space.fln_underground.positive?) + !space.country? && !space.pop.zero? && space.fln_underground.positive? end def terror_spaces(board) @@ -44,8 +44,8 @@ module ColonialTwilight # Extort 4.3.1 def may_extort_in?(space) - (!space.pop.zero? && space.fln_underground.positive? && space.fln_control? && - (space.country? ? space.independent? : true)) + !space.pop.zero? && space.fln_underground.positive? && space.fln_control? && + (space.country? ? space.independent? : true) end def extort_spaces(board) @@ -54,7 +54,7 @@ module ColonialTwilight # Subvert 4.3.2 def may_subvert_in?(space) - (space.fln_underground.positive? && space.algerian_cubes.positive?) + space.fln_underground.positive? && space.algerian_cubes.positive? end def subvert_spaces(board) @@ -72,7 +72,7 @@ module ColonialTwilight # OAS 5.3.1 def may_oas_in?(space) - (!space.country? && !space.pop.zero? && !space.terror.positive?) + !space.country? && !space.pop.zero? && !space.terror.positive? end def oas_spaces(board) diff --git a/spec/fln_rules_spec.rb b/spec/fln_rules_spec.rb index 486d3ec..a373082 100644 --- a/spec/fln_rules_spec.rb +++ b/spec/fln_rules_spec.rb @@ -9,103 +9,107 @@ end describe ColonialTwilight::FLNRules do rules = FLNRulesImpl.new - describe 'Rally' do - board = ColonialTwilight::Board.new - # 25 sectors + 3 cities - it 'collects spaces where operation can be conducted' do expect(rules.rally_spaces(board).size).to eq(28) end + + before do + @board = ColonialTwilight::Board.new end describe 'Rally' do - board = ColonialTwilight::Board.new - board.load :short - # 25 sectors + 2 countries - it 'collects spaces where operation can be conducted' do expect(rules.rally_spaces(board).size).to eq(27) end - end + it 'collects spaces where operation can be conducted' do + expect(rules.rally_spaces(@board).size).to eq(28) + end - describe 'Agitate' do - board = ColonialTwilight::Board.new - it 'collects spaces where operation can be conducted' do expect(rules.agitate_spaces(board.spaces).size).to eq(0) end + it 'collects spaces where operation can be conducted' do + @board.load :short + # 25 sectors + 2 countries + expect(rules.rally_spaces(@board).size).to eq(27) + end end describe 'Agitate' do - board = ColonialTwilight::Board.new - board.load :short - # 6 with bases + 1 in fln control - it 'collects spaces where operation can be conducted' do expect(rules.agitate_spaces(board.spaces).size).to eq(5) end - end + it 'collects spaces where operation can be conducted' do + expect(rules.agitate_spaces(@board.spaces).size).to eq(0) + end - describe 'Attack' do - board = ColonialTwilight::Board.new - # 25 sectors + 3 cities - it 'collects spaces where operation can be conducted' do expect(rules.attack_spaces(board).size).to eq(0) end + it 'collects spaces where operation can be conducted' do + @board.load :short + # 6 with bases + 1 in fln control + expect(rules.agitate_spaces(@board.spaces).size).to eq(5) + end end describe 'Attack' do - board = ColonialTwilight::Board.new - board.load :short - # 25 sectors + 2 countries - it 'collects spaces where operation can be conducted' do expect(rules.attack_spaces(board).size).to eq(7) end - end + it 'collects spaces where operation can be conducted' do + # 25 sectors + 3 cities + expect(rules.attack_spaces(@board).size).to eq(0) + end - describe 'Terror' do - board = ColonialTwilight::Board.new - it 'collects spaces where operation can be conducted' do expect(rules.terror_spaces(board).size).to eq(0) end + it 'collects spaces where operation can be conducted' do + @board.load :short + # 25 sectors + 2 countries + expect(rules.attack_spaces(@board).size).to eq(7) + end end describe 'Terror' do - board = ColonialTwilight::Board.new - board.load :short - # 6 sectors - it 'collects spaces where operation can be conducted' do expect(rules.terror_spaces(board).size).to eq(6) end - end + it 'collects spaces where operation can be conducted' do + expect(rules.terror_spaces(@board).size).to eq(0) + end - describe 'Extort' do - board = ColonialTwilight::Board.new - it 'collects spaces where operation can be conducted' do expect(rules.extort_spaces(board).size).to eq(0) end + it 'collects spaces where operation can be conducted' do + # 6 sectors + @board.load :short + expect(rules.terror_spaces(@board).size).to eq(6) + end end describe 'Extort' do - board = ColonialTwilight::Board.new - board.load :short - # 2 sectors - it 'collects spaces where operation can be conducted' do expect(rules.extort_spaces(board).size).to eq(2) end - end + it 'collects spaces where operation can be conducted' do + expect(rules.extort_spaces(@board).size).to eq(0) + end - describe 'Subvert' do - board = ColonialTwilight::Board.new - it 'collects spaces where operation can be conducted' do expect(rules.subvert_spaces(board).size).to eq(0) end + it 'collects spaces where operation can be conducted' do + @board.load :short + # 2 sectors + expect(rules.extort_spaces(@board).size).to eq(2) + end end describe 'Subvert' do - board = ColonialTwilight::Board.new - board.load :short - # 4 sectors - it 'collects spaces where operation can be conducted' do expect(rules.subvert_spaces(board).size).to eq(4) end - end + it 'collects spaces where operation can be conducted' do + expect(rules.subvert_spaces(@board).size).to eq(0) + end - describe 'Ambush' do - board = ColonialTwilight::Board.new - # 25 sectors + 3 cities - it 'collects spaces where operation can be conducted' do expect(rules.ambush_spaces(board).size).to eq(0) end + it 'collects spaces where operation can be conducted' do + @board.load :short + # 4 sectors + expect(rules.subvert_spaces(@board).size).to eq(4) + end end describe 'Ambush' do - board = ColonialTwilight::Board.new - board.load :short - # 25 sectors + 2 countries - it 'collects spaces where operation can be conducted' do expect(rules.ambush_spaces(board).size).to eq(7) end - end + it 'collects spaces where operation can be conducted' do + # 25 sectors + 3 cities + expect(rules.ambush_spaces(@board).size).to eq(0) + end - describe 'OAS' do - board = ColonialTwilight::Board.new - # 14 sectors + 3 cities - it 'collects spaces where operation can be conducted' do expect(rules.oas_spaces(board).size).to eq(17) end + it 'collects spaces where operation can be conducted' do + @board.load :short + # 25 sectors + 2 countries + expect(rules.ambush_spaces(@board).size).to eq(7) + end end describe 'OAS' do - board = ColonialTwilight::Board.new - board.load :short - # 11 sectors + 3 countries - it 'collects spaces where operation can be conducted' do expect(rules.oas_spaces(board).size).to eq(14) end + it 'collects spaces where operation can be conducted' do + # 14 sectors + 3 cities + expect(rules.oas_spaces(@board).size).to eq(17) + end + + it 'collects spaces where operation can be conducted' do + @board.load :short + # 11 sectors + 3 countries + expect(rules.oas_spaces(@board).size).to eq(14) + end end end |