summaryrefslogtreecommitdiff
path: root/rules.ts
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-04-23 01:06:14 +0200
committerTor Andersson <tor@ccxvii.net>2024-04-23 01:06:14 +0200
commita2b06565c5fbc9df9fb770735ba5984a90e76563 (patch)
tree2332daf042fed9c40aed2174cdd253b0b47b0c15 /rules.ts
parentf8c7e394995b0e773bbdfd0bd6a552cd1c79e9d5 (diff)
downloadplantagenet-a2b06565c5fbc9df9fb770735ba5984a90e76563.tar.gz
Towton: Norfolk is Late and Test of Arms.
Diffstat (limited to 'rules.ts')
-rw-r--r--rules.ts63
1 files changed, 56 insertions, 7 deletions
diff --git a/rules.ts b/rules.ts
index 91c2bb7..e3ff72f 100644
--- a/rules.ts
+++ b/rules.ts
@@ -23,19 +23,14 @@
Scenario special rules.
- Ia: Capture of the King
-
Ib: Norfolk is Late
Ib: Test of Arms
- Ib: check exile boxes (just in case)?
II: Foreign Haven - Warwick
II: Foreign Haven - Edward IV
II: Shaky Allies
II: Queen Regent
- III: King Richard
-
Review all undo steps.
Review all states for needless pauses.
Review all states for adding extra pauses to prevent loss of control.
@@ -1616,6 +1611,16 @@ function add_york_favour(loc: Locale) {
set_add(game.pieces.favoury, loc)
}
+function set_york_favour(loc: Locale) {
+ set_add(game.pieces.favoury, loc)
+ set_delete(game.pieces.favourl, loc)
+}
+
+function set_lancaster_favour(loc: Locale) {
+ set_add(game.pieces.favourl, loc)
+ set_delete(game.pieces.favoury, loc)
+}
+
function remove_york_favour(loc: Locale) {
if (loc === LOC_LONDON)
set_delete(game.pieces.favoury, LONDON_FOR_YORK)
@@ -5617,23 +5622,42 @@ function goto_battle() {
// === 4.4.1 BATTLE ARRAY ===
+function norfolk_is_late() {
+ if (game.scenario === SCENARIO_IB && game.battle.round === 1) {
+ let n = 0
+ for (let lord of all_york_lords)
+ if (get_lord_locale(lord) === game.battle.where)
+ ++n
+ return n > 1
+ }
+ return false
+}
+
function has_friendly_reserves() {
- for (let lord of game.battle.reserves)
+ for (let lord of game.battle.reserves) {
+ if (lord === LORD_NORFOLK && norfolk_is_late())
+ continue
if (is_friendly_lord(lord))
return true
+ }
return false
}
function count_friendly_reserves() {
let n = 0
- for (let lord of game.battle.reserves)
+ for (let lord of game.battle.reserves) {
+ if (lord === LORD_NORFOLK && norfolk_is_late())
+ continue
if (is_friendly_lord(lord))
++n
+ }
return n
}
function pop_first_reserve() {
for (let lord of game.battle.reserves) {
+ if (lord === LORD_NORFOLK && norfolk_is_late())
+ continue
if (is_friendly_lord(lord)) {
set_delete(game.battle.reserves, lord)
return lord
@@ -5707,6 +5731,8 @@ states.array_attacker = {
let done = true
if (array[A1] === NOBODY || array[A2] === NOBODY || array[A3] === NOBODY) {
for (let lord of game.battle.reserves) {
+ if (lord === LORD_NORFOLK && norfolk_is_late())
+ continue
if (lord !== game.who && is_friendly_lord(lord)) {
gen_action_lord(lord)
done = false
@@ -5732,6 +5758,8 @@ states.array_defender = {
let done = true
if (array[D1] === NOBODY || array[D2] === NOBODY || array[D3] === NOBODY) {
for (let lord of game.battle.reserves) {
+ if (lord === LORD_NORFOLK && norfolk_is_late())
+ continue
if (lord !== game.who && is_friendly_lord(lord)) {
gen_action_lord(lord)
done = false
@@ -7222,6 +7250,17 @@ function end_battle_round() {
return
}
+ if (game.scenario === SCENARIO_IB && game.battle.where === LOC_YORK) {
+ if (game.battle.loser === YORK) {
+ log("Test of Arms: York favours Lancaster.")
+ set_lancaster_favour(LOC_YORK)
+ }
+ if (game.battle.loser === LANCASTER) {
+ log("Test of Arms: York favours York.")
+ set_york_favour(LOC_YORK)
+ }
+ }
+
game.battle.round++
goto_battle_rounds()
}
@@ -8722,6 +8761,16 @@ function check_threshold_victory() {
// === 5.3 SCENARIO END VICTORY ===
function check_scenario_end_victory() {
+ if (game.scenario === SCENARIO_IB) {
+ if (has_york_favour(LOC_YORK))
+ goto_game_over(YORK, "York favours York.")
+ else if (has_lancaster_favour(LOC_YORK))
+ goto_game_over(LANCASTER, "York favours Lancaster.")
+ else
+ goto_game_over("Draw", "York favours nobody.")
+ return true
+ }
+
if (current_turn() + 1 === scenario_end_marker[game.scenario]) {
if (game.influence === 0)
goto_game_over("Draw", "The game ended in a draw.")