diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 41 |
1 files changed, 16 insertions, 25 deletions
@@ -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") |