summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/fln_bot/fln_extort.rb
blob: 5889e24e5b60a09e3aebe5e8f17d56fe41b256f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module ColonialTwilight
  module FLNBotExtort
    def extort(except: nil, to_agitate_in: nil)
      return false if available_resources > 4
      return false unless @turn.may_special_activity?(:extort)
      return false if (space = extort_priority(extortable(except: except)).sample).nil?

      apply_action @turn.special_activity_in(:extort, space, -1, to_agitate_in: to_agitate_in).extort
    end

    def extortable(except: nil)
      @board.search { |s| may_extort_0_in?(s) }.reject { |s| @turn.special_activity_selected?(s) || s == except }
    end
  end
end