From c4348c579a1abc8f763855c8e930ecb890022d77 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 26 Mar 2022 14:26:48 +0100 Subject: New battle CSS. --- play.html | 33 ++++++++++--------------------- play.js | 67 ++++++++++++++++++++++++++++++++++++--------------------------- rules.js | 16 +++++---------- 3 files changed, 53 insertions(+), 63 deletions(-) diff --git a/play.html b/play.html index d2b6869..8d84f2b 100644 --- a/play.html +++ b/play.html @@ -15,30 +15,17 @@ - - - - - - - - - - - - - - - - - - - - -
-
+
+
+
+
+
+
+
+
+
@@ -87,7 +75,6 @@
- b) ? 1 : 0; + return (aa < bb) ? -1 : (aa > bb) ? 1 : 0; +} + +function sort_battle_row(root) { + let swapped; + let children = root.children; + do { + swapped = false; + for (let i = 1; i < children.length; ++i) { + if (compare_blocks(children[i-1].block, children[i].block) > 0) { + children[i].after(children[i-1]); + swapped = true; + } + } + } while (swapped); +} + function update_battle() { function fill_cell(name, list, reserve) { let cell = window[name]; @@ -596,6 +615,9 @@ function update_battle() { for (let block of list) { ui.present.add(block); + if (!cell.contains(ui.battle_menu[block])) + cell.appendChild(ui.battle_menu[block]); + if (block === view.who) ui.battle_block[block].classList.add("selected"); else @@ -640,37 +662,24 @@ function update_battle() { } for (let b in BLOCKS) { - if (ui.present.has(b)) { - if (!cell.contains(ui.battle_menu[b])) - cell.appendChild(ui.battle_menu[b]); - } else { + if (!ui.present.has(b)) { if (cell.contains(ui.battle_menu[b])) cell.removeChild(ui.battle_menu[b]); } } + + sort_battle_row(cell); } if (player === LANCASTER) { fill_cell("FR", view.battle.LR, true); - fill_cell("FA", view.battle.LA, false); - fill_cell("FB", view.battle.LB, false); - fill_cell("FC", view.battle.LC, false); - fill_cell("FD", view.battle.LD, false); - fill_cell("EA", view.battle.YA, false); - fill_cell("EB", view.battle.YB, false); - fill_cell("EC", view.battle.YC, false); - fill_cell("ED", view.battle.YD, false); + fill_cell("FF", view.battle.LF, false); + fill_cell("EF", view.battle.YF, false); fill_cell("ER", view.battle.YR, true); } else { fill_cell("ER", view.battle.LR, true); - fill_cell("EA", view.battle.LA, false); - fill_cell("EB", view.battle.LB, false); - fill_cell("EC", view.battle.LC, false); - fill_cell("ED", view.battle.LD, false); - fill_cell("FA", view.battle.YA, false); - fill_cell("FB", view.battle.YB, false); - fill_cell("FC", view.battle.YC, false); - fill_cell("FD", view.battle.YD, false); + fill_cell("EF", view.battle.LF, false); + fill_cell("FF", view.battle.YF, false); fill_cell("FR", view.battle.YR, true); } } diff --git a/rules.js b/rules.js index 717ec41..06fcf20 100644 --- a/rules.js +++ b/rules.js @@ -3351,8 +3351,9 @@ states.game_over = { function make_battle_view() { let battle = { - LA: [], LB: [], LC: [], LD: [], LR: [], - YA: [], YB: [], YC: [], YD: [], YR: [], + round: game.battle_round, + LF: [], LR: [], + YF: [], YR: [], flash: game.flash }; @@ -3366,16 +3367,9 @@ function make_battle_view() { } fill_cell(battle.LR, LANCASTER, b => is_battle_reserve(b)); - fill_cell(battle.LA, LANCASTER, b => !is_battle_reserve(b) && block_initiative(b) === 'A'); - fill_cell(battle.LB, LANCASTER, b => !is_battle_reserve(b) && block_initiative(b) === 'B'); - fill_cell(battle.LC, LANCASTER, b => !is_battle_reserve(b) && block_initiative(b) === 'C'); - fill_cell(battle.LD, LANCASTER, b => !is_battle_reserve(b) && block_initiative(b) === 'D'); - + fill_cell(battle.LF, LANCASTER, b => !is_battle_reserve(b)); fill_cell(battle.YR, YORK, b => is_battle_reserve(b)); - fill_cell(battle.YA, YORK, b => !is_battle_reserve(b) && block_initiative(b) === 'A'); - fill_cell(battle.YB, YORK, b => !is_battle_reserve(b) && block_initiative(b) === 'B'); - fill_cell(battle.YC, YORK, b => !is_battle_reserve(b) && block_initiative(b) === 'C'); - fill_cell(battle.YD, YORK, b => !is_battle_reserve(b) && block_initiative(b) === 'D'); + fill_cell(battle.YF, YORK, b => !is_battle_reserve(b)); return battle; } -- cgit v1.2.3