summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-18 23:15:45 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-18 23:41:55 +0200
commitdbbe5ae68ffc6210241bbbb6eb86f9e4d0f16956 (patch)
treee6b95e1c5afd1030dca32a3137f4902654c9e174 /play.js
parent0896110768cfa63710c362a4dfa3b15de551b882 (diff)
downloadmaria-dbbe5ae68ffc6210241bbbb6eb86f9e4d0f16956.tar.gz
Mixed stack supreme commander when equal ranks.
Diffstat (limited to 'play.js')
-rw-r--r--play.js41
1 files changed, 16 insertions, 25 deletions
diff --git a/play.js b/play.js
index 4e560aa..b87f53f 100644
--- a/play.js
+++ b/play.js
@@ -677,27 +677,20 @@ function on_blur_piece() {
/* UPDATE UI */
-function layout_general_offset(g, s) {
- // if not selected: number of unselected generals below us
- // if not selected: (number of unselected generals + 1) + number of selected generals below us
- if (!set_has(view.selected, g)) {
- let n = 0
- for (let i = g+1; i < 20; ++i)
- if (view.pos[i] === s && !set_has(view.selected, i))
- ++n
- return n
- } else {
- let n = 0
- for (let i = 0; i < 20; ++i)
- if (view.pos[i] === s && !set_has(view.selected, i))
- ++n
- if (n > 0)
- ++n
- for (let i = g+1; i < 20; ++i)
- if (view.pos[i] === s && set_has(view.selected, i))
- ++n
- return n
- }
+function layout_general_offset(who, here) {
+ let other = -1
+ for (let p = 0; p < 20; ++p)
+ if (view.pos[p] === here && who !== p)
+ other = p
+ if (other < 0)
+ return 0
+ if ((view.supreme & (1 << who)) || view.selected === who)
+ return 1
+ if ((view.supreme & (1 << other)) || view.selected === other)
+ return 0
+ if (who < other)
+ return 1
+ return 0
}
function layout_general_offset_elim(g) {
@@ -1026,10 +1019,8 @@ function on_update() {
for (let v = 16; v >= 0; --v)
action_button_with_argument("value", v, v)
- for (let p = 0; p < 20; ++p) {
- action_button_with_argument("promote", p, "Promote " + piece_abbr[p])
- action_button_with_argument("demote", p, "Demote " + piece_abbr[p])
- }
+ for (let p = 0; p < 20; ++p)
+ action_button_with_argument("supreme", p, power_name[piece_power[p]])
action_button("force_march", "Force march")