diff options
author | Tor A <tor@ccxvii.net> | 2021-05-06 18:51:30 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-16 19:12:55 +0100 |
commit | a76a4e4ddebadedbb22cf0f5509c486278850238 (patch) | |
tree | f848de1352a219031a36316f0584afaf4fa1eebe /rules.js | |
parent | 3cbadb2a7abb9ecdc9a902f084c6ff44a1ca04fe (diff) | |
download | richard-iii-a76a4e4ddebadedbb22cf0f5509c486278850238.tar.gz |
richard: Fix Usurpation and handle UI when pretender/king is dead.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -354,11 +354,11 @@ function is_london_friendly_to(owner) { return is_area_friendly_to("Middlesex", owner); } -function count_lancaster_nobles() { +function count_lancaster_nobles_and_heirs() { let count = 0; for (let b in BLOCKS) if (block_owner(b) == LANCASTER && - (block_type(b) == 'nobles' || block_type(b) == 'church')) + (block_type(b) == 'nobles' || block_type(b) == 'church' || block_type(b) == 'heir')) if (is_on_map_not_in_exile_or_man(b)) ++count; if (is_london_friendly_to(LANCASTER)) @@ -366,11 +366,11 @@ function count_lancaster_nobles() { return count; } -function count_york_nobles() { +function count_york_nobles_and_heirs() { let count = 0; for (let b in BLOCKS) if (block_owner(b) == YORK && - (block_type(b) == 'nobles' || block_type(b) == 'church')) + (block_type(b) == 'nobles' || block_type(b) == 'church' || block_type(b) == 'heir')) if (is_on_map_not_in_exile_or_man(b)) ++count; if (is_london_friendly_to(YORK)) @@ -391,14 +391,21 @@ function block_home(who) { } function block_owner(who) { - if (who == REBEL) - return block_owner(game.pretender); + if (who == REBEL) { + let pretender = game.pretender; + if (game.pretender) + return block_owner(game.pretender); + else if (game.king) + return ENEMY[block_owner(game.king)]; + else + return YORK; // whatever... they're both dead + } return BLOCKS[who].owner; } function block_initiative(who) { if (block_type(who) == 'bombard') - return game.battle_round == 1 ? 'A' : 'D'; + return game.battle_round <= 1 ? 'A' : 'D'; return BLOCKS[who].combat[0]; } @@ -2972,8 +2979,8 @@ function goto_political_turn() { print_turn_log("Levies disband:"); // Usurpation - let l_count = count_lancaster_nobles(); - let y_count = count_york_nobles(); + let l_count = count_lancaster_nobles_and_heirs(); + let y_count = count_york_nobles_and_heirs(); log(""); log("Lancaster controls " + l_count + " nobles."); log("York controls " + y_count + " nobles."); |