summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-27 23:55:30 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-28 23:33:22 +0100
commit24a1e303b84fad2a4c60c037109943025912999e (patch)
tree4ff00ec592a7b4723bcdeeb838dc9aae740839cd /rules.js
parentdfc5632eef35ed36a5b1f400292c2739802d85f0 (diff)
downloadmaria-24a1e303b84fad2a4c60c037109943025912999e.tar.gz
separate subsidy and returned card arrays and prompts
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js49
1 files changed, 40 insertions, 9 deletions
diff --git a/rules.js b/rules.js
index ca83974..16f9481 100644
--- a/rules.js
+++ b/rules.js
@@ -1681,7 +1681,9 @@ function search_hussar_bfs(from) {
function for_each_card_in_hand(f) {
for (let c of game.hand1[game.power])
f(c)
- for (let c of game.hand2[game.power]) // subsidies and returned cards
+ for (let c of game.hand2[game.power]) // subsidies
+ f(c)
+ for (let c of game.hand3[game.power]) // returned cards
f(c)
}
@@ -1692,10 +1694,11 @@ function gen_cards_in_hand() {
function remove_card_in_hand(c) {
set_delete(game.hand1[game.power], c)
set_delete(game.hand2[game.power], c)
+ set_delete(game.hand3[game.power], c)
}
function count_cards_in_hand() {
- return game.hand1[game.power].length + game.hand2[game.power].length > 0
+ return game.hand1[game.power].length + game.hand2[game.power].length + game.hand3[game.power] > 0
}
function find_largest_discard(u) {
@@ -1714,6 +1717,8 @@ function count_used_cards() {
held[to_deck(c)]++
for (let c of game.hand2[pow])
held[to_deck(c)]++
+ for (let c of game.hand3[pow])
+ held[to_deck(c)]++
}
// count cards in political display
@@ -1901,6 +1906,10 @@ function end_tactical_cards() {
set_add(game.hand1[game.power], c)
game.hand2[game.power] = []
+ for (let c of game.hand3[game.power])
+ set_add(game.hand1[game.power], c)
+ game.hand3[game.power] = []
+
for (let c of game.draw)
set_add(game.hand1[game.power], c)
delete game.draw
@@ -1936,7 +1945,13 @@ states.tactical_cards_show = {
inactive: "draw tactical cards",
prompt() {
view.draw = game.draw
- prompt("Draw " + format_card_list_prompt(game.draw) + ".")
+ let str = "Draw " + format_card_list_prompt(game.draw)
+ if (game.hand2[game.power].length > 0)
+ str += " (and " + format_card_list_prompt(game.hand2[game.power]) + " from subsidies)"
+ if (game.hand3[game.power].length > 0)
+ str += " (and " + format_card_list_prompt(game.hand3[game.power]) + " from political display)"
+ str += "."
+ prompt(str)
view.actions.next = 1
},
next() {
@@ -2231,7 +2246,7 @@ states.supply_hussars = {
// put back into hand unused cards
for (let c of game.supply.pool)
- set_add(game.hand2[game.power], c)
+ set_add(game.hand1[game.power], c)
delete game.supply.pool
delete game.supply.used
@@ -3379,7 +3394,7 @@ function end_re_enter_train() {
// put back into hand unused cards
for (let c of game.recruit.pool)
- set_add(game.hand2[game.power], c)
+ set_add(game.hand1[game.power], c)
delete game.recruit
@@ -3687,7 +3702,7 @@ function end_recruit() {
// put back into hand unused cards
for (let c of game.recruit.pool)
- set_add(game.hand2[game.power], c)
+ set_add(game.hand1[game.power], c)
delete game.recruit
} else {
@@ -4525,7 +4540,7 @@ function goto_politics() {
// 25.1 Return face-down (previously placed) TCs to the players
for (let pow of all_major_powers) {
for (let c of game.face_down[pow])
- set_add(game.hand2[pow], c)
+ set_add(game.hand3[pow], c)
game.face_down[pow] = []
}
@@ -5441,7 +5456,7 @@ states.recruit_for_expeditionary_corps = {
// put back into hand unused cards
for (let c of game.recruit.pool)
- set_add(game.hand2[game.power], c)
+ set_add(game.hand1[game.power], c)
delete game.recruit
@@ -6975,6 +6990,8 @@ function make_tactics_discard(n) {
return false
if (set_has(game.hand2[pow], c))
return false
+ if (set_has(game.hand3[pow], c))
+ return false
}
for (let pow of all_major_powers) {
if (set_has(game.face_up[pow], c))
@@ -7014,6 +7031,7 @@ exports.setup = function (seed, scenario, _options) {
deck: null,
hand1: [ [], [], [], [], [], [] ],
hand2: [ [], [], [], [], [], [] ],
+ hand3: [ [], [], [], [], [], [] ],
deals: [], // [ power, promise, turn ] tuples
contracts: [
@@ -7230,7 +7248,7 @@ function mask_hand1(player) {
if (player_from_power(pow) === player)
view_hand[pow] = game.hand1[pow]
else
- view_hand[pow] = game.hand1[pow].concat(game.hand2[pow]).map(c => c & ~127)
+ view_hand[pow] = game.hand1[pow].concat(game.hand2[pow], game.hand3[pow]).map(c => c & ~127)
}
return view_hand
}
@@ -7246,6 +7264,17 @@ function mask_hand2(player) {
return view_hand
}
+function mask_hand3(player) {
+ let view_hand = []
+ for (let pow of all_powers) {
+ if (player_from_power(pow) === player)
+ view_hand[pow] = game.hand3[pow]
+ else
+ view_hand[pow] = []
+ }
+ return view_hand
+}
+
function mask_face_down() {
return game.face_down.map(list => list.map(c => c & ~127))
}
@@ -7287,6 +7316,7 @@ exports.view = function (state, player) {
troops: mask_troops(player),
hand1: mask_hand1(player),
hand2: mask_hand2(player),
+ hand3: mask_hand3(player),
pt: total_troops_list(),
discard: total_discard_list(),
@@ -7318,6 +7348,7 @@ exports.view = function (state, player) {
view.troops = game.troops
view.hand1 = game.hand1
view.hand2 = game.hand2
+ view.hand3 = game.hand3
} else if (game.active !== player) {
let inactive = states[game.state].inactive || game.state
if (typeof inactive === "function")