summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-06-02 12:40:54 +0200
committerTor Andersson <tor@ccxvii.net>2024-06-02 12:58:22 +0200
commit7b341a0f43bb11a77b765d49c80e9baaf51e568c (patch)
treec4e32b4b663cf97e977aadb368a01e777e7af9df /rules.js
parente7deec7acc1e29b60f02312be64bbe2bd0f22780 (diff)
downloadfriedrich-7b341a0f43bb11a77b765d49c80e9baaf51e568c.tar.gz
show approximate ceil(count / 5) discard piles
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js24
1 files changed, 23 insertions, 1 deletions
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,