summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-09-04 13:48:55 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:27 +0100
commit09378fab9f98633ce8b3ee912a5fa0a52936e13d (patch)
treee2fa4a5901908af718c9a97f6811b6551a39fd61 /rules.js
parent08957786dfbd686481418dae2ea1d9b3ffedddfd (diff)
downloadrommel-in-the-desert-09378fab9f98633ce8b3ee912a5fa0a52936e13d.tar.gz
Show battle/pursuit dialogs explicitly in given states only.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js58
1 files changed, 32 insertions, 26 deletions
diff --git a/rules.js b/rules.js
index 296c761..d0e2797 100644
--- a/rules.js
+++ b/rules.js
@@ -9,7 +9,7 @@ var game = null
var view = null
var after_rout_table = {
- end_battle_2: end_battle_2,
+ end_battle: end_battle,
end_refuse_battle_move_2: end_refuse_battle_move_2,
end_retreat_2: end_retreat_2,
goto_combat_phase: goto_combat_phase,
@@ -30,13 +30,6 @@ function debug_hexes3(n, list) {
console.log("".padStart(y*2," ") + list.slice(y*hexw, (y+1)*hexw).map(x=>String(x).padStart(3, ' ')).join(" "))
}
-function debug_hexes2(n, list) {
- console.log("--", n, "--")
- list = list.map((x,i) => hex_exists[i] ? x : "")
- for (let y = 0; y < hexh; ++y)
- console.log("".padStart(y*2," ") + list.slice(y*hexw, (y+1)*hexw).map(x=>String(x).padStart(3, ' ')).join(" "))
-}
-
function debug_hexes(n, list) {
console.log("--", n, "--")
list = list.map((x,i) => hex_exists[i] ? x : "")
@@ -1332,6 +1325,9 @@ function trace_fortress_network(fortress, ss) {
supply_net.fill(0)
supply_line.fill(0)
+ if (supply_enemy[fortress] > 1 && supply_friendly[fortress] <= 1)
+ return
+
supply_src[fortress] = 1
supply_net[fortress] = 1
supply_visited[fortress] = 1
@@ -2295,7 +2291,6 @@ function visit_hex(x) {
let mf_enemy = (game.active === AXIS) ? MF_ALLIED : MF_AXIS
if (set_has(game.minefields[mf_enemy], x))
set_add(game.minefields[MF_REVEAL], x)
- console.log("VISIT", x, hex_name[x])
}
function visit_path(from, to, speed) {
@@ -4193,6 +4188,11 @@ function end_retreat() {
}
game.retreat_units = null
+ // mark shielding units as moved
+ for_each_undisrupted_friendly_unit_in_hex(game.retreat, u => {
+ set_unit_moved(u)
+ })
+
// no shielding units remain
if (is_friendly_rout_hex(game.retreat))
goto_rout(game.retreat, false, end_retreat_2)
@@ -4200,7 +4200,6 @@ function end_retreat() {
// rear-guard eliminated all enemy units
else if (is_enemy_rout_hex(game.retreat))
goto_rout(game.retreat, true, end_retreat_2)
-
else
end_retreat_2()
}
@@ -4690,13 +4689,7 @@ function goto_battle(x) {
game.hits = [ 0, 0, 0, 0 ]
}
-function end_battle_1() {
- game.flash = ""
- game.battle = 0
- game.hits = 0
-}
-
-function end_battle_2() {
+function end_battle() {
if (!is_battle_hex(game.battle)) {
release_hex_control(game.battle)
hide_units_in_hex(game.battle)
@@ -4705,6 +4698,10 @@ function end_battle_2() {
set_delete(game.active_battles, game.battle)
set_delete(game.assault_battles, game.battle)
+ game.flash = ""
+ game.battle = 0
+ game.hits = 0
+
set_active_player()
if (game.active_battles.length > 0)
game.state = 'select_battle'
@@ -4912,6 +4909,7 @@ function apply_battle_hit(who) {
states.battle_fire = {
inactive: "battle fire",
+ show_battle: true,
prompt() {
if (game.active === game.phasing)
view.prompt = `Battle: Offensive Fire!`
@@ -4946,6 +4944,7 @@ states.battle_fire = {
states.battle_hits = {
inactive: "battle hits",
+ show_battle: true,
prompt() {
if (game.active === game.phasing)
view.prompt = `Battle: Allocate ${format_hits()} from Defensive Fire.`
@@ -4965,9 +4964,7 @@ states.battle_hits = {
function end_battle_hits() {
if (is_friendly_rout_hex(game.battle)) {
- let where = game.battle
- end_battle_1()
- goto_rout(where, false, end_battle_2)
+ goto_rout(game.battle, false, end_battle)
} else if (game.active === game.phasing && has_friendly_units_in_battle()) {
// goto offensive fire
log_br()
@@ -4975,13 +4972,13 @@ function end_battle_hits() {
game.state = 'battle_fire'
game.hits = [ 0, 0, 0, 0 ]
} else {
- end_battle_1()
- end_battle_2()
+ end_battle()
}
}
states.probe_fire = {
inactive: "probe combat fire",
+ show_battle: true,
prompt() {
if (game.active !== game.phasing)
view.prompt = `Probe: Offensive Fire!`
@@ -4994,6 +4991,8 @@ states.probe_fire = {
},
unit(who) {
apply_select(who)
+ if (game.selected >= 0)
+ apply_auto_target(who)
},
armor() {
apply_battle_fire(ARMOR)
@@ -5014,6 +5013,7 @@ states.probe_fire = {
states.probe_hits = {
inactive: "probe combat hits",
+ show_battle: true,
prompt() {
if (game.active !== game.phasing)
view.prompt = `Probe: Allocate ${format_hits()} from Defensive Fire.`
@@ -5233,6 +5233,7 @@ function roll_rout_fire(who, n) {
states.pursuit_fire = {
inactive: "pursuit fire",
+ show_pursuit: true,
prompt() {
view.prompt = `Pursuit Fire.`
let done = true
@@ -5259,6 +5260,7 @@ states.pursuit_fire = {
states.rout_fire = {
inactive: "rout fire",
+ show_pursuit: true,
prompt() {
view.prompt = `Pursuit Fire (Rout).`
let done = true
@@ -5310,6 +5312,7 @@ function gen_pursuit_hits(normal_steps, elite_steps, iterate) {
states.pursuit_hits = {
inactive: "pursuit hits",
+ show_pursuit: true,
prompt() {
view.prompt = "Pursuit Fire: Allocate " + format_hits() + "."
let normal_steps = count_normal_steps_in_pursuit()
@@ -5328,6 +5331,7 @@ states.pursuit_hits = {
states.rout_hits = {
inactive: "rout hits",
+ show_pursuit: true,
prompt() {
view.prompt = "Pursuit Fire: Allocate " + format_hits() + "."
let normal_steps = count_normal_steps_in_rout()
@@ -6345,7 +6349,7 @@ function goto_initial_supply_cards() {
}
states.initial_supply_cards = {
- inactive: "mulligan",
+ inactive: "initial supply cards",
prompt() {
view.prompt = `Setup: You may discard your entire hand and redraw a new one.`
gen_action('discard')
@@ -6981,9 +6985,11 @@ exports.view = function(state, current) {
if (current === game.active)
view.selected = game.selected
- if (game.pursuit) view.pursuit = game.pursuit
- if (game.battle) view.battle = game.battle
- if (game.battle || game.pursuit) {
+ if (states[game.state].show_battle)
+ view.battle = game.battle
+ if (states[game.state].show_pursuit)
+ view.pursuit = game.pursuit
+ if (view.battle || view.pursuit) {
view.hits = game.hits
view.flash = game.flash
if (game.fired.length > 0)