summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-08-02 15:40:44 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-27 12:00:41 +0100
commit547dadf730c28797c25ab566104d3e2c5d4f8f80 (patch)
treefd50ca176e19a101eee3e70945e9ac594b073d37
parentc0073245bdc1fcae00cd7a216e5e2fac23aa6f31 (diff)
downloadtime-of-crisis-547dadf730c28797c25ab566104d3e2c5d4f8f80.tar.gz
v2: temple
-rw-r--r--rules.js68
1 files changed, 66 insertions, 2 deletions
diff --git a/rules.js b/rules.js
index 91c3c7e..1343993 100644
--- a/rules.js
+++ b/rules.js
@@ -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()