diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2023-10-23 21:47:03 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2023-10-23 21:47:03 +0200 |
commit | ab2b97fc77b8b52c8b9a402b59dbf4454516b64f (patch) | |
tree | 90eb6bee354604bd6d8e4dc6d95cf25ebd14ae45 /lib/colonial_twilight | |
parent | 31d2196c94b2731b305b5c8704b0a956bf37c544 (diff) | |
download | colonial-twilight-ab2b97fc77b8b52c8b9a402b59dbf4454516b64f.zip colonial-twilight-ab2b97fc77b8b52c8b9a402b59dbf4454516b64f.tar.gz |
Board : clean up
Diffstat (limited to 'lib/colonial_twilight')
-rw-r--r-- | lib/colonial_twilight/board.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/colonial_twilight/board.rb b/lib/colonial_twilight/board.rb index ede3835..f080a54 100644 --- a/lib/colonial_twilight/board.rb +++ b/lib/colonial_twilight/board.rb @@ -6,6 +6,7 @@ require 'colonial_twilight/spaces' module ColonialTwilight class Board FRANCE_TRACK = %w[A B C D E F].freeze + TRACKS = %i[support_commitment opposition_bases fln_resources gov_resources commitment france_track border_zone_track].freeze attr_reader :spaces @@ -37,6 +38,10 @@ module ColonialTwilight set_adjacents end + def inspect + 'Board' + end + def load(scenario) case scenario when :short then short @@ -66,8 +71,7 @@ module ColonialTwilight alias countries country def has(where = :spaces, &block) - r = search(where, &block) - r.length.positive? + !send(where).select(&block).empty? end def search(where = :spaces, &block) @@ -91,17 +95,9 @@ module ColonialTwilight end def shift_track(what, amount) - case what - when :support_commitment then @support_commitment.clamp amount - when :opposition_bases then @opposition_bases.clamp amount - when :fln_resources then @fln_resources.clamp amount - when :gov_resources then @gov_resources.clamp amount - when :commitment then @commitment.clamp amount - when :france_track then @france_track.clamp amount - when :border_zone_track then @border_zone_track.clamp amount - else - raise "unknown track : #{what}" - end + raise "unknown track : #{what}" unless TRACKS.include? what + + instance_variable_get("@#{what}").shift amount end def apply(action) |