diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-08-02 15:40:44 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-27 12:00:41 +0100 |
commit | 547dadf730c28797c25ab566104d3e2c5d4f8f80 (patch) | |
tree | fd50ca176e19a101eee3e70945e9ac594b073d37 /rules.js | |
parent | c0073245bdc1fcae00cd7a216e5e2fac23aa6f31 (diff) | |
download | time-of-crisis-547dadf730c28797c25ab566104d3e2c5d4f8f80.tar.gz |
v2: temple
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() |