From b02a37e7878a3316d34fbc0d4f3bd74284c44b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 2 May 2024 17:18:53 +0200 Subject: FLNRules : add March rules and specs --- lib/colonial_twilight/fln_rules.rb | 8 ++++++++ spec/fln_rules_spec.rb | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/lib/colonial_twilight/fln_rules.rb b/lib/colonial_twilight/fln_rules.rb index f8e6c40..c506e72 100644 --- a/lib/colonial_twilight/fln_rules.rb +++ b/lib/colonial_twilight/fln_rules.rb @@ -29,6 +29,14 @@ module ColonialTwilight end # March 3.3.2 + def must_stop?(space_from, space_to) + space_from.wilaya != space_to.wilaya || space_from.country? || space_to.country? + end + + def must_activate?(board, space_from, space_to, num = 1) + (space_from.country? || space_to.support?) && + (num + space_to.gov_cubes + (space_from.country? ? board.border_zone_track : 0)) > 3 + end # Attack 3.3.3 def may_attack_in?(space) diff --git a/spec/fln_rules_spec.rb b/spec/fln_rules_spec.rb index 6a39759..7dfc00b 100644 --- a/spec/fln_rules_spec.rb +++ b/spec/fln_rules_spec.rb @@ -158,4 +158,42 @@ describe ColonialTwilight::FLNRules do expect(rules.oas_spaces(@board).size).to eq(14) end end + + describe 'March' do + it 'may keep on' do + expect(rules.must_stop?(@board.by_name('Saida'), @board.by_name('Mecheria'))).to be false + end + + it 'must stop when crossing international borders' do + expect(rules.must_stop?(@board.by_name('Morocco'), @board.by_name('Mecheria'))).to be true + end + + it 'must stop when crossing international borders' do + expect(rules.must_stop?(@board.by_name('Tebessa'), @board.by_name('Tunisia'))).to be true + end + + it 'must stop when crossing a wilaya border' do + expect(rules.must_stop?(@board.by_name('Setif'), @board.by_name('Barika'))).to be true + end + + it 'must not activate' do + expect(rules.must_activate?(@board, @board.by_name('Setif'), @board.by_name('Barika'))).to be false + end + + it 'might activate when support' do + c = @board.by_name('Constantine') + c.alignment = :support + c.add :french_troops, 1 + expect(rules.must_activate?(@board, @board.by_name('Setif'), c, 2)).to be false + expect(rules.must_activate?(@board, @board.by_name('Setif'), c, 3)).to be true + end + + it 'might activate when crossing border' do + c = @board.by_name('Mecheria') + c.add :french_troops, 1 + expect(rules.must_activate?(@board, @board.by_name('Morocco'), c, 2)).to be false + expect(rules.must_activate?(@board, @board.by_name('Morocco'), c, 3)).to be true + end + + end end -- cgit v1.1-2-g2b99