summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-02-25 15:23:57 +0100
committerTor Andersson <tor@ccxvii.net>2023-05-03 18:48:15 +0200
commit3bea3cbdf46d84a2476404bb07ff16ea14a4e637 (patch)
tree51961450894b77babd554a27cf90582611afc7f5
parent3d51314af3e348300736d36660e04c336b86fe99 (diff)
downloadandean-abyss-3bea3cbdf46d84a2476404bb07ff16ea14a4e637.tar.gz
Seeded card setup.
-rw-r--r--play.html3
-rw-r--r--rules.js85
2 files changed, 35 insertions, 53 deletions
diff --git a/play.html b/play.html
index 9b68a9d..d5994e0 100644
--- a/play.html
+++ b/play.html
@@ -28,9 +28,10 @@
<a class="menu_item" href="info/cards.html" target="_blank")">Cards</a>
<div class="menu_separator"></div>
<div class="menu_item" onclick="send_restart('Standard')">&#x26a0; Restart Standard</div>
- <div class="menu_item" onclick="send_restart('Open')">&#x26a0; <s>Restart Open</s></div>
<div class="menu_item" onclick="send_restart('Short')">&#x26a0; Restart Short</div>
<div class="menu_item" onclick="send_restart('Quick')">&#x26a0; Restart Quick</div>
+ <div class="menu_item" onclick="send_restart('3P Quick')">&#x26a0; Restart 3P Quick</div>
+ <div class="menu_item" onclick="send_restart('2P Quick')">&#x26a0; Restart 2P Quick</div>
</div>
</div>
<div class="icon_button" onclick="toggle_pieces()"><img src="/images/earth-america.svg"></div>
diff --git a/rules.js b/rules.js
index 717b521..e08a270 100644
--- a/rules.js
+++ b/rules.js
@@ -203,16 +203,24 @@ exports.setup = function (seed, scenario, options) {
setup_standard()
- if (scenario === "Quick") {
+ if (scenario.includes("Quick")) {
log_h1("Scenario: Quick")
setup_quick()
- setup_quick_deck()
- } else if (scenario === "Short") {
- setup_short_deck()
+ setup_deck(2, 6, 6)
+ } else if (scenario.includes("Short")) {
+ if (options.seeded)
+ setup_deck(3, 10, 5)
+ else
+ setup_deck(3, 0, 15)
} else {
- setup_standard_deck()
+ if (options.seeded)
+ setup_deck(4, 10, 5)
+ else
+ setup_deck(4, 0, 15)
}
+ log("DECK " + game.deck.join(", "))
+
update_control()
goto_card()
@@ -327,54 +335,27 @@ function shuffle_all_cards() {
return deck
}
-function setup_standard_deck() {
- let cards = shuffle_all_cards()
- let piles = [
- cards.slice(0, 15),
- cards.slice(15, 15+15),
- cards.slice(30, 30+15),
- cards.slice(45, 45+15),
- ]
- piles[0].push(73)
- piles[1].push(74)
- piles[2].push(75)
- piles[3].push(76)
- shuffle(piles[0])
- shuffle(piles[1])
- shuffle(piles[2])
- shuffle(piles[3])
- game.deck = piles[0].concat(piles[1], piles[2], piles[3])
-}
-
-function setup_short_deck() {
- let cards = shuffle_all_cards()
- let piles = [
- cards.slice(0, 15),
- cards.slice(15, 15+15),
- cards.slice(30, 30+15),
- ]
- piles[0].push(73)
- piles[1].push(74)
- piles[2].push(75)
- shuffle(piles[0])
- shuffle(piles[1])
- shuffle(piles[2])
- game.deck = piles[0].concat(piles[1], piles[2], piles[3])
-}
-
-function setup_quick_deck() {
+function setup_deck(count, a, b) {
let cards = shuffle_all_cards()
- let piles = [
- cards.slice(0, 6),
- cards.slice(6, 6+6),
- cards.slice(12, 12+6),
- cards.slice(24, 24+6),
- ]
- piles[1].push(73)
- piles[3].push(74)
- shuffle(piles[1])
- shuffle(piles[3])
- game.deck = piles[0].concat(piles[1], piles[2], piles[3])
+ let deck = []
+ let pile
+ let i = 0
+ for (let p = 0; p < count; ++p) {
+ if (a > 0) {
+ pile = cards.slice(i, i + a)
+ i += a
+ shuffle(pile)
+ deck = deck.concat(pile)
+ }
+ if (b > 0) {
+ pile = cards.slice(i, i + b)
+ i += b
+ pile.push(73 + p)
+ shuffle(pile)
+ deck = deck.concat(pile)
+ }
+ }
+ game.deck = deck
}
function set_support(place, amount) {