diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-11-17 15:54:44 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 15:54:44 +0100 |
commit | e81412d934d02edbe80f34e1b3613067f3478b91 (patch) | |
tree | 307a0ea94fc9b7906ecdccafea757dc6ff2a4c4a /rules.js | |
parent | 8631c9e971bddb84f79029adc7e976b0201f8147 (diff) | |
download | richard-iii-e81412d934d02edbe80f34e1b3613067f3478b91.tar.gz |
Fix pretender going home bug!
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -359,7 +359,29 @@ function available_home(who) { return where } -function go_home_if_possible(who) { +function pretender_go_home_if_possible(who) { + if (!is_in_exile(who)) { + // pretender heirs must go home! + if (is_heir(who)) + return true + let n = count_available_homes(who) + if (n === 0) { + game.turn_log.push([block_name(who), "Pool"]) + disband(who) + } else if (n === 1) { + let home = available_home(who) + if (game.location[who] !== home) { + game.location[who] = home + game.turn_log.push([block_name(who), "#" + game.location[who]]) // TODO: "Home"? + } + } else { + return true + } + } + return false +} + +function king_go_home_if_possible(who) { if (!is_in_exile(who)) { let n = count_available_homes(who) if (n === 0) { @@ -3100,7 +3122,7 @@ function goto_pretender_goes_home() { let choices = false for (let b = 0; b < block_count; ++b) if (block_owner(b) === game.active && is_block_on_map(b)) - if (go_home_if_possible(b)) + if (pretender_go_home_if_possible(b)) choices = true if (!choices) { print_turn_log_no_count("Pretender went home:") @@ -3240,7 +3262,7 @@ function goto_king_goes_home() { let choices = false for (let b = 0; b < block_count; ++b) if (block_owner(b) === game.active && is_block_on_map(b)) - if (go_home_if_possible(b)) + if (king_go_home_if_possible(b)) choices = true if (!choices) { print_turn_log_no_count("King went home:") |