From 750134aa2c8a249c140a7aefd04ea3d260653adc Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 10 Jun 2022 00:27:17 +0200 Subject: Add event card house rules. --- create.html | 17 ++++++++++++++ rules.js | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 84 insertions(+), 8 deletions(-) diff --git a/create.html b/create.html index 090b354..3ff4b7a 100644 --- a/create.html +++ b/create.html @@ -10,6 +10,7 @@ Players may swap any blocks on the map as long as the original number of deployed blocks in each city is maintained. +

Optional rules:

@@ -17,3 +18,19 @@ Optional rules:
Julius Caesar goes first on the first turn regardless of the cards played.
+ +

+House rules: +
+
+
+
+ diff --git a/rules.js b/rules.js index cb1c41e..182f1cb 100644 --- a/rules.js +++ b/rules.js @@ -14,6 +14,12 @@ exports.roles = [ const { CARDS, SPACES, EDGES, BLOCKS } = require('./data'); const APOLLO = 1; +const JUPITER = 2; +const MARS = 3; +const MERCURY = 4; +const NEPTUNE = 5; +const PLUTO = 6; +const VULCAN = 7; const OBSERVER = "Observer"; const BOTH = "Both"; @@ -188,16 +194,23 @@ function roll_d6() { function reset_deck() { let deck = []; for (let c = 1; c <= 27; ++c) - deck.push(c); + if (!game.removed || !game.removed.includes(c)) + deck.push(c); return deck; } function deal_cards(deck, n) { let hand = []; - for (let i = 0; i < n; ++i) { + let events = 0; + let max_events = (game.max_2_events ? 2 : n); + while (hand.length < n) { let c = random(deck.length); - hand.push(deck[c]); - deck.splice(c, 1); + if (events < max_events || deck[c] > 7) { + if (deck[c] <= 7) + ++events; + hand.push(deck[c]); + deck.splice(c, 1); + } } return hand; } @@ -2493,14 +2506,60 @@ exports.setup = function (seed, scenario, options) { log: [], }; - if (options && options.tournament) { - log("Tournament rule:\nCaesar is the first player on the very first turn of the game."); - logbr(); + if (options.tournament) { + log("Caesar goes first on the first turn regardless of the cards played."); game.tournament = 1; } + if (options.max_2_events) { + log("At most 2 events per hand."); + game.max_2_events = 1; + } + + game.removed = []; + + if (options.remove_apollo || options.remove_all_events) { + log("Apollo removed from deck."); + game.removed.push(APOLLO); + } + + if (options.remove_jupiter || options.remove_all_events) { + log("Jupiter removed from deck."); + game.removed.push(JUPITER); + } + + if (options.remove_mars || options.remove_all_events) { + log("Mars removed from deck."); + game.removed.push(MARS); + } + + if (options.remove_mercury || options.remove_all_events) { + log("Mercury removed from deck."); + game.removed.push(MERCURY); + } + + if (options.remove_neptune || options.remove_all_events) { + log("Neptune removed from deck."); + game.removed.push(NEPTUNE); + } + + if (options.remove_pluto || options.remove_all_events) { + log("Pluto removed from deck."); + game.removed.push(PLUTO); + } + + if (options.remove_vulcan || options.remove_all_events) { + log("Vulcan removed from deck."); + game.removed.push(VULCAN); + } + + if (game.removed.length === 0) + delete game.removed; + + logbr(); + // Option for backwards compatible replays. - if (options && options.automatic_disruption) + if (options.automatic_disruption) game.automatic_disruption = 1; setup_historical_deployment(); -- cgit v1.2.3