summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/actions/fln
diff options
context:
space:
mode:
Diffstat (limited to 'lib/colonial_twilight/actions/fln')
-rw-r--r--lib/colonial_twilight/actions/fln/agitate.rb51
-rw-r--r--lib/colonial_twilight/actions/fln/fln_action.rb13
-rw-r--r--lib/colonial_twilight/actions/fln/rally.rb66
3 files changed, 130 insertions, 0 deletions
diff --git a/lib/colonial_twilight/actions/fln/agitate.rb b/lib/colonial_twilight/actions/fln/agitate.rb
new file mode 100644
index 0000000..fd0e287
--- /dev/null
+++ b/lib/colonial_twilight/actions/fln/agitate.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+require_relative 'fln_action'
+require_relative 'rally'
+
+module ColonialTwilight
+ module Actions
+ module FLN
+ # Agitate 3.3.1
+ class Agitate < FlnAction
+ # 1 resources per Terror marker, then 1 resource for the level shift
+ def initialize(space, mode)
+ super(space, mode, cost: (mode[:remove_terror] || 0) + (mode[:shift_oppose] || 0))
+ end
+
+ def validate!
+ super
+ raise 'select at least 1 mode' unless mode.keys.size.positive?
+
+ return if space.terror.zero? || (mode.key?(:remove_terror) && mode[:remove_terror] == space.terror)
+
+ raise 'remove Terror marker first' if mode.key?(:shift_oppose)
+ end
+
+ # remove Terror first, then shift 1 level toward Oppose
+ def apply!(board)
+ raise NotImplementedError
+ end
+
+ class << self
+ def op?
+ true
+ end
+
+ # with Base and or Control && terror or shift to oppose possible
+ def applicable?(space)
+ Rally.applicable?(space) &&
+ (space.fln_bases.positive? || space.fln_control?) && (space.terror.positive? || !space.oppose?)
+ end
+
+ def available_modes(space)
+ modes = {}
+ modes[:remove_terror] = space.terror if space.terror.positive?
+ modes[:shift_oppose] = 1 unless space.oppose?
+ modes
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/colonial_twilight/actions/fln/fln_action.rb b/lib/colonial_twilight/actions/fln/fln_action.rb
new file mode 100644
index 0000000..3a571aa
--- /dev/null
+++ b/lib/colonial_twilight/actions/fln/fln_action.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require_relative '../action'
+
+module ColonialTwilight
+ module Actions
+ class FlnAction < GameAction
+ def initialize(space, mode, cost: 1)
+ super(faction: :FLN, space: space, mode: mode, cost: cost)
+ end
+ end
+ end
+end
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