summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-07-14 18:06:26 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:25 +0100
commit397bea71ffd9f30180bf6e446740e8a5e06d3dc6 (patch)
tree3fde6580690a39e71b5d08c423b635ba0f8782ec
parentda6628ef85ea689ee0616ff123350b6b137314b5 (diff)
downloadrommel-in-the-desert-397bea71ffd9f30180bf6e446740e8a5e06d3dc6.tar.gz
refuse battle
-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: {