From 7b341a0f43bb11a77b765d49c80e9baaf51e568c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 2 Jun 2024 12:40:54 +0200 Subject: show approximate ceil(count / 5) discard piles --- rules.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 89d84e3..ae613e7 100644 --- a/rules.js +++ b/rules.js @@ -1050,7 +1050,7 @@ function find_largest_discard(u) { throw "OUT OF CARDS" } -function next_tactics_deck() { +function count_used_cards() { let held = [ 0, 0, 0, 0, 0 ] // count cards in hands @@ -1058,12 +1058,26 @@ function next_tactics_deck() { for (let c of game.hand[pow]) held[to_deck(c)]++ } + + // count cards currently being drawn if (game.draw) for (let c of game.draw) held[to_deck(c)]++ + + // count cards remaining in deck + for (let c of game.deck) + held[to_deck(c)]++ + + // set-aside prussian card if (game.oo > 0) held[to_deck(game.oo)]++ + return held +} + +function next_tactics_deck() { + let held = count_used_cards() + // find next unused deck for (let i = 1; i < 5; ++i) { if (held[i] === 0) { @@ -4425,6 +4439,13 @@ function total_troops_list() { return list } +function total_discard_list() { + let discard = count_used_cards() + for (let i = 0; i < 5; ++i) + discard[i] = Math.ceil((50 - discard[i]) / 5) + return discard +} + exports.view = function (state, player) { game = state view = { @@ -4440,6 +4461,7 @@ exports.view = function (state, player) { hand: mask_hand(player), oo: game.oo, pt: total_troops_list(), + discard: total_discard_list(), power: game.power, retro: game.retro, -- cgit v1.2.3