diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 51 |
1 files changed, 27 insertions, 24 deletions
@@ -1,21 +1,10 @@ "use strict" -/* -TODO - -[ ] killed leader stash for buy/trash phase - -TODO: can_select_general - check actual possible actions -TODO: can_select_governor - check actual possible actions -TODO: can_select_militia - check actual possible actions - -*/ - var game var view const states = {} -const AUTO_PLAY_EVENTS = false +const AUTO_PLAY_EVENTS = true const P1 = "Red" const P2 = "Blue" @@ -834,6 +823,9 @@ function can_militia_initiate_battle(where) { return true if (some_barbarian((id, loc) => loc === where)) return true + for (let id = 0; id < 3; ++id) + if (get_rival_emperor_location(id) === where) + return true return false } @@ -844,6 +836,9 @@ function can_general_initiate_battle(where) { return true if (some_barbarian((id, loc) => loc === where)) return true + for (let id = 0; id < 3; ++id) + if (get_rival_emperor_location(id) === where) + return true return false } @@ -2069,6 +2064,7 @@ states.take_actions = { log("Recruit Governor " + (game.selected_governor % 6) + ".") spend_senate(game.selected_governor % 6) set_governor_location(game.selected_governor, AVAILABLE) + resume_take_actions() }, recruit_general() { @@ -2375,7 +2371,7 @@ function calc_extra_votes(where) { states.place_governor = { inactive: "Place Governor", prompt() { - let need = calc_needed_votes(game.where, false) - calc_extra_votes(game.where) + let need = Math.max(0, calc_needed_votes(game.where, false) - calc_extra_votes(game.where)) let dice = game.count if (game.where === ITALIA) dice += count_own_basilicas() @@ -2412,7 +2408,7 @@ states.place_governor = { states.praetorian_guard = { inactive: "Praetorian Guard", prompt() { - let need = calc_needed_votes(game.where, true) - calc_extra_votes(game.where) + let need = Math.max(0, calc_needed_votes(game.where, true) - calc_extra_votes(game.where)) let dice = game.count if (game.where === ITALIA) dice += count_own_basilicas() @@ -2676,7 +2672,7 @@ function has_mobs_in_own_provinces() { states.becoming_emperor = { inactive: "Becoming Emperor", prompt() { - prompt("Becoming Emperor: Place your Emperor token.") + prompt("Becoming Emperor: Place your Emperor.") for (let i = 0; i < 6; ++i) { let id = game.current * 6 + i if (is_region(get_governor_location(id))) @@ -3074,7 +3070,6 @@ function can_play_foederati() { } function play_foederati() { - // TODO: auto-select general on map? game.state = "foederati" } @@ -3120,10 +3115,16 @@ states.foederati_general = { let tribe = get_barbarian_tribe(id) let from = get_barbarian_location(id) if (count_legions_in_army(game.count) > count_barbarians_in_army(game.count)) { - log("Foederati " + BARBARIAN_NAME[tribe] + " from %" + from + " to %" + game.where + ".") + if (is_barbarian_inactive(id)) + log("Foederati inactive " + BARBARIAN_NAME[tribe] + " from %" + from + " to %" + game.where + ".") + else + log("Foederati " + BARBARIAN_NAME[tribe] + " from %" + from + " to %" + game.where + ".") set_barbarian_location(id, ARMY + game.count) } else { - log("Foederati " + BARBARIAN_NAME[tribe] + " in %" + from + ".") + if (is_barbarian_inactive(id)) + log("Foederati inactive " + BARBARIAN_NAME[tribe] + " in %" + from + ".") + else + log("Foederati " + BARBARIAN_NAME[tribe] + " in %" + from + ".") eliminate_barbarian(id) } resume_take_actions() @@ -3267,7 +3268,7 @@ function auto_play_princeps_senatus() { } function can_play_princeps_senatus() { - return !used_card_event(CARD_S2X) + return !used_card_event(CARD_S2X) && game.sip > 0 } function play_princeps_senatus() { @@ -3299,7 +3300,6 @@ function can_play_force_march() { } function play_force_march() { - // TODO: auto-select general on map? game.state = "force_march_who" } @@ -4372,10 +4372,11 @@ function goto_combat_victory_attacker() { // Surviving Barbarians go home (to active) let tribe = game.combat.target - console.log("BARB", tribe, game.combat) - for (let id = first_barbarian[tribe]; id <= last_barbarian[tribe]; ++id) - if (get_barbarian_location(id) === game.where) - set_barbarian_location(id, BARBARIAN_HOMELAND[tribe]) + if (is_province(game.where)) { + for (let id = first_barbarian[tribe]; id <= last_barbarian[tribe]; ++id) + if (get_barbarian_location(id) === game.where) + set_barbarian_location(id, BARBARIAN_HOMELAND[tribe]) + } } else { if (game.emperor === ARMY + game.combat.attacker) award_combat_legacy(game.current, "Military Emperor Victory", 4) @@ -5079,6 +5080,8 @@ function vp_tie(p) { function goto_game_end() { log_h1("Game End") + game.played.length = 0 + game.crisis[0] = -1 game.crisis[1] = 0 game.crisis[2] = 0 |