summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2025-04-09 15:51:48 -0400
committerJoël Simoneau <simoneaujoel@gmail.com>2025-04-09 15:51:48 -0400
commit320900676c29dec41252b231b79905c8391513c4 (patch)
tree9c6fff46cda075551ad2ba3ddd05add937ec82c5
parent67d4bf6c2b6715611bf399d9eaf3401b16f92879 (diff)
downloadvijayanagara-320900676c29dec41252b231b79905c8391513c4.tar.gz
Clean up plunder
-rw-r--r--play.js4
-rw-r--r--rules.js34
2 files changed, 25 insertions, 13 deletions
diff --git a/play.js b/play.js
index 380767e..94806fa 100644
--- a/play.js
+++ b/play.js
@@ -76,10 +76,10 @@ const LAYOUT = {
"Delhi BK": [571, 422],
"Delhi VE": [724, 414],
"Delhi mongols": [573, 324],
- "Mountain Passes DS": [404, 106],
+ "Mountain Passes DS": [263, 183],
"Mountain Passes BK": [236, 110],
"Mountain Passes VE": [318, 105],
- "Mountain Passes mongols": [263, 183],
+ "Mountain Passes mongols": [404, 127],
"Punjab DS": [515, 164],
"Punjab BK": [279, 262],
"Punjab VE": [477, 266],
diff --git a/rules.js b/rules.js
index 8fa8b23..2b2cfc5 100644
--- a/rules.js
+++ b/rules.js
@@ -1503,7 +1503,7 @@ states.attack_casualties = {
function end_attack_casualties() {
if (game.summary)
- upop_summary()
+ upop_summary("No casualty.")
clear_undo()
if (game.cmd.step === 2) {
game.cmd.step += 1
@@ -1518,8 +1518,7 @@ function goto_attack_resolution() {
if (is_rebel_faction(game.cmd.target) && is_rebel_faction(game.cmd.attacker))
attack_influence_shift()
else if (game.cmd.attacker === MI && !is_timurid()) {
- change_current(game.cmd.sa_faction)
- game.state = "plunder"
+ goto_plunder()
} else if (game.vm) {
vm_next()
} else {
@@ -2754,22 +2753,35 @@ states.mi_attack = {
}
}
+function goto_plunder() {
+ change_current(DS)
+ if (count_pieces(game.cmd.where, MI, TROOPS) > 0) {
+ log_space(game.cmd.where, "Plunder")
+ game.state = "plunder"
+ } else
+ end_plunder()
+}
+
states.plunder = {
inactive: "Attack & Plunder",
prompt() {
- let n = Math.min(game.resources[DS] - 3, count_pieces(game.cmd.where, MI, TROOPS))
- view.prompt = `Attack & Plunder: Plunder ${n} resources from the Delhi Sultanate!`
- gen_action_resources(DS)
+ if (game.resources[DS] <= 3) {
+ view.prompt = "Attack & Plunder: Plunder cannot reduce Delhi Sultanate resources under 3."
+ view.actions.next = 1
+ } else {
+ let n = Math.min(game.resources[DS] - 3, count_pieces(game.cmd.where, MI, TROOPS))
+ view.prompt = `Attack & Plunder: Lose ${n} resources from the plundering Mongol Invaders!`
+ gen_action_resources(DS)
+ }
},
resources(f) {
clear_undo()
- log_space(game.cmd.where, "Plunder")
-
let n = Math.min(game.resources[DS] - 3, count_pieces(game.cmd.where, MI, TROOPS))
logi_resources(f, -n)
add_resources(f, -n)
goto_plunder_remove()
- }
+ },
+ next: goto_plunder_remove
}
function goto_plunder_remove() {
@@ -3919,13 +3931,13 @@ function pop_summary() {
game.summary = null
}
-function upop_summary() {
+function upop_summary(msg="Nothing") {
if (game.summary.length > 0) {
for (let [n, msg] of game.summary) {
log(msg.replace("%", String(n)))
}
} else {
- log("Nothing")
+ log(msg)
}
game.summary = null
}