summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-12-21 17:14:34 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:38 +0100
commit6f3c4bdb9d983e7ad4f2a1ef89eb0dfee9d608e1 (patch)
tree78384c3bd488b6822dfc9ecaec4c81e3d17a608c /rules.js
parentbbfd640bf2b82ab390261fcc5d525454dff67cfe (diff)
downloadnevsky-6f3c4bdb9d983e7ad4f2a1ef89eb0dfee9d608e1.tar.gz
Don't manually click to build siegeworks.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js43
1 files changed, 15 insertions, 28 deletions
diff --git a/rules.js b/rules.js
index 8382db3..d1587c6 100644
--- a/rules.js
+++ b/rules.js
@@ -13,9 +13,9 @@
// TODO: show besieged lords differently in UI
// TODO: mark moved/fought units (blue highlight?)
-// CAPABILITIES
-// TODO: Spoils
-// TODO: BATTLE + STORM + SALLY
+// TODO: BATTLE
+// TODO: SALLY
+// TODO: STORM
// TODO: remove push_state/pop_state stuff - use explicit substates with common functions instead
@@ -3849,7 +3849,7 @@ function count_besieging_lords(loc) {
return count_friendly_lords_at(loc)
}
-function can_siegeworks() {
+function can_build_siegeworks() {
let here = get_lord_locale(game.command)
if (count_besieging_lords(here) >= stronghold_strength(here))
if (count_siege_markers(here) < 4)
@@ -3878,7 +3878,7 @@ function goto_surrender() {
if (count_besieged_lords(here) === 0)
game.state = "surrender"
else
- goto_siegeworks()
+ build_siegeworks()
}
function surrender_stronghold(here) {
@@ -3906,12 +3906,13 @@ states.surrender = {
prompt() {
view.prompt = "Siege: You may roll for Surrender."
view.actions.surrender = 1
- if (can_siegeworks())
+ if (can_build_siegeworks())
view.actions.siegeworks = 1
else
view.actions.pass = 1
},
surrender() {
+ clear_undo()
let here = get_lord_locale(game.command)
let die = roll_die()
let n = count_siege_markers(here)
@@ -3921,38 +3922,24 @@ states.surrender = {
end_siege()
} else {
log(`Surrender ${die} > ${n} failed.`)
- goto_siegeworks()
+ build_siegeworks()
}
},
siegeworks() {
- log("Declined Surrender.")
- goto_siegeworks()
+ build_siegeworks()
},
pass() {
- log("Declined Surrender.")
- goto_siegeworks()
- },
-}
-
-function goto_siegeworks() {
- // TODO: automatic or manual placement?
- if (can_siegeworks())
- game.state = "siegeworks"
- else
end_siege()
+ },
}
-states.siegeworks = {
- prompt() {
- view.prompt = "Siege: Siegeworks - add one siege marker."
- let here = get_lord_locale(game.command)
- gen_action_locale(here)
- },
- locale(here) {
+function build_siegeworks() {
+ if (can_build_siegeworks()) {
log("Added Siege marker.")
+ let here = get_lord_locale(game.command)
add_siege_marker(here)
- end_siege()
- },
+ }
+ end_siege()
}
function end_siege() {