summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/colonial_twilight/board.rb47
-rw-r--r--lib/colonial_twilight/fln_bot.rb2
2 files changed, 30 insertions, 19 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
diff --git a/lib/colonial_twilight/fln_bot.rb b/lib/colonial_twilight/fln_bot.rb
index ae4536b..0cb8b46 100644
--- a/lib/colonial_twilight/fln_bot.rb
+++ b/lib/colonial_twilight/fln_bot.rb
@@ -610,7 +610,7 @@ module ColonialTwilight
# :pass, :event, :agitate
end
cost = h[:fln_resources]
- @board.fln_resources -= cost
+ @board.shift_resources :fln, -cost
@expended_resources += cost unless h.has_key? :already_expended # _reserve_agitate
h[:resources] = {:cost=>cost, :value=>@board.fln_resources}
h[:controls].each do |k,v|