summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2024-05-02 17:18:53 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2024-05-02 17:18:53 +0200
commitb02a37e7878a3316d34fbc0d4f3bd74284c44b28 (patch)
treeea95b8e41157b41caedad8a8d538cbcd10cebb9e
parentafa0b16ba4ed371092071e635a0fdd688d8efb9c (diff)
downloadcolonial-twilight-master.zip
colonial-twilight-master.tar.gz
FLNRules : add March rules and specsHEADmaster
-rw-r--r--lib/colonial_twilight/fln_rules.rb8
-rw-r--r--spec/fln_rules_spec.rb38
2 files changed, 46 insertions, 0 deletions
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