summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-01 00:36:33 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-01 00:36:33 +0100
commitd939e4e0146919eb323e62bd59d0b92611fe968a (patch)
tree7cb361411af9f43ad70ca7d376140723124006ab
parent600a5b7bb46e9b7cabc4b50755332ba3fe4e8075 (diff)
downloadmaria-d939e4e0146919eb323e62bd59d0b92611fe968a.tar.gz
show troop total in power banner
-rw-r--r--play.js2
-rw-r--r--rules.js12
2 files changed, 14 insertions, 0 deletions
diff --git a/play.js b/play.js
index 0e885e3..eaa0869 100644
--- a/play.js
+++ b/play.js
@@ -1382,6 +1382,8 @@ function on_update() {
}
}
+ banner += ` \u2014 ${view.pt[pow]} troops`
+
ui.power_header[pow].innerHTML = banner
ui.hand[pow].replaceChildren()
diff --git a/rules.js b/rules.js
index 06c6446..e027f01 100644
--- a/rules.js
+++ b/rules.js
@@ -6189,6 +6189,17 @@ function is_trump_card(c) {
return (game.trump >= 0) && (is_reserve(c) || to_suit(c) === game.trump)
}
+function total_troops_list() {
+ let list = []
+ for (let pow of all_powers) {
+ let n = 0
+ for (let p of all_power_generals[pow])
+ n += game.troops[p]
+ list[pow] = n
+ }
+ return list
+}
+
exports.view = function (state, player) {
game = state
view = {
@@ -6211,6 +6222,7 @@ exports.view = function (state, player) {
troops: mask_troops(player),
hand1: mask_hand1(player),
hand2: mask_hand2(player),
+ pt: total_troops_list(),
discard: total_discard_list(),
contracts: game.contracts,