summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-12 00:11:11 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-12 00:20:53 +0100
commit85d278eb7b798209eaf59199f0b5964a93ba612a (patch)
tree2d68b61c86125d60efceceece274d04a2bd23064
parent26721bd0947120cc4715235c9593de2147aaa23c (diff)
downloadmaria-85d278eb7b798209eaf59199f0b5964a93ba612a.tar.gz
Streamline setup with pre-allocating the minimum troops.
-rw-r--r--play.js2
-rw-r--r--rules.js34
2 files changed, 21 insertions, 15 deletions
diff --git a/play.js b/play.js
index 6f7f17e..be27367 100644
--- a/play.js
+++ b/play.js
@@ -1635,7 +1635,7 @@ function on_update() {
action_button("end_turn", "End turn")
confirm_action_button("confirm_end_movement", "End movement",
- "You have NOT moved ANY pieces!\nAre you sure you want to SKIP movement?")
+ "You have UNMOVED pieces!\nAre you sure you want to END movement?")
action_button("undo", "Undo")
diff --git a/rules.js b/rules.js
index c0a9af3..8e93c36 100644
--- a/rules.js
+++ b/rules.js
@@ -4350,7 +4350,7 @@ function goto_retroactive_conquest() {
}
})
- game.retro = map_filter(game.retro, (s,pow) => pow !== game.power)
+ game.retro = map_filter(game.retro, (_,pow) => pow !== game.power)
log_conquest(conq)
@@ -6390,10 +6390,10 @@ const setup_max_troops = [
]
const setup_troops = [
- 0, 0, 0, 0, 0,
- 0, 0, 0, 6,
+ 7, 6, 5, 0, 0,
+ 0, 0, 4, 6,
0, 0, 0,
- 0, 0, 0, 0, 0, 0,
+ 0, 0, 6, 2, 0, 4,
5,
5,
]
@@ -6624,7 +6624,7 @@ states.setup = {
} else {
let n_stacks = 0
for (let p of all_power_generals[game.power]) {
- if (game.troops[p] === 0) {
+ if (!set_has(game.moved, p)) {
gen_action_piece(p)
n_stacks ++
}
@@ -6650,16 +6650,16 @@ states.setup = {
function count_unsetup_min() {
let n = 0
for (let p of all_power_generals[game.power])
- if (game.troops[p] === 0)
- n += setup_min_troops[p]
+ if (game.selected !== p && !set_has(game.moved, p))
+ n += setup_min_troops[p] - game.troops[p]
return n
}
function count_unsetup_max() {
let n = 0
for (let p of all_power_generals[game.power])
- if (game.troops[p] === 0)
- n += setup_max_troops[p]
+ if (game.selected !== p && !set_has(game.moved, p))
+ n += setup_max_troops[p] - game.troops[p]
return n
}
@@ -6673,21 +6673,23 @@ states.setup_general = {
let n_self_min = setup_min_troops[who]
let n_self_max = setup_max_troops[who]
- let n_other_min = count_unsetup_min() - n_self_min
- let n_other_max = count_unsetup_max() - n_self_max
- let n_troops = setup_total_troops[game.power] - count_used_troops()
+
+ let n_troops = setup_total_troops[game.power] - count_used_troops() + game.troops[who]
+ let n_leave_min = count_unsetup_min()
+ let n_leave_max = count_unsetup_max()
// leave at least 1 for each remaining general
- let take_max = Math.min(n_self_max, n_troops - n_other_min)
+ let take_max = Math.min(n_self_max, n_troops - n_leave_min)
// leave no more than 8 for each remaining general
- let take_min = Math.max(n_self_min, n_troops - n_other_max)
+ let take_min = Math.max(n_self_min, n_troops - n_leave_max)
view.actions.value = []
for (let i = take_min; i <= take_max; ++i)
view.actions.value.push(i)
},
value(v) {
+ set_add(game.moved, game.selected)
game.troops[game.selected] = v
game.selected = -1
game.state = "setup"
@@ -6697,12 +6699,16 @@ states.setup_general = {
function goto_setup() {
game.stage = 0
set_active_setup_power()
+ for (let p of all_generals)
+ if (setup_min_troops[p] === setup_max_troops[p])
+ set_add(game.moved, p)
game.state = "setup"
}
function end_setup() {
let end = is_intro() ? 2 : 4
if (++game.stage === end) {
+ set_clear(game.moved)
goto_start_turn()
} else {
set_active_setup_power()