summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/board.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-09-02 17:18:31 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-09-02 17:18:31 +0200
commitc18b41671efabbd20a743e01dd8498d71d550eb9 (patch)
tree37838e2ae212973e3f61962a26c50b129f819ec9 /lib/colonial_twilight/board.rb
parent314b20c23a1362eef24efc6f80c7005ec24e878d (diff)
downloadcolonial-twilight-c18b41671efabbd20a743e01dd8498d71d550eb9.zip
colonial-twilight-c18b41671efabbd20a743e01dd8498d71d550eb9.tar.gz
Board : counter.clamp(0, 50)
Diffstat (limited to 'lib/colonial_twilight/board.rb')
-rw-r--r--lib/colonial_twilight/board.rb47
1 files changed, 29 insertions, 18 deletions
diff --git a/lib/colonial_twilight/board.rb b/lib/colonial_twilight/board.rb
index 473d0c1..ba6956b 100644
--- a/lib/colonial_twilight/board.rb
+++ b/lib/colonial_twilight/board.rb
@@ -3,18 +3,6 @@
require 'json'
-# FIXME :
-# - json should not be here
-# - has_?
-# - can_?
-#
-# check min/max bases, points, tracks
-#
-# delegate [syms].each do |s| define_method s delegate.instance_method(s) end
-#
-# scenario as JSON ?, tools to generate them
-#
-
module ColonialTwilight
class Forces
@@ -311,6 +299,20 @@ module ColonialTwilight
end
end
+ def shift_commitment dc
+ @commitment = (@commitment + dc).clamp(0, 50)
+ end
+
+ def shift_resources who, dr
+ if who == :fln
+ @fln_resources = (@fln_resources + dr).clamp(0, 50)
+ elsif who == :gov
+ @gov_resources = (@gov_resources + dr).clamp(0, 50)
+ else
+ raise "shift_resources : unknown who : #{who}"
+ end
+ end
+
def shift_france_track dt
ft = @france_track + dt
return false if (ft < 0 or ft > 5)
@@ -318,6 +320,13 @@ module ColonialTwilight
true
end
+ def shift_border_zone_track dt
+ ft = @shift_border_zone_track + dt
+ return false if (ft < 0 or ft > 4)
+ @border_zone_track = ft
+ true
+ end
+
def has where=:spaces, &block
r = search &block
r.length > 0
@@ -345,6 +354,8 @@ module ColonialTwilight
@opposition_bases += s.pop if s.alignment == :oppose
@support_commitment += s.pop if s.alignment == :support
end
+ @support_commitment = @support_commitment.clamp(0, 50)
+ @opposition_bases = @opposition_bases.clamp(0, 50)
values << @support_commitment << @opposition_bases
end
@@ -486,12 +497,12 @@ module ColonialTwilight
end
def short
- self.commitment = 15
- self.fln_resources = 15
- self.gov_resources = 20
- self.resettled_sectors = 0
- self.france_track = 4
- self.border_zone_track = 3
+ @commitment = 15
+ @fln_resources = 15
+ @gov_resources = 20
+ @resettled_sectors = 0
+ @france_track = 4
+ @border_zone_track = 3
@out_of_play.fln_underground = 5
@available.gov_bases = 2
@available.french_police = 4