From 0d389b3c5a4cd50307af262666c7df01df33c6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Oct 2023 10:03:52 +0200 Subject: FLNBotRules : rally 6 checks agitate --- lib/colonial_twilight/fln_bot_rules.rb | 5 +++++ spec/fln_bot_rules_spec.rb | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb index 78f06ba..6b6376f 100644 --- a/lib/colonial_twilight/fln_bot_rules.rb +++ b/lib/colonial_twilight/fln_bot_rules.rb @@ -100,6 +100,11 @@ module ColonialTwilight def may_rally_6_in?(space, already_rallied) # 2+ pop to agitate after rally r = (already_rallied || may_rally_in?(space)) && space.pop > 1 + if r + # to agitate : FLN base or control after rally + n = already_rallied ? 0 : place_guerrillas_in(space).values.sum + r &= (space.fln_bases.positive? || (space.gov < (space.fln + n))) + end dbg " may_rally_6_in : #{space.name}", r r end diff --git a/spec/fln_bot_rules_spec.rb b/spec/fln_bot_rules_spec.rb index 8667a11..2b9ddde 100644 --- a/spec/fln_bot_rules_spec.rb +++ b/spec/fln_bot_rules_spec.rb @@ -265,8 +265,20 @@ describe ColonialTwilight::FLNBotRules do expect(@rules.may_rally_6_in?(a, false)).to be false end - it 'may_rally_6_in? pop 1+' do - a = Sector.new({ pop: 2 }) + it 'may_rally_6_in? pop 2+ but no base, no control after' do + a = Sector.new({ pop: 2, gov_cubes: 1 }) + @board.available_fln_underground = 1 + expect(@rules.may_rally_6_in?(a, false)).to be false + end + + it 'may_rally_6_in? pop 2+ and base' do + a = Sector.new({ pop: 2, gov_cubes: 6, fln_bases: 1 }) + expect(@rules.may_rally_6_in?(a, false)).to be true + end + + it 'may_rally_6_in? pop 2+ and control' do + a = Sector.new({ pop: 2, gov_cubes: 1, fln_active: 1 }) + @board.available_fln_underground = 1 expect(@rules.may_rally_6_in?(a, false)).to be true end -- cgit v1.1-2-g2b99