diff options
Diffstat (limited to 'lib/colonial_twilight/actions/fln/rally.rb')
| -rw-r--r-- | lib/colonial_twilight/actions/fln/rally.rb | 66 |
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 |
