diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-01-01 20:22:06 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 13:02:38 +0100 |
commit | 2c56e6ef5edb0a1aa0876537c8d4b84b4a2b976a (patch) | |
tree | f7ba2f1ec3fb9c02065a75ce832a2c6f120cf83b | |
parent | 4abe5236db7fd5730851f3e20b314646fc355ee6 (diff) | |
download | nevsky-2c56e6ef5edb0a1aa0876537c8d4b84b4a2b976a.tar.gz |
Zap distinction between battle_lord and lord actions.
-rw-r--r-- | play.html | 12 | ||||
-rw-r--r-- | play.js | 34 | ||||
-rw-r--r-- | rules.js | 81 |
3 files changed, 61 insertions, 66 deletions
@@ -314,6 +314,10 @@ body.Teutons #plan_actions .russian { display: none } box-shadow: 0 0 0 1px #584800, 0 0 0 3px yellow; } +.mat.command .background { + box-shadow: 0 0 0 1px #584800, 0 0 0 3px gold; +} + .mat .capabilities { position: absolute; width: 372px; @@ -907,6 +911,14 @@ body.shift .mustered_vassals { drop-shadow(-2px 0px 0px yellow); } +.cylinder.command { + filter: + drop-shadow(2px 0px 0px gold) + drop-shadow(0px 2px 0px gold) + drop-shadow(0px -2px 0px gold) + drop-shadow(-2px 0px 0px gold); +} + .cylinder.andreas { background-image: url(images/lord_teutonic_1.svg) } .cylinder.hermann.marshal { background-image: url(images/lord_teutonic_2.svg) } .cylinder.hermann { background-image: url(images/lord_teutonic_3.svg) } @@ -209,10 +209,6 @@ function is_lord_action(lord) { return !!(view.actions && view.actions.lord && set_has(view.actions.lord, lord)) } -function is_battle_lord_action(lord) { - return !!(view.actions && view.actions.battle_lord && set_has(view.actions.battle_lord, lord)) -} - function is_battle_array_action(ix) { return !!(view.actions && view.actions.array && set_has(view.actions.array, ix)) } @@ -598,13 +594,6 @@ function on_click_cylinder(evt) { } } -function on_click_battle_cylinder(evt) { - if (evt.button === 0) { - let id = evt.target.my_id - send_action('battle_lord', id) - } -} - function on_click_card(evt) { if (evt.button === 0) { let id = evt.target.my_id @@ -1058,15 +1047,11 @@ function update_lord_mat(ix) { update_forces(ui.routed[ix], view.pieces.routed[ix], ix, true) } -function is_lord_mat_selected(ix) { - if (view.who >= 0) - return ix === view.who - if (view.group) - return view.group.includes(ix) - return false +function is_lord_command(ix) { + return view.command === ix } -function is_cylinder_selected(ix) { +function is_lord_selected(ix) { if (view.who >= 0) return ix === view.who if (view.group) @@ -1119,8 +1104,11 @@ function update_lord(ix) { if (ix === LORD_ANDREY) ui.lord_cylinder[ix].classList.toggle("marshal", !is_lord_on_map(LORD_ALEKSANDR)) - ui.lord_cylinder[ix].classList.toggle("selected", is_cylinder_selected(ix)) - ui.lord_mat[ix].classList.toggle("selected", is_lord_mat_selected(ix)) + ui.lord_cylinder[ix].classList.toggle("selected", is_lord_selected(ix)) + ui.lord_mat[ix].classList.toggle("selected", is_lord_selected(ix)) + + ui.lord_cylinder[ix].classList.toggle("command", is_lord_command(ix)) + ui.lord_mat[ix].classList.toggle("command", is_lord_command(ix)) ui.lord_mat[ix].classList.toggle("besieged", is_lord_besieged(ix)) ui.lord_mat[ix].classList.toggle("moved", is_lord_moved(ix)) @@ -1391,8 +1379,8 @@ function update_battle() { } for (let lord = 0; lord < 12; ++lord) { - ui.battle_cylinder[lord].classList.toggle("action", is_battle_lord_action(lord)) - ui.battle_cylinder[lord].classList.toggle("selected", is_cylinder_selected(lord)) + ui.battle_cylinder[lord].classList.toggle("action", is_lord_action(lord)) + ui.battle_cylinder[lord].classList.toggle("selected", is_lord_selected(lord)) } ui.garrison.replaceChildren() @@ -1768,7 +1756,7 @@ function build_map() { e = ui.battle_cylinder[ix] = document.createElement("div") e.className = "cylinder lord " + clean_name(lord.side) + " " + clean_name(lord.name) e.my_id = ix - e.addEventListener("mousedown", on_click_battle_cylinder) + e.addEventListener("mousedown", on_click_cylinder) e.addEventListener("mouseenter", on_focus_cylinder) e.addEventListener("mouseleave", on_blur) @@ -5163,7 +5163,7 @@ states.array_attacker = { if (array[A1] === NOBODY || array[A2] === NOBODY || array[A3] === NOBODY) { for (let lord of game.battle.reserves) { if (lord !== game.who && is_friendly_lord(lord)) { - gen_action_battle_lord(lord) + gen_action_lord(lord) done = false } } @@ -5173,7 +5173,7 @@ states.array_attacker = { if (array[A1] === NOBODY || array[A2] === NOBODY || array[A3] === NOBODY) { for (let lord of game.battle.reserves) { if (lord !== game.who && is_friendly_lord(lord) && is_lord_unbesieged(lord)) { - gen_action_battle_lord(lord) + gen_action_lord(lord) done = false } } @@ -5183,7 +5183,7 @@ states.array_attacker = { if (array[SA1] === NOBODY || array[SA2] === NOBODY || array[SA3] === NOBODY) { for (let lord of game.battle.reserves) { if (lord !== game.who && is_friendly_lord(lord) && is_lord_besieged(lord)) { - gen_action_battle_lord(lord) + gen_action_lord(lord) done = false } } @@ -5215,7 +5215,7 @@ states.array_attacker = { } }, array: action_array_place, - battle_lord(lord) { + lord(lord) { game.who = lord }, end_array() { @@ -5267,7 +5267,7 @@ states.array_defender = { if (empty_front || empty_rear) { for (let lord of game.battle.reserves) { if (lord !== game.who && is_friendly_lord(lord)) { - gen_action_battle_lord(lord) + gen_action_lord(lord) done = false } } @@ -5284,7 +5284,7 @@ states.array_defender = { } }, array: action_array_place, - battle_lord(lord) { + lord(lord) { game.who = lord }, end_array() { @@ -5320,9 +5320,9 @@ states.array_defender_storm = { for (let lord of game.battle.reserves) if (is_friendly_lord(lord)) - gen_action_battle_lord(lord) + gen_action_lord(lord) }, - battle_lord(lord) { + lord(lord) { set_delete(game.battle.reserves, lord) game.battle.array[D2] = lord end_array_defender() @@ -5518,16 +5518,16 @@ states.bridge = { let array = game.battle.array if (game.active === game.battle.attacker) { if (array[D2] !== NOBODY) - gen_action_battle_lord(array[D2]) + gen_action_lord(array[D2]) if (array[RD2] !== NOBODY) - gen_action_battle_lord(array[RD2]) + gen_action_lord(array[RD2]) } else { // Cannot play on Relief Sallying lord if (array[A2] !== NOBODY) - gen_action_battle_lord(array[A2]) + gen_action_lord(array[A2]) } }, - battle_lord(lord) { + lord(lord) { log(`Played E${game.what} on L${lord}.`) if (!game.battle.bridge) game.battle.bridge = [] @@ -5543,14 +5543,14 @@ states.field_organ = { if (game.active === game.battle.attacker) { for (let pos of STEP_ARRAY[1]) if (array[pos] !== NOBODY) - gen_action_battle_lord(array[pos]) + gen_action_lord(array[pos]) } else { for (let pos of STEP_ARRAY[0]) if (array[pos] !== NOBODY) - gen_action_battle_lord(array[pos]) + gen_action_lord(array[pos]) } }, - battle_lord(lord) { + lord(lord) { log(`Played E${game.what} on L${lord}.`) game.battle.field_organ = lord resume_battle_events() @@ -5724,7 +5724,7 @@ states.reposition_advance = { for (let lord of game.battle.reserves) if (is_friendly_lord(lord) && lord !== game.who) - gen_action_battle_lord(lord) + gen_action_lord(lord) if (game.who !== NOBODY) { if (game.active === game.battle.attacker) { @@ -5743,7 +5743,7 @@ states.reposition_advance = { } } }, - battle_lord(lord) { + lord(lord) { game.who = lord }, array(pos) { @@ -5776,21 +5776,21 @@ states.reposition_center = { if (game.active === game.battle.attacker) { if (array[A2] === NOBODY) { - if (array[A1] !== NOBODY) gen_action_battle_lord(game.battle.array[A1]) - if (array[A3] !== NOBODY) gen_action_battle_lord(game.battle.array[A3]) + if (array[A1] !== NOBODY) gen_action_lord(game.battle.array[A1]) + if (array[A3] !== NOBODY) gen_action_lord(game.battle.array[A3]) } if (array[SA2] === NOBODY) { - if (array[SA1] !== NOBODY) gen_action_battle_lord(game.battle.array[SA1]) - if (array[SA3] !== NOBODY) gen_action_battle_lord(game.battle.array[SA3]) + if (array[SA1] !== NOBODY) gen_action_lord(game.battle.array[SA1]) + if (array[SA3] !== NOBODY) gen_action_lord(game.battle.array[SA3]) } } else { if (array[D2] === NOBODY) { - if (array[D1] !== NOBODY) gen_action_battle_lord(game.battle.array[D1]) - if (array[D3] !== NOBODY) gen_action_battle_lord(game.battle.array[D3]) + if (array[D1] !== NOBODY) gen_action_lord(game.battle.array[D1]) + if (array[D3] !== NOBODY) gen_action_lord(game.battle.array[D3]) } if (array[RD2] === NOBODY) { - if (array[RD1] !== NOBODY) gen_action_battle_lord(game.battle.array[RD1]) - if (array[RD3] !== NOBODY) gen_action_battle_lord(game.battle.array[RD3]) + if (array[RD1] !== NOBODY) gen_action_lord(game.battle.array[RD1]) + if (array[RD3] !== NOBODY) gen_action_lord(game.battle.array[RD3]) } } @@ -5802,7 +5802,7 @@ states.reposition_center = { if (from === RD1 || from === RD3) gen_action_array(RD2) } }, - battle_lord(lord) { + lord(lord) { game.who = lord }, array(pos) { @@ -5840,9 +5840,9 @@ states.reposition_storm = { view.prompt = "Reposition: You may switch positions between Front and any Reserve Lord." for (let lord of game.battle.reserves) if (is_friendly_lord(lord) && lord !== game.who) - gen_action_battle_lord(lord) + gen_action_lord(lord) }, - battle_lord(lord) { + lord(lord) { log(`Swapped in L${lord}.`) set_delete(game.battle.reserves, lord) if (game.active === game.battle.attacker) { @@ -6323,9 +6323,9 @@ function prompt_strike_choice(X1, X2, X3, Y2) { if (game.battle.array[X2] === NOBODY && game.battle.array[Y2] !== NOBODY) { view.who = game.battle.array[Y2] if (game.battle.array[X1] !== NOBODY) - gen_action_battle_lord(game.battle.array[X1]) + gen_action_lord(game.battle.array[X1]) if (game.battle.array[X3] !== NOBODY) - gen_action_battle_lord(game.battle.array[X3]) + gen_action_lord(game.battle.array[X3]) } } @@ -6347,11 +6347,11 @@ states.strike_choice = { if (has_sa_strike()) { view.group = [ array[SA1], array[SA2], array[SA3] ] if (array[D1] !== NOBODY) - gen_action_battle_lord(array[D1]) + gen_action_lord(array[D1]) if (array[D2] !== NOBODY) - gen_action_battle_lord(array[D2]) + gen_action_lord(array[D2]) if (array[D3] !== NOBODY) - gen_action_battle_lord(array[D3]) + gen_action_lord(array[D3]) } } else { if (game.battle.rc === -1) { @@ -6362,10 +6362,9 @@ states.strike_choice = { } } }, - battle_lord(lord) { - this.array(get_lord_array_position(lord)) - }, - array(pos) { + lord(lord) { + let pos = get_lord_array_position(lord) + console.log("STRIKE CHOICE", pos) if (pos === A1 || pos === D1) @@ -6406,11 +6405,11 @@ states.select_strike_group = { for (let p of sg) { let lord = game.battle.array[p] if (game.battle.ah1[p] + game.battle.ah2[p] > 0) - gen_action_battle_lord(lord) + gen_action_lord(lord) } } }, - battle_lord(lord) { + lord(lord) { for (let i = 0; i < game.battle.groups.length; ++i) { for (let p of game.battle.groups[i][0]) if (game.battle.array[p] === lord) @@ -8543,10 +8542,6 @@ function gen_action_lord(lord) { gen_action("lord", lord) } -function gen_action_battle_lord(lord) { - gen_action("battle_lord", lord) -} - function gen_action_array(pos) { gen_action("array", pos) } |