summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/fln_bot_rules.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2023-11-13 10:14:49 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2023-11-13 10:14:49 +0100
commita8be09ab04e4c29e6ce032dffcde0c134cc74382 (patch)
treea1549f0ae6d92d74ba1f1ac98f22d13f3fb69dda /lib/colonial_twilight/fln_bot_rules.rb
parent5500a1add4c167d018665d3d1e5f69652f91b0db (diff)
downloadcolonial-twilight-a8be09ab04e4c29e6ce032dffcde0c134cc74382.zip
colonial-twilight-a8be09ab04e4c29e6ce032dffcde0c134cc74382.tar.gz
FLNBotRules : add attack && ambush && specs
Diffstat (limited to 'lib/colonial_twilight/fln_bot_rules.rb')
-rw-r--r--lib/colonial_twilight/fln_bot_rules.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb
index 818f0bf..8f0f37a 100644
--- a/lib/colonial_twilight/fln_bot_rules.rb
+++ b/lib/colonial_twilight/fln_bot_rules.rb
@@ -218,6 +218,37 @@ module ColonialTwilight
(de_gaule && space.sector? && space.troops.positive? && space.police.positive? && space.gov_control?)
end
+ # Attack
+
+ def may_attack_1_in?(space)
+ # attack will remove 1+ GOV piece, do not expose a base
+ r = may_attack_in?(space) && space.guerrillas > 5 && space.fln_bases.zero?
+ dbg " may_attack_1_in : #{space.name}", r
+ r
+ end
+
+ def may_ambush_1_in?(space)
+ # do not expose a base
+ r = may_ambush_in?(space) && (space.fln_bases.zero? ? true : space.guerrillas > 1)
+ dbg " may_attack_1_in : #{space.name}", r
+ r
+ end
+
+ def may_attack_2_in?(space)
+ # 4+ guerrillas, do not expose a base
+ r = may_attack_in?(space) && space.guerrillas > 3 && space.fln_bases.zero?
+ dbg " may_attack_2_in : #{space.name}", r
+ r
+ end
+
+ def attack_priority(spaces)
+ # GOV bases -> French Troops -> French Police -> most pieces
+ f = _filter(spaces) { |s| s.gov_bases.positive? }
+ f = _filter(f) { |s| s.french_troops.positive? }
+ f = _filter(f) { |s| s.french_police.positive? }
+ _max(f, :gov)
+ end
+
# 8.1.2 - Procedure Guidelines
def _filter(spaces, &block)