summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/fln_bot/fln_rules.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2026-03-11 15:16:47 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2026-03-11 15:16:47 +0100
commit9458b6413e3609e12f563dcb321d493b5f317017 (patch)
tree0e8bb866639541ee1e5b9c669b964054d9da8aa6 /lib/colonial_twilight/fln_bot/fln_rules.rb
parent96eba00d76af7fe662bc7f26d8962ada3bfa15b2 (diff)
downloadcolonial-twilight-9458b6413e3609e12f563dcb321d493b5f317017.zip
colonial-twilight-9458b6413e3609e12f563dcb321d493b5f317017.tar.gz
update FlnBot infrastructure
Diffstat (limited to 'lib/colonial_twilight/fln_bot/fln_rules.rb')
-rw-r--r--lib/colonial_twilight/fln_bot/fln_rules.rb94
1 files changed, 94 insertions, 0 deletions
diff --git a/lib/colonial_twilight/fln_bot/fln_rules.rb b/lib/colonial_twilight/fln_bot/fln_rules.rb
new file mode 100644
index 0000000..39acd3d
--- /dev/null
+++ b/lib/colonial_twilight/fln_bot/fln_rules.rb
@@ -0,0 +1,94 @@
+# frozen_string_literal: true
+
+module ColonialTwilight
+ module FLNRules
+ # Rally 3.3.1 + France Track
+ def may_rally_in?(space)
+ space.sector? || (space.city? && !space.support?) || (space.country? && space.independent?)
+ end
+
+ def rally_spaces(board)
+ board.search(&method(:may_rally_in?))
+ end
+
+ def may_agitate_in?(space)
+ !space.country? && (space.fln_control? || space.fln_bases.positive?) && (space.terror.positive? || !space.oppose?)
+ end
+
+ def agitate_spaces(board)
+ board.search(&method(:may_agitate_in?))
+ end
+
+ def max_placable_guerrillas(space)
+ space.fln_bases.positive? ? space.fln_bases + space.pop : 1
+ end
+
+ def max_agitate_cost(space)
+ space.terror + (space.oppose? ? 0 : 1)
+ 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)
+ space.guerrillas.positive? && space.gov.positive?
+ end
+
+ def attack_spaces(board)
+ board.search(&method(:may_attack_in?))
+ end
+
+ # Terror 3.3.4
+ def may_terror_in?(space)
+ !space.country? && !space.pop.zero? && space.fln_underground.positive?
+ end
+
+ def terror_spaces(board)
+ board.search(&method(:may_terror_in?))
+ end
+
+ # Extort 4.3.1
+ def may_extort_in?(space)
+ space.fln_underground.positive? && (space.country? ? space.independent? : !space.pop.zero? && space.fln_control?)
+ end
+
+ def extort_spaces(board)
+ board.search(&method(:may_extort_in?))
+ end
+
+ # Subvert 4.3.2
+ def may_subvert_in?(space)
+ space.fln_underground.positive? && space.algerian_cubes.positive?
+ end
+
+ def subvert_spaces(board)
+ board.search(&method(:may_subvert_in?))
+ end
+
+ # Ambush 4.3.3
+ def may_ambush_in?(space)
+ may_attack_in?(space) && space.fln_underground.positive?
+ end
+
+ def ambush_spaces(board)
+ board.search(&method(:may_ambush_in?))
+ end
+
+ # OAS 5.3.1
+ def may_oas_in?(space)
+ !space.country? && !space.pop.zero? && !space.terror.positive?
+ end
+
+ def oas_spaces(board)
+ board.search(&method(:may_oas_in?))
+ end
+ end
+end