summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js87
1 files changed, 78 insertions, 9 deletions
diff --git a/rules.js b/rules.js
index 3ba015c..c65c84e 100644
--- a/rules.js
+++ b/rules.js
@@ -5,9 +5,8 @@
// TODO: raiders
// TODO: legal pass withdrawal moves (reduce supply net, withdraw from fortress attack)
-// TODO: MINEFIELDS
-// TODO: SUPPLY COMMITMENT
// TODO: BUILDUP
+// TODO: MINEFIELDS
// TODO: setup scenario specials
@@ -1358,9 +1357,17 @@ function is_allied_player() {
}
function end_player_turn() {
+ // Forget partial retreats
set_clear(game.partial_retreats)
- // TODO: end when both pass
+ // Reveal supply cards
+ log_br()
+ log(`Supply Cards Played:\n${game.commit[0]} real and ${game.commit[1]} dummy.`)
+ game.commit = [ 0, 0 ]
+
+ if (game.passed === 2)
+ return end_month()
+
if (game.phasing === AXIS)
game.phasing = ALLIED
else
@@ -1383,9 +1390,45 @@ function goto_player_turn() {
set_clear(game.fired)
set_clear(game.moved)
+ game.commit = [ 0, 0 ]
+
goto_initial_supply_check()
}
+function goto_supply_commitment() {
+ game.state = 'supply_commitment'
+}
+
+states.supply_commitment = {
+ prompt() {
+ view.prompt = `Supply Commitment: ${game.commit[0]} real and ${game.commit[1]} dummy.`
+ let hand = is_axis_player() ? game.axis_hand : game.allied_hand
+ if (game.commit[0] + game.commit[1] < 3) {
+ if (hand[0] > 0)
+ gen_action('real_card')
+ if (hand[1] > 0)
+ gen_action('dummy_card')
+ }
+ gen_action_next()
+ },
+ real_card() {
+ push_undo()
+ let hand = is_axis_player() ? game.axis_hand : game.allied_hand
+ hand[0]--
+ game.commit[0]++
+ },
+ dummy_card() {
+ push_undo()
+ let hand = is_axis_player() ? game.axis_hand : game.allied_hand
+ hand[1]--
+ game.commit[1]++
+ },
+ next() {
+ push_undo()
+ goto_turn_option()
+ },
+}
+
function goto_turn_option() {
set_active_player()
game.state = 'turn_option'
@@ -1395,35 +1438,51 @@ states.turn_option = {
inactive: "turn option",
prompt() {
view.prompt = "Select Turn Option"
- gen_action('basic')
- gen_action('offensive')
- gen_action('assault')
- gen_action('blitz')
- gen_action('pass')
+ if (game.commit[0] >= 1)
+ view.actions.basic = 1
+ else
+ view.actions.basic = 0
+ if (game.commit[0] >= 2)
+ view.actions.offensive = view.actions.assault = 1
+ else
+ view.actions.offensive = view.actions.assault = 0
+ if (game.commit[0] >= 3)
+ view.actions.blitz = 1
+ else
+ view.actions.blitz = 0
+ if (game.commit[0] === 0)
+ view.actions.pass = 1
+ else
+ view.actions.pass = 0
},
basic() {
push_undo()
game.turn_option = 'basic'
+ game.passed = 0
goto_move_phase()
},
offensive() {
push_undo()
game.turn_option = 'offensive'
+ game.passed = 0
goto_move_phase()
},
assault() {
push_undo()
game.turn_option = 'assault'
+ game.passed = 0
goto_move_phase()
},
blitz() {
push_undo()
game.turn_option = 'blitz'
+ game.passed = 0
goto_move_phase()
},
pass() {
push_undo()
game.turn_option = 'pass'
+ game.passed ++
goto_move_phase()
},
}
@@ -1467,7 +1526,7 @@ function goto_initial_supply_check_rout() {
}
}
if (n === 0)
- goto_turn_option()
+ goto_supply_commitment()
else if (n === 1)
goto_rout(where, false, goto_initial_supply_check_rout)
else
@@ -4091,7 +4150,9 @@ exports.setup = function (seed, scenario, options) {
allied_sides: [],
// current turn option and selected moves
+ commit: [0, 0],
turn_option: null,
+ passed: 0,
side_limit: {},
forced: null,
rommel: 0,
@@ -4132,6 +4193,9 @@ exports.view = function(state, current) {
month: game.month,
units: game.units,
moved: game.moved,
+ axis_hand: game.axis_hand[0] + game.axis_hand[1],
+ allied_hand: game.allied_hand[0] + game.allied_hand[1],
+ commit: game.commit[0] + game.commit[1],
axis_hexes: game.axis_hexes,
allied_hexes: game.allied_hexes,
axis_sides: game.axis_sides,
@@ -4139,6 +4203,11 @@ exports.view = function(state, current) {
selected: game.selected,
}
+ if (current === AXIS)
+ view.cards = game.axis_hand
+ if (current === ALLIED)
+ view.cards = game.allied_hand
+
if (game.from1) view.from1 = game.from1
if (game.from2) view.from2 = game.from2
if (game.to1) view.to1 = game.to1