summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-23 00:13:59 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-23 00:13:59 +0200
commit1670c2a19ab91d6e5f30080a469cf5c55aac902b (patch)
tree35da786ecf2336a34743c166066bc6b63d7ee01f
parent23bd83c80d3e0a2d7dd18f76ae4039effd7ce448 (diff)
downloadmaria-1670c2a19ab91d6e5f30080a469cf5c55aac902b.tar.gz
Clamp marker shifts at end.
-rw-r--r--play.js4
-rw-r--r--rules.js41
2 files changed, 37 insertions, 8 deletions
diff --git a/play.js b/play.js
index 363615d..7b69656 100644
--- a/play.js
+++ b/play.js
@@ -1202,6 +1202,10 @@ function on_update() {
action_button("recruit", "Recruit")
action_button("transfer", "Transfer")
+ action_button("execute", "Execute")
+ action_button("discard", "Discard")
+
+ action_button("save", "Save")
action_button("stop", "Stop")
action_button("pass", "Pass")
action_button("next", "Next")
diff --git a/rules.js b/rules.js
index 1450e9d..5ee586f 100644
--- a/rules.js
+++ b/rules.js
@@ -3208,7 +3208,7 @@ function elector_majority() {
let elector_france = 0
let elector_pragmatic = 0
for (let i = 0; i < 8; i += 2) {
- if (view.elector[i+1] === P_FRANCE)
+ if (game.elector[i+1] === P_FRANCE)
elector_france ++
else
elector_pragmatic ++
@@ -3384,7 +3384,7 @@ function goto_determine_order_of_influence() {
log(">" + format_card(c) + " " + power_name[pow])
set_add(game.saved[pow], c)
} else {
- log(">" + format_card(c) + " " + power_name[pow] + "(bluff)")
+ log(">" + format_card(c) + " " + power_name[pow] + " (bluff)")
set_add(game.hand[pow], c)
}
}
@@ -3443,7 +3443,7 @@ states.select_political_card = {
for (let pc of game.political)
if (set_has(political_cards[pc].powers, game.power))
gen_action_political(pc)
- view.actions.pass = 1
+ view.actions.save = 1
},
political(pc) {
push_undo()
@@ -3451,14 +3451,32 @@ states.select_political_card = {
game.saved[game.power] = []
game.pc = pc
game.pcx = -1
- next_execute_political_card()
+ game.state = "political_card_discard_or_execute"
},
- pass() {
+ save() {
log(power_name[game.power] + " saved its TC.")
goto_select_political_card()
},
}
+states.political_card_discard_or_execute = {
+ inactive: "select a political card",
+ prompt() {
+ prompt(`Execute or discard "${political_cards[game.pc].title}".`)
+ view.actions.execute = 1
+ view.actions.discard = 1
+ },
+ execute() {
+ push_undo()
+ next_execute_political_card()
+ },
+ discard() {
+ push_undo()
+ log("Discarded with no effect.")
+ end_execute_political_card()
+ },
+}
+
function end_politics() {
delete game.political
@@ -3466,7 +3484,7 @@ function end_politics() {
for (let pow of all_major_powers) {
if (!(game.stage & (1 << pow))) {
for (let c of game.saved[pow])
- set_add(game.hand, c)
+ set_add(game.hand[pow], c)
game.saved[pow] = []
}
}
@@ -3544,6 +3562,7 @@ states.political_card_done = {
inactive: "execute political card",
prompt() {
prompt("Political card done.")
+ view.pc = game.pc
view.actions.end_political_card = 1
},
end_political_card() {
@@ -3576,8 +3595,10 @@ states.political_shift = {
push_undo()
let info = event_shift[current_political_effect()]
game[info.track] += n
- game[info.track] = Math.max(1, Math.min(TRACK_SIZE[info.track], game[info.track]))
- log("Shifted " + TRACK_NAME[info.track] + " to " + game[info.track] + ".")
+ if (n < 0)
+ log("Shift " + TRACK_NAME[info.track] + " " + (-n) + " left.")
+ else
+ log("Shift " + TRACK_NAME[info.track] + " " + (n) + " right.")
next_execute_political_card()
},
pass() {
@@ -3686,6 +3707,10 @@ function goto_france_minus_tc_this_turn() {
/* POLITICAL TRACKS */
function goto_adjust_political_tracks() {
+ // clamp final values to track
+ game.saxony = Math.max(1, Math.min(5, game.saxony))
+ game.russia = Math.max(1, Math.min(9, game.russia))
+ game.italy = Math.max(1, Math.min(9, game.italy))
// TODO: handle expeditionary corps
// TODO: handle victory points (italy)
// TODO: handle saxony alliance