summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteisuru <31881306+teisuru@users.noreply.github.com>2023-10-15 12:41:13 +0200
committerTor Andersson <tor@ccxvii.net>2023-12-10 18:16:55 +0100
commit88a8df8cf0aa33f362734643682c0f2b4d0b46b4 (patch)
tree903c226a0bb8b327b89a4a6e4e70e906d75312e6
parent2663781a5dae52f23bab0ffe2b7f16ca0c6b17f5 (diff)
downloadplantagenet-88a8df8cf0aa33f362734643682c0f2b4d0b46b4.tar.gz
end tides of war + heralds
-rw-r--r--play.html4
-rw-r--r--play.js3
-rw-r--r--rules.js132
3 files changed, 134 insertions, 5 deletions
diff --git a/play.html b/play.html
index 0e01978..228d79b 100644
--- a/play.html
+++ b/play.html
@@ -24,6 +24,10 @@
<a class="menu_item" target="_blanK" href="/plantagenet/info/playbook.html">Background Book</a>
<a class="menu_item" target="_blanK" href="/plantagenet/info/reference.html">Reference Sheets</a>
<a class="menu_item" target="_blanK" href="/plantagenet/info/cards.html">Arts of War</a>
+ <div class="menu_item" onclick="send_save()">&#x1F41E; Save</div>
+ <div class="menu_item" onclick="send_restore()">&#x1F41E; Restore</div>
+ <div class="menu_separator"></div>
+ <div class="menu_item" onclick="send_restart()">&#x26a0; Restart</div>
<div class="resign menu_separator"></div>
<div class="resign menu_item" onclick="confirm_resign()">Resign</div>
</div>
diff --git a/play.js b/play.js
index 5eba9f0..0ecdf30 100644
--- a/play.js
+++ b/play.js
@@ -1616,7 +1616,8 @@ function on_update() {
action_button("surrender", "Surrender")
// Use all commands
-
+ action_button("heralds", "Heralds")
+
// Use one command
action_button("sail", "Sail")
action_button("parley", "Parley")
diff --git a/rules.js b/rules.js
index 24fa6b6..b9878c7 100644
--- a/rules.js
+++ b/rules.js
@@ -3459,6 +3459,8 @@ states.command = {
view.actions.sail = 1
if (can_action_parley_command())
view.actions.parley = 1
+ if (can_action_heralds())
+ view.actions.heralds = 1
},
pass() {
@@ -3476,6 +3478,7 @@ states.command = {
supply: goto_supply,
tax: goto_tax,
sail: goto_sail,
+ heralds: goto_heralds,
locale: goto_march,
@@ -4850,6 +4853,80 @@ states.confirm_approach_sail = {
goto_battle()
},
}
+
+// === CAPABILITY : HERALDS ===
+
+function can_action_heralds() {
+ if (!is_first_action())
+ return false
+ // at a seaport
+ let here = get_lord_locale(game.command)
+ if (!is_seaport(here))
+ return false
+
+ if (!lord_has_capability(game.command, AOW_LANCASTER_HERALDS))
+ return false
+
+ return true
+}
+
+function goto_heralds(){
+ game.state = "heralds"
+
+}
+
+states.heralds = {
+ inactive: "Heralds",
+ prompt() {
+ view.prompt = "Heralds: Choose a Lord on calendar to shift him to next turn box"
+ for (let lord = first_friendly_lord; lord <= last_friendly_lord; ++lord) {
+ if (is_lord_on_calendar(lord))
+ gen_action_lord(lord)
+ }
+ },
+ lord(other) {
+ clear_undo()
+ goto_heralds_attempt(other)
+ },
+}
+
+function goto_heralds_attempt(lord) {
+ game.what = lord
+ push_state("heralds_attempt")
+ init_influence_check(game.command)
+}
+
+states.heralds_attempt = {
+ inactive: "Heralds Attempt",
+ prompt() {
+ view.prompt = `Attempt to shift ${lord_name[game.what]} to next Turn Box. `
+ prompt_influence_check()
+ },
+ spend1: add_influence_check_modifier_1,
+ spend3: add_influence_check_modifier_2,
+ check() {
+ let results = do_influence_check()
+ log(`Attempt to shift L${game.what} ${results.success ? "Successful" : "Failed"}: (${range(results.rating)}) ${results.success ? HIT[results.roll] : MISS[results.roll]}`)
+
+ if (results.success) {
+ game.who = game.what
+ set_lord_calendar(game.who, current_turn() + 1)
+ end_heralds_attempt()
+ } else {
+ end_heralds_attempt()
+ }
+ },
+}
+
+function end_heralds_attempt() {
+ spend_all_actions()
+ pop_state()
+ clear_undo()
+ end_influence_check()
+ resume_command()
+}
+
+
// === BATTLE ===
function set_active_attacker() {
@@ -7000,7 +7077,7 @@ function disband_lord(lord, permanently = false) {
for (let x = 0; x < FORCE_TYPE_COUNT; ++x) {
set_lord_forces(lord, x, 0)
- //set_lord_routed(lord, x, 0)
+ //set_lord_routed(lord, x, 0)
}
set_lord_moved(lord, 0)
@@ -7306,6 +7383,7 @@ function end_reset() {
// === END CAMPAIGN: TIDES OF WAR ===
function tides_calc() {
+ log_h3(`Tides of War`)
let town = 0
let cities = 0
let fortress = 0
@@ -7317,6 +7395,14 @@ function tides_calc() {
let domsy = 0
let domwl = 0
let domwy = 0
+ let prenl = 0
+ let preny = 0
+ let presl = 0
+ let presy = 0
+ let prewl = 0
+ let prewy = 0
+ let prel = 0
+ let prey = 0
let x = 0
// DOMINATION CALC
@@ -7480,7 +7566,7 @@ function tides_calc() {
}
if (town >= 1) {
log(`Most Towns 1 Influence for York`)
- domy += 2
+ domy += 1
}
if (cities <= -1) {
@@ -7493,9 +7579,44 @@ function tides_calc() {
}
if (town <= -1) {
log(`Most Towns 1 Influence for Lancaster`)
- doml += 2
+ doml += 1
}
+ // LORD PRESENCE
+ for (let lord = first_lancaster_lord; lord <= last_lancaster_lord; ++lord) {
+ if (is_lord_on_map(lord)) {
+ if (data.locales[get_lord_locale(lord)].region === "North") {
+ prenl = 1
+ }
+ if (data.locales[get_lord_locale(lord)].region === "South") {
+ presl = 1
+ }
+ if (data.locales[get_lord_locale(lord)].region === "Wales") {
+ prewl = 1
+ }
+ }
+ }
+ for (let lord = first_york_lord; lord <= last_york_lord; ++lord) {
+ if (is_lord_on_map(lord)) {
+ if (data.locales[get_lord_locale(lord)].region === "North") {
+ preny = 1
+ }
+ if (data.locales[get_lord_locale(lord)].region === "South") {
+ presy = 1
+ }
+ if (data.locales[get_lord_locale(lord)].region === "Wales")
+ prewy = 1
+ }
+ }
+ prel = prenl+presl+prewl
+ prey = preny+presy+prewy
+
+ log("Presence in Areas : " +prel+ " for Lancaster")
+ log("Presence in Areas : " +prey+ " for Yorkists")
+
+ domy += preny+presy+prewy
+ doml += prenl+presl+prewl
+
// CAPS EFFECT
if (
@@ -7507,6 +7628,7 @@ function tides_calc() {
doml += 2
}
+
if (
lord_has_capability(LORD_EXETER_1, AOW_LANCASTER_COUNCIL_MEMBER) ||
lord_has_capability(LORD_EXETER_2, AOW_LANCASTER_COUNCIL_MEMBER) ||
@@ -7518,8 +7640,9 @@ function tides_calc() {
doml += 1
}
+
if (lord_has_capability(LORD_EDWARD_IV, AOW_YORK_FIRST_SON)) {
- log(`Capability: First Son 1 Influence for Lancaster`)
+ log(`Capability: First Son 1 Influence for York`)
domy += 1
}
@@ -7537,6 +7660,7 @@ function tides_calc() {
}
}
+
log(`Total ` + domy + ` Influence for York`)
log(`Total ` + doml + ` Influence for Lancaster`)