summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/actions/fln/rally.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2026-03-15 10:57:18 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2026-03-15 10:57:18 +0100
commite4e09f936d38a89082f40354fdf451ad875baffa (patch)
tree0b80d727e6e75fb46cc0b7f193dca24465baddb5 /lib/colonial_twilight/actions/fln/rally.rb
parent7d7db184eacd1407c87d01355ae587acccccf7ac (diff)
downloadcolonial-twilight-e4e09f936d38a89082f40354fdf451ad875baffa.zip
colonial-twilight-e4e09f936d38a89082f40354fdf451ad875baffa.tar.gz
Rally & Agitate action classes
Diffstat (limited to 'lib/colonial_twilight/actions/fln/rally.rb')
-rw-r--r--lib/colonial_twilight/actions/fln/rally.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/colonial_twilight/actions/fln/rally.rb b/lib/colonial_twilight/actions/fln/rally.rb
new file mode 100644
index 0000000..c9ed489
--- /dev/null
+++ b/lib/colonial_twilight/actions/fln/rally.rb
@@ -0,0 +1,66 @@
+# frozen_string_literal: true
+
+require_relative 'fln_action'
+require_relative 'agitate'
+
+module ColonialTwilight
+ module Actions
+ module FLN
+ # Rally 3.3.1
+ class Rally < FlnAction
+ def initialize(space, mode)
+ super(space, mode)
+ @agitate = nil
+ end
+
+ def cost
+ super + (@agitate.nil? ? 0 : @agitate.cost)
+ end
+
+ def validate!
+ super
+ raise 'select 1 mode' if mode.keys.size != 1
+ raise 'flip all Guerrillas' if mode.key?(:underground) && mode[:underground] != space.fln_active
+ end
+
+ # France track: shift 1 level toward "F"
+ # in space place 1 underground Guerrilla, or replace 2 Guerrillas with 1 Base
+ # or in space with FLN Base: add underground Guerrillas equal to population + Bases,
+ # or flip all Guerrillas underground
+ def apply!(board)
+ raise NotImplementedError
+ end
+
+ def agitate!(mode)
+ raise 'agitate! called twice' unless @agitate.nil?
+
+ @agitate = Agitate.new(@data[:space], mode)
+ self
+ end
+
+ class << self
+ def op?
+ true
+ end
+
+ # Sectors, Cities not at Support, Independent Countries, France track
+ def applicable?(space)
+ return space.name == 'France track' && !space.max? if space.track?
+
+ space.sector? || (space.city? && !space.support?) || (space.country? && space.independent?)
+ end
+
+ def available_modes(space)
+ modes = { place_guerilla: 1 }
+ modes[:place_base] = 1 if space.guerrillas > 1 && space.bases < space.max_bases
+ unless space.fln_bases.zero?
+ modes[:place_guerilla] = space.fln_bases + space.pop
+ modes[:underground] = space.fln_active if space.fln_active.positive?
+ end
+ modes
+ end
+ end
+ end
+ end
+ end
+end