diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 68 |
1 files changed, 66 insertions, 2 deletions
@@ -1078,6 +1078,14 @@ function count_own_basilicas() { return n } +function count_own_temples() { + let n = 0 + for (let where = 0; where < 12; ++where) + if (is_own_province(where) && has_temple(where)) + ++n + return n +} + function roll_dice(count, target) { let hits = 0 while (count > 0) { @@ -1359,16 +1367,72 @@ function goto_upkeep() { // === CRISIS === function goto_crisis() { + // Temples + if (is_deluxe()) { + game.count = count_own_temples() + } + + roll_crisis() +} + +function roll_crisis() { game.crisis[0] = -1 game.crisis[1] = roll_die() game.crisis[2] = roll_die() game.crisis[3] = 0 game.crisis[4] = 0 - let sum = game.crisis[1] + game.crisis[2] - log("Crisis B" + game.crisis[1] + " W" + game.crisis[2]) + if (is_deluxe()) { + if (game.count > 0) { + game.state = "use_temple" + return + } + } + + resolve_crisis() +} + +states.use_temple = { + inactive: "Temple", + prompt() { + let sum = game.crisis[1] + game.crisis[2] + + let name + if (sum === 2) + name = "Ira Deorum" + else if (sum === 7) + name = "Event" + else if (sum === 12) + name = "Pax Deorum" + else { + if (get_player_count() === 2) + name = BARBARIAN_NAME[CRISIS_TABLE_2P[sum - 2]] + else if (get_player_count() === 3) + name = BARBARIAN_NAME[CRISIS_TABLE_3P[sum - 2]] + else + name = BARBARIAN_NAME[CRISIS_TABLE_4P[sum - 2]] + } + + view.prompt = `Crisis: Rolled ${sum} ${name}. Use Temple to re-roll?` + view.actions.temple = 1 + view.actions.pass = 1 + }, + temple() { + log("Temple re-roll.") + --game.count + roll_crisis() + }, + pass() { + game.count = 0 + resolve_crisis() + }, +} + +function resolve_crisis() { + let sum = game.crisis[1] + game.crisis[2] + if (sum === 2) { logi("Ira Deorum") return goto_ira_deorum() |