summaryrefslogtreecommitdiff
path: root/rules.ts
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-04-22 19:57:43 +0200
committerTor Andersson <tor@ccxvii.net>2024-04-22 20:07:00 +0200
commit65fd21b9ba818e837230aa5d5b1f0aea91bb54ff (patch)
tree8caa9c9095bf3cff1467f33a7e1a1bdf3ac99ed0 /rules.ts
parent050644d3560802625132bf01162fac9659bd0f47 (diff)
downloadplantagenet-65fd21b9ba818e837230aa5d5b1f0aea91bb54ff.tar.gz
Ia. Capture of the King.
TODO: display henry vi on capturing lord's mat in client.
Diffstat (limited to 'rules.ts')
-rw-r--r--rules.ts56
1 files changed, 54 insertions, 2 deletions
diff --git a/rules.ts b/rules.ts
index e43ac98..aade2db 100644
--- a/rules.ts
+++ b/rules.ts
@@ -354,6 +354,7 @@ const NOCARD = -1 as Card
const CALENDAR = 100 as Locale
const CALENDAR_EXILE = 200 as Locale
const LONDON_FOR_YORK = 300 as Locale // extra london marker
+const CAPTURE_OF_THE_KING = 400 as Locale // Ia. special rule (400 + lord ID that has him captured)
const VASSAL_READY = 29 as Lord
const VASSAL_CALENDAR = 30 as Lord
@@ -1174,7 +1175,8 @@ function set_lord_in_exile(lord: Lord) {
}
function is_lord_in_exile(lord: Lord) {
- return get_lord_locale(lord) >= CALENDAR_EXILE
+ let loc = get_lord_locale(lord)
+ return loc >= CALENDAR_EXILE && loc <= CALENDAR_EXILE + 16
}
function is_lord_on_map(lord: Lord) {
@@ -1187,7 +1189,8 @@ function is_lord_in_play(lord: Lord) {
}
function is_lord_on_calendar(lord: Lord) {
- return get_lord_locale(lord) >= CALENDAR
+ let loc = get_lord_locale(lord)
+ return loc >= CALENDAR && loc <= CALENDAR_EXILE + 16
}
function is_lord_ready(lord: Lord) {
@@ -7444,6 +7447,9 @@ function gen_each_friendly_routed_vassal() {
function goto_death_check() {
game.who = NOBODY
+ if (is_capture_of_the_king_triggered())
+ goto_capture_of_the_king()
+
log_h4("Death Check")
set_active_defender()
@@ -7629,6 +7635,52 @@ states.bloody_thou_art = {
},
}
+// === SCENARIO IA: CAPTURE OF THE KING ===
+
+function is_capture_of_the_king_triggered() {
+ return game.scenario === SCENARIO_IA && game.battle.loser === LANCASTER && get_lord_locale(LORD_HENRY_VI) === game.battle.where
+}
+
+function goto_capture_of_the_king() {
+ set_active(YORK)
+ game.state = "capture_of_the_king"
+ game.who = LORD_HENRY_VI
+}
+
+states.capture_of_the_king = {
+ inactive: "Capture of the King",
+ prompt() {
+ view.prompt = "Capture of the King: Place Henry VI with any unrouted Yorkist lord."
+ for (let lord of all_york_lords)
+ if (is_lord_on_map(lord) && !set_has(game.battle.routed, lord))
+ gen_action_lord(lord)
+ },
+ lord(lord) {
+ push_undo()
+ disband_lord(LORD_HENRY_VI, true)
+ log(`L${LORD_HENRY_VI} captured by L${lord}.`)
+ set_delete(game.battle.routed, lord)
+ set_delete(game.battle.fled, lord)
+ set_lord_locale(LORD_HENRY_VI, CAPTURE_OF_THE_KING + lord as Locale)
+ // Note: the other 10 influence were already gained from normal battle victory
+ goto_death_check()
+ },
+}
+
+function check_capture_of_the_king() {
+ if (game.scenario === SCENARIO_IA) {
+ let loc = get_lord_locale(LORD_HENRY_VI)
+ if (loc >= CAPTURE_OF_THE_KING) {
+ let who = loc - CAPTURE_OF_THE_KING as Lord
+ if (!is_lord_on_map(who)) {
+ log(`L${LORD_HENRY_VI} released!`)
+ disband_lord(LORD_HENRY_VI, false)
+ increase_lancaster_influence(10)
+ }
+ }
+ }
+}
+
// === DEATH CHECK EVENT: ESCAPE SHIP ===
function can_play_escape_ship() {