diff options
-rw-r--r-- | play.js | 2 | ||||
-rw-r--r-- | rules.js | 155 |
2 files changed, 134 insertions, 23 deletions
@@ -1472,6 +1472,8 @@ function on_update() { action_button("play_all", "Play All") + action_button("confirm", "Confirm") + action_button("recruit_general", "Recruit General") action_button("create_army", "Create Army") @@ -25,7 +25,11 @@ const P2 = "Blue" const P3 = "Yellow" const P4 = "Green" -exports.scenarios = [ "Standard", "Expansion", "Random" ] +exports.scenarios = [ + "Standard", + "Expansion - Fixed", + "Expansion - Random", +] exports.roles = function (scenario, options) { if (options.players == 2) @@ -2553,7 +2557,7 @@ function enter_capital() { } if (game.combat) - end_battle() + goto_post_combat() } function resume_occupy_seat_of_power() { @@ -3243,8 +3247,106 @@ function can_play_demagogue() { } function play_demagogue() { - log("Demagogue.") - // TODO + game.state = "demagogue_confirm" +} + +states.demagogue_confirm = { + inactive: "Demagogue", + prompt() { + prompt("Demagogue: Force all other players to reveal and return a card.") + view.actions.confirm = 1 + }, + confirm() { + clear_undo() + log_h3("Demagogue") + game.demagogue = new Array(get_player_count()).fill(-1) + game.count = game.current + game.state = "demagogue" + game.current = next_player() + }, +} + +states.demagogue = { + inactive: "Demagogue", + prompt() { + prompt("Demagogue: Reveal and return one card to your available pile.") + for (let c of current_hand()) + gen_action_card(c) + }, + card(c) { + push_undo() + set_delete(current_hand(), c) + set_add(current_draw(), c) + game.demagogue[game.current] = c + game.state = "demagogue_done" + }, +} + +states.demagogue_done = { + inactive: "Demagogue", + prompt() { + prompt("Demagogue: Done.") + view.actions.done = 1 + }, + done() { + clear_undo() + game.current = next_player() + if (game.current === game.count) + goto_demagogue_reveal() + }, +} + +function goto_demagogue_reveal() { + let mobs = false + for (let p = 0; p < get_player_count(); ++p) { + if (p !== game.current) { + let c = game.demagogue[p] + logi(PLAYER_NAME[p] + " " + card_name(c)) + if (card_value(c) === 1) + mobs = true + else + game.demagogue[p] = -1 + } + } + if (mobs) + game.state = "demagogue_mobs" + else + end_demagogue() +} + +states.demagogue_mobs = { + inactive: "Demagogue", + prompt() { + prompt("Demagogue: Place mobs in provinces governed by players who returned a 1 value card.") + view.color = POPULACE + for (let where = 0; where < 12; ++where) { + let p = get_province_player(where) + if (game.demagogue[p] >= 0) + gen_action_region(where) + } + view.actions.pass = 1 + }, + region(where) { + push_undo() + let p = get_province_player(where) + logi("Mob in %" + where) + set_mobs(where, get_mobs(where) + 1) + game.demagogue[p] = -1 + for (let p = 0; p < game.demagogue.length; ++p) + if (game.demagogue[p] >= 0) + return + end_demagogue() + }, + pass() { + push_undo() + end_demagogue() + }, +} + +function end_demagogue() { + log_br() + game.demagogue = undefined + game.state = "take_actions" } // === COMBAT === @@ -3928,7 +4030,7 @@ function award_legacy_summary(p, reason, n) { function goto_combat_no_victory() { log("Both sides eliminated.") game.combat.killed = 0 - end_battle() + goto_post_combat() } function goto_combat_victory_defender() { @@ -3941,7 +4043,7 @@ function goto_combat_victory_defender() { log(BARBARIAN_NAME[game.combat.target] + " won.") else if (game.combat.type === "rival_emperor") log(RIVAL_EMPEROR_NAME[game.combat.target] + " won.") - end_battle() + goto_post_combat() } function goto_combat_victory_attacker() { @@ -3966,7 +4068,7 @@ function goto_combat_victory_attacker() { if (can_enter_capital(game.where)) game.state = "advance_after_combat" else - end_battle() + goto_post_combat() } states.advance_after_combat = { @@ -3982,13 +4084,11 @@ states.advance_after_combat = { }, pass() { push_undo() - end_battle() + goto_post_combat() }, } -function end_battle() { - log_br() - +function goto_post_combat() { // Deselect eliminated general... if (game.selected_general >= 0 && get_general_location(game.selected_general) === AVAILABLE) game.selected_general = -1 @@ -4014,7 +4114,10 @@ function goto_free_increase_support_level() { game.state = "free_increase_support_level" return } else { - log("Kept for cost reduction.") + if (bit <= 8) + log("Kept for senate credit.") + else + log("Kept for military credit.") game.killed |= bit game.combat.killed &= ~bit } @@ -4023,8 +4126,7 @@ function goto_free_increase_support_level() { if (game.combat.target === "barbarians" && has_card_event(CARD_S4X)) { game.state = "triumph" } else { - game.combat = null - game.state = "take_actions" + end_combat() } } @@ -4045,8 +4147,11 @@ states.free_increase_support_level = { }, keep() { push_undo() - log("Kept for cost reduction.") let bit = find_next_killed_in_combat() + if (bit <= 8) + log("Kept for senate credit.") + else + log("Kept for military credit.") game.killed |= bit game.combat.killed &= ~bit goto_free_increase_support_level() @@ -4066,16 +4171,20 @@ states.triumph = { award_legacy(game.current, "Triumph", game.combat.dtaken) - game.combat = null - game.state = "take_actions" + end_combat() }, pass() { push_undo() - game.combat = null - game.state = "take_actions" + end_combat() }, } +function end_combat() { + log_br() + game.combat = null + game.state = "take_actions" +} + // === SUPPORT CHECK === function goto_support_check() { @@ -4765,6 +4874,8 @@ exports.setup = function (seed, scenario, options) { game.events = setup_events() + log_h1("Time of Crisis") + switch (scenario) { default: case "Standard": @@ -4780,7 +4891,7 @@ exports.setup = function (seed, scenario, options) { setup_market_pile(CARD_P4), ] break - case "Expansion": + case "Expansion - Fixed": game.market = [ setup_market_pile(CARD_M2), setup_market_pile(CARD_S2), @@ -4802,7 +4913,7 @@ exports.setup = function (seed, scenario, options) { setup_market_pile(CARD_P4X), ] break - case "Random": + case "Expansion - Random": game.market = [ setup_market_pile(random(2) ? CARD_M2 : CARD_M2X), setup_market_pile(random(2) ? CARD_S2 : CARD_S2X), @@ -4838,8 +4949,6 @@ exports.setup = function (seed, scenario, options) { update_neutral_italia() - log_h1("Time of Crisis") - game.first = game.current = random(player_count) return save_game() |