summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/colonial_twilight/fln_bot_rules.rb10
-rw-r--r--spec/fln_bot_rules_spec.rb42
-rw-r--r--spec/mock_board.rb4
3 files changed, 56 insertions, 0 deletions
diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb
index 77ee6d7..7093740 100644
--- a/lib/colonial_twilight/fln_bot_rules.rb
+++ b/lib/colonial_twilight/fln_bot_rules.rb
@@ -144,6 +144,16 @@ module ColonialTwilight
_filter(f) { |s| s.gov_cubes.zero? }
end
+ def may_rally_9_in?(space)
+ r = may_agitate_in?(space) && (space.terror.positive? || !space.oppose?)
+ dbg " may_rally_9_in : #{space.name}", r
+ r
+ end
+
+ def rally_9_priority(spaces, resources)
+ _filter(spaces) { |s| !s.oppose? && resources > s.terror }
+ end
+
# Extort
def may_extort_0_in?(space)
diff --git a/spec/fln_bot_rules_spec.rb b/spec/fln_bot_rules_spec.rb
index 9e200f4..1e2fc27 100644
--- a/spec/fln_bot_rules_spec.rb
+++ b/spec/fln_bot_rules_spec.rb
@@ -411,6 +411,48 @@ describe ColonialTwilight::FLNBotRules do
c = Sector.new(fln_active: 1, fln_underground: 1, gov_cubes: 1)
expect(@rules.rally_8_priority([a, b, c])[0]).to be b
end
+
+ it 'may_rally_9_in? no control and no base' do
+ a = Sector.new(terror: 2)
+ expect(@rules.may_rally_9_in?(a)).to be false
+ end
+
+ it 'may_rally_9_in? has control but no terror and oppose' do
+ a = Sector.new(fln_active: 1, oppose: true)
+ expect(@rules.may_rally_9_in?(a)).to be false
+ end
+
+ it 'may_rally_9_in? has base but no terror and oppose' do
+ a = Sector.new(fln_bases: 1, gov_cubes: 1, oppose: true)
+ expect(@rules.may_rally_9_in?(a)).to be false
+ end
+
+ it 'may_rally_9_in? has control and terror' do
+ a = Sector.new(fln_active: 1, terror: 1)
+ expect(@rules.may_rally_9_in?(a)).to be true
+ end
+
+ it 'may_rally_9_in? has base and terror' do
+ a = Sector.new(fln_bases: 1, gov_cubes: 1, terror: 1)
+ expect(@rules.may_rally_9_in?(a)).to be true
+ end
+
+ it 'may_rally_9_in? has control and not oppose' do
+ a = Sector.new(fln_active: 1, terror: 1)
+ expect(@rules.may_rally_9_in?(a)).to be true
+ end
+
+ it 'may_rally_9_in? has base and not oppose' do
+ a = Sector.new(fln_bases: 1, gov_cubes: 1, terror: 1)
+ expect(@rules.may_rally_9_in?(a)).to be true
+ end
+
+ it 'rally_9_priority no cubes' do
+ a = Sector.new(terror: 1, oppose: true)
+ b = Sector.new(terror: 1, neutral: true)
+ c = Sector.new(terror: 2, neutral: true)
+ expect(@rules.rally_9_priority([a, b, c], 2)[0]).to be b
+ end
end
describe 'Extort' do
diff --git a/spec/mock_board.rb b/spec/mock_board.rb
index e1db1b3..2ea3899 100644
--- a/spec/mock_board.rb
+++ b/spec/mock_board.rb
@@ -37,6 +37,10 @@ class Sector
@data[:oppose] || false
end
+ def neutral?
+ @data[:neutral] || false
+ end
+
def terror
@data[:terror] || 0
end