summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-07-19 12:25:47 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:25 +0100
commit710bc4a5242b47a17a9fdcc34323587c38cfb09b (patch)
tree6875747a00f60d6fbc2d00652af287f130522b80
parent459586dfb04f3b79a4180e84e3603f5bffaf2abc (diff)
downloadrommel-in-the-desert-710bc4a5242b47a17a9fdcc34323587c38cfb09b.tar.gz
No rommel in 1940
-rw-r--r--play.js2
-rw-r--r--rules.js18
2 files changed, 14 insertions, 6 deletions
diff --git a/play.js b/play.js
index 1408a0a..89a5413 100644
--- a/play.js
+++ b/play.js
@@ -16,6 +16,8 @@ const ANTITANK = 2
const ARTILLERY = 3
function set_has(set, item) {
+ if (!set)
+ return false
let a = 0
let b = set.length - 1
while (a <= b) {
diff --git a/rules.js b/rules.js
index b4dd302..a500baf 100644
--- a/rules.js
+++ b/rules.js
@@ -1159,7 +1159,7 @@ function goto_move_phase() {
game.state = 'select_moves'
if (game.active === AXIS) {
// Automatically select Rommel Move for 1-move turn options
- if (game.turn_option !== 'offensive' && game.turn_option !== 'blitz')
+ if (game.turn_option !== 'offensive' && game.turn_option !== 'blitz' && game.scenario !== "1940")
game.rommel = 1
}
}
@@ -1195,7 +1195,7 @@ states.select_moves = {
}
function gen_rommel_move() {
- if (game.active === AXIS)
+ if (game.active === AXIS && game.scenario !== "1940")
view.actions.rommel = game.rommel ? 0 : 1
}
@@ -1705,6 +1705,7 @@ states.select_active_battles = {
inactive: "combat phase (select active battles)",
prompt() {
view.prompt = `Select active battles.`
+ view.active_battles = game.active_battles
for (let x of all_hexes)
if (!set_has(game.active_battles, x) && is_battle_hex(x))
gen_action_hex(x)
@@ -1727,6 +1728,8 @@ states.select_assault_battles = {
inactive: "combat phase (select assault battles)",
prompt() {
view.prompt = `Select assault battles.`
+ view.active_battles = game.active_battles
+ view.assault_battles = game.assault_battles
for (let x of game.active_battles)
if (!set_has(game.assault_battles, x))
gen_action_hex(x)
@@ -1746,6 +1749,8 @@ states.select_battle = {
inactive: "combat phase (select next battle)",
prompt() {
view.prompt = `Select next battle to resolve.`
+ view.active_battles = game.active_battles
+ view.assault_battles = game.assault_battles
for (let x of game.active_battles)
gen_action_hex(x)
if (game.active_battles.length === 0)
@@ -2266,7 +2271,7 @@ function setup_units(where, steps, list) {
}
const SCENARIOS = {
- 1940: {
+ "1940": {
year: 1940,
start: 1,
end: 6,
@@ -2768,9 +2773,10 @@ exports.view = function(state, current) {
if (game.pursuit) view.pursuit = game.pursuit
if (game.battle) view.battle = game.battle
- if (game.fired !== undefined) view.fired = game.fired
- if (game.hits !== undefined) view.hits = game.hits
- if (game.flash !== undefined) view.flash = game.flash
+ if (game.battle || game.pursuit) {
+ view.hits = game.hits
+ view.flash = game.flash
+ }
return common_view(current)
}