diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-04-30 01:33:24 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-04-30 01:50:00 +0200 |
commit | d0b46006ed6c282e3aae5fe128c3422b260ee112 (patch) | |
tree | d09330eb064f01e9fe045952aef0064d097b4383 | |
parent | 29a76580ca56f5fe1e45107800c7679abb377a16 (diff) | |
download | plantagenet-d0b46006ed6c282e3aae5fe128c3422b260ee112.tar.gz |
asset and unit stacking
-rw-r--r-- | play.css | 99 | ||||
-rw-r--r-- | play.js | 30 | ||||
-rw-r--r-- | rules.ts | 24 |
3 files changed, 115 insertions, 38 deletions
@@ -353,12 +353,17 @@ body.Lancaster #plan_actions .york { display: none } border: 2px solid transparent; border-radius: 8px; box-shadow: 0 0 0 1px #444, 0 1px 4px #0008; + margin: 3px; } .asset.action { box-shadow: 0 0 0 1px #444, 0 0 0 4px white !important; } +.prov + .prov { margin-bottom: -30px; } +.coin + .coin { margin-bottom: -30px; } +.cart + .cart { margin-bottom: -30px; } + /* UNITS */ .unit { @@ -369,9 +374,15 @@ body.Lancaster #plan_actions .york { display: none } .unit.shape { width: 43px; height: 35px; - filter: drop-shadow(0px 2px 2px #0004); + margin: -26px 0 0px 0px; } +.unit.men_at_arms { background-image: url(images/unit_men_at_arms.svg) } +.unit.longbowmen { background-image: url(images/unit_longbowmen.svg) } +.unit.militia { background-image: url(images/unit_militia.svg) } +.unit.mercenaries { background-image: url(images/unit_mercenaries.svg) } +.unit.burgundians { background-image: url(images/unit_handgunners.svg) } + .unit.retinue { border: 2px solid gray; width: 46px; @@ -499,41 +510,73 @@ body.shift .mat .capabilities { .mat .board .routed_retinue_vassals { position: absolute; - top: 130px; + top: 240px; left: 24px; + width: 170px; + height: 0px; display: flex; + align-content: center; flex-wrap: wrap; gap: 5px; } +.break { + flex-basis: 100%; + width: 0; + height: 0; +} + .mat .board .troops { position: absolute; - top: 36px; + top: 80px; right: 0px; - width: 172px; + width: 170px; + height: 60px; display: flex; flex-wrap: wrap; + flex-direction: column-reverse; + justify-content: end; + align-content: center; gap: 0px; } .mat .board .routed_troops { position: absolute; - bottom: 144px; + top: 170px; right: 0px; - width: 172px; + width: 170px; + height: 60px; display: flex; flex-wrap: wrap; + flex-direction: column-reverse; + justify-content: end; + align-content: center; gap: 0px; } +.defender .att .troops, +.attacker .def .troops, +.defender .att .routed_troops, +.attacker .def .routed_troops +{ + flex-direction: column; + justify-content: start; +} + +.defender .att .troops .shape, +.attacker .def .troops .shape, +.defender .att .routed_troops .shape, +.attacker .def .routed_troops .shape { + margin: 0 0 -26px 0; +} + .mat .board .marker_area { pointer-events: none; position: absolute; - top: 240px; - left: 24px; - width: 172px; + top: -18px; + right: 18px; + height: 50px; display: flex; - justify-content: center; align-items: center; flex-wrap: wrap; gap: 5px; @@ -544,29 +587,31 @@ body.shift .mat .capabilities { position: absolute; top: 305px; left: 24px; - width: 172px; + width: 170px; + height: 40px; display: flex; justify-content: center; flex-wrap: wrap; - gap: 5px; + gap: 4px; } .mat .board .assets { position: absolute; - top: 236px; - - //left: 210px; - //width: 162px; - left: 222px; - width: 140px; - height: 122px; - + bottom: 22px; + right: 0px; + width: 170px; + height: 150px; display: flex; - justify-content: center; + justify-content: end; align-content: center; - flex-direction: column; + flex-direction: column-reverse; flex-wrap: wrap; - gap: 5px; +} + +.defender .att .assets, +.attacker .def .assets +{ + justify-content: start; } /* BATTLE GRID WITH LORD MATS */ @@ -602,8 +647,12 @@ body.shift .mat .capabilities { .attacker .def, .defender .att .unit, .attacker .def .unit, -.defender .att .asset, -.attacker .def .asset, +.defender .att .assets, +.attacker .def .assets, +.defender .att .valour, +.attacker .def .valour, +.defender .att .fled, +.attacker .def .fled, .defender .att .moved_fought, .attacker .def .moved_fought, .defender .att .feed, @@ -511,10 +511,10 @@ function build_lord_mat(lord, ix, side, name) { ui.valour_area[ix] = build_div(board, "valour_area") ui.marker_area[ix] = build_div(board, "marker_area") - ui.lord_fled[ix] = build_div(ui.marker_area[ix], "marker square fled hide") - ui.lord_feed[ix] = build_div(ui.marker_area[ix], "marker small feed x2") ui.lord_moved1[ix] = build_div(ui.marker_area[ix], "marker square moved_fought one hide") ui.lord_moved2[ix] = build_div(ui.marker_area[ix], "marker square moved_fought two hide") + ui.lord_fled[ix] = build_div(ui.marker_area[ix], "marker square fled hide") + ui.lord_feed[ix] = build_div(ui.marker_area[ix], "marker small feed x2") ui.mat[ix] = mat register_action(ui.mat_card[ix], "lord", ix) @@ -944,15 +944,15 @@ function add_vassal(parent, vassal, lord, routed) { parent.appendChild(elt) } -function add_force(parent, type, lord, routed) { +function add_force(parent, type, lord, routed, first) { let elt if (routed) { - if (is_action(routed_force_action_name[type], lord)) + if (first && is_action(routed_force_action_name[type], lord)) elt = get_cached_element("action unit " + force_class_name[type], routed_force_action_name[type], lord) else elt = get_cached_element("unit " + force_class_name[type], routed_force_action_name[type], lord) } else { - if (is_action(force_action_name[type], lord)) + if (first && is_action(force_action_name[type], lord)) elt = get_cached_element("action unit " + force_class_name[type], force_action_name[type], lord) else elt = get_cached_element("unit " + force_class_name[type], force_action_name[type], lord) @@ -960,9 +960,9 @@ function add_force(parent, type, lord, routed) { parent.appendChild(elt) } -function add_asset(parent, type, n, lord) { +function add_asset(parent, type, n, lord, first) { let elt - if (is_action(asset_action_name[type], lord)) + if (first && is_action(asset_action_name[type], lord)) elt = get_cached_element("action asset " + asset_action_name[type] + " x" + n, asset_action_name[type], lord) else elt = get_cached_element("asset " + asset_action_name[type] + " x" + n) @@ -985,8 +985,10 @@ function update_forces(parent, a, b, forces, lord_ix, routed) { } else { let n = map_get_pack4(forces, lord_ix, i, 0) for (let k = 0; k < n; ++k) { - add_force(parent, i, lord_ix, routed) + add_force(parent, i, lord_ix, routed, k === n-1) } + if (i > 1) + parent.appendChild(get_cached_element("break")) } } } @@ -997,22 +999,24 @@ function update_assets(parent, assets, lord_ix) { let n = map_get_pack4(assets, lord_ix, i, 0) if (asset_type_x34[i]) { while (n >= 4) { - add_asset(parent, i, 4, lord_ix) n -= 4 + add_asset(parent, i, 4, lord_ix, n === 0) } while (n >= 3) { - add_asset(parent, i, 3, lord_ix) n -= 3 + add_asset(parent, i, 3, lord_ix, n === 0) } } while (n >= 2) { - add_asset(parent, i, 2, lord_ix) n -= 2 + add_asset(parent, i, 2, lord_ix, n === 0) } while (n >= 1) { - add_asset(parent, i, 1, lord_ix) n -= 1 + add_asset(parent, i, 1, lord_ix, n === 0) } + if (i < 2) + parent.appendChild(get_cached_element("break")) } } @@ -1499,9 +1503,9 @@ function on_update() { // Muster & Spoils action_button("take_prov", "Provender") - action_button("take_coin", "Coin") action_button("take_ship", "Ship") action_button("take_cart", "Cart") + action_button("take_all", "Take all") action_button("levy_troops", "Levy Troops") action_button("levy_beloved_warwick", "Beloved Warwick") action_button("levy_irishmen", "Irishmen") @@ -235,6 +235,7 @@ interface State { sail?(): void, stronghold?(): void, supply?(): void, + take_all?(): void, take_cart?(): void, take_prov?(): void, take_ship?(): void, @@ -5485,6 +5486,8 @@ function prompt_spoils() { view.actions.take_prov = 1 if (game.spoils[CART] > 0) view.actions.take_cart = 1 + if (game.spoils[PROV] > 0 || game.spoils[CART] > 0) + view.actions.take_all = 1 } function take_spoils(type: Asset) { @@ -5494,6 +5497,13 @@ function take_spoils(type: Asset) { game.who = NOBODY } +function take_all_spoils() { + add_lord_assets(game.who, PROV, game.spoils[PROV]) + add_lord_assets(game.who, CART, game.spoils[CART]) + game.spoils = [ 0, 0, 0 ] + game.who = NOBODY +} + function goto_exile_spoils() { round_spoils() if (has_any_spoils()) { @@ -5549,6 +5559,11 @@ states.exile_spoils = { take_spoils(CART) }, + take_all() { + push_undo_without_who() + take_all_spoils() + }, + end_spoils() { end_exile_spoils() }, @@ -7789,6 +7804,11 @@ states.battle_spoils = { take_spoils(CART) }, + take_all() { + push_undo_without_who() + take_all_spoils() + }, + end_spoils() { end_battle_spoils() }, @@ -12294,6 +12314,10 @@ states.rebel_supply_depot = { push_undo_without_who() take_spoils(PROV) }, + take_all() { + push_undo_without_who() + take_all_spoils() + }, end_spoils() { push_undo_without_who() end_rebel_supply_depot() |