summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js109
1 files changed, 105 insertions, 4 deletions
diff --git a/rules.js b/rules.js
index bc87a17..4bdecee 100644
--- a/rules.js
+++ b/rules.js
@@ -1233,11 +1233,12 @@ states.move_who = {
game.move_road = 4
},
end_move() {
+ clear_undo()
game.side_limit = {}
game.rommel = 0
game.from1 = game.from2 = game.to1 = game.to2 = 0
- // TODO
- goto_combat_phase()
+ // TODO: forced marches
+ goto_refuse_battle()
}
}
@@ -1358,6 +1359,11 @@ states.move_to = {
if (can_move_regroup_2(who, from, game.to2))
gen_action_hex(game.to2)
+
+ gen_action_unit(who)
+ },
+ unit(who) {
+ pop_undo()
},
hex(to) {
push_undo()
@@ -1424,6 +1430,11 @@ states.group_move_to = {
for (let to = first_hex; to <= last_hex; ++to)
if (to != from && hex_exists[to] && can_move_group_2(who, game.move_from, to))
gen_action_hex(to)
+
+ gen_action_unit(who)
+ },
+ unit(who) {
+ this.stop()
},
hex(to) {
let who = game.selected[0]
@@ -1460,6 +1471,93 @@ function stop_move(who) {
game.state = 'move_who'
}
+// === PURSUIT FIRE ===
+
+function goto_pursuit_fire() {
+}
+
+// === REFUSE BATTLE ===
+
+function gen_withdraw_group_move(who, from) {
+ for (let to = first_hex; to <= last_hex; ++to)
+ if (to != from && hex_exists[to] && can_move_to(to, 4, unit_speed(who)))
+ gen_action_hex(to)
+}
+
+function goto_refuse_battle() {
+ if (game.active_battles.length > 0) {
+ set_passive_player()
+ game.state = 'refuse_battle'
+ } else {
+ goto_combat_phase()
+ }
+}
+
+states.refuse_battle = {
+ inactive: "refuse battle",
+ prompt() {
+ view.prompt = `You may Refuse Battle.`
+ for (let x of game.active_battles)
+ gen_action_hex(x)
+ gen_action('next')
+ },
+ hex(x) {
+ push_undo()
+ set_delete(game.active_battles, x)
+ game.battle = x
+ game.from1 = x
+ goto_pursuit_fire(x)
+ }
+ next() {
+ clear_undo()
+ set_active_player()
+ goto_combat_phase()
+ }
+}
+
+states.refuse_battle_who = {
+ inactive: "refuse battle (withdraw group move: who)",
+ prompt() {
+ view.prompt = `Withdraw: Select unit to move.`
+ for_each_friendly_unit_in_hex(game.from1, u => {
+ gen_action_unit(u)
+ })
+ },
+ unit(u) {
+ push_undo()
+ game.selected = [ u ]
+ game.state = 'refuse_battle_to'
+ },
+ next() {
+ clear_undo()
+ game.state = 'refuse_battle'
+ }
+}
+
+states.refuse_battle_to = {
+ inactive: "refuse battle (withdraw group move: to)",
+ prompt() {
+ view.prompt = `Withdraw: Select destination.`
+ let who = game.selected[0]
+ search_move(game.from1, 0, 4)
+ gen_withdraw_group_move(who, game.from1)
+ gen_action_unit(who)
+ },
+ unit(who) {
+ pop_undo()
+ },
+ hex(to) {
+ let who = game.selected[0]
+ set_unit_hex(who, to)
+ game.selected = []
+ game.state = 'refuse_battle_who'
+ },
+ next() {
+ clear_undo()
+ game.state = 'refuse_battle'
+ }
+}
+
// ==== COMBAT PHASE ===
function goto_combat_phase() {
@@ -1574,6 +1672,7 @@ function count_normal_steps() {
for (let u = 0; u < units.length; ++u)
if (is_enemy_unit(u) && unit_hex(u) === game.battle)
steps[unit_class(u)] += unit_steps(u)
+ return steps
}
function count_elite_steps() {
@@ -1581,6 +1680,7 @@ function count_elite_steps() {
for (let u = 0; u < units.length; ++u)
if (is_enemy_unit(u) && unit_hex(u) === game.battle)
steps[unit_class(u)] += unit_steps(u)
+ return steps
}
function count_hp() {
@@ -1588,6 +1688,7 @@ function count_hp() {
for (let u = 0; u < units.length; ++u)
if (is_enemy_unit(u) && unit_hex(u) === game.battle)
hp[unit_class(u)] += unit_hp(u)
+ return hp
}
const xxx_fire_target = {
@@ -1899,8 +2000,8 @@ const SCENARIOS = {
year: 1940,
start: 1,
end: 6,
- axis_deployment: region_all, // XXX region_libya_and_sidi_omar,
- allied_deployment: region_all, // XXX region_egypt,
+ axis_deployment: region_libya_and_sidi_omar,
+ allied_deployment: region_egypt,
axis_initial_supply: 6,
allied_initial_supply: 3,
special: {