diff options
-rw-r--r-- | play.css | 2 | ||||
-rw-r--r-- | play.html | 4 | ||||
-rw-r--r-- | play.js | 47 | ||||
-rw-r--r-- | rules.js | 58 |
4 files changed, 89 insertions, 22 deletions
@@ -375,12 +375,14 @@ TWOD.piece.cylinder { .card.action { box-shadow: 0 0 0 4px white; + margin-top: -10px; } /* .card.tc.reverse + .card.tc.reverse { margin-left: -200px; } */ +.draw-break { margin-left: 180px; } .card.tc { margin-right: -180px; } .panel_body { padding-right: calc(18px + 180px); } @@ -56,6 +56,8 @@ </div> </div> +<div id="power_panel_list"> + <div id="hand_prussia_panel" class="panel"> <div id="hand_prussia_header" class="panel_header">Prussia</div> <div id="hand_prussia" class="panel_body"> @@ -98,6 +100,8 @@ </div> </div> +</div> + <div id="clock_of_fate_panel" class="panel"> <div id="clock_of_fate_header" class="panel_header">Clock of Fate</div> <div id="clock_of_fate" class="panel_body"> @@ -119,6 +119,17 @@ const ui = { spaces_element: document.getElementById("spaces"), pieces_element: document.getElementById("pieces"), markers_element: document.getElementById("markers"), + clock_of_fate: document.getElementById("clock_of_fate"), + power_panel_list: document.getElementById("power_panel_list"), + hand: [ + document.getElementById("hand_prussia"), + document.getElementById("hand_hanover"), + document.getElementById("hand_russia"), + document.getElementById("hand_sweden"), + document.getElementById("hand_austria"), + document.getElementById("hand_imperial"), + document.getElementById("hand_france"), + ], cities: [], action_register: [], } @@ -280,16 +291,6 @@ function on_init() { for (let e of ui.turns) ui.pieces_element.appendChild(e) - ui.hand = [ - document.getElementById("hand_prussia"), - document.getElementById("hand_hanover"), - document.getElementById("hand_russia"), - document.getElementById("hand_sweden"), - document.getElementById("hand_austria"), - document.getElementById("hand_imperial"), - document.getElementById("hand_france"), - ] - ui.tc = [] make_tc_deck(0) make_tc_deck(1) @@ -303,7 +304,8 @@ function on_init() { make_tc_deck_back("deck_4"), ] - ui.clock_of_fate = document.getElementById("clock_of_fate") + ui.tcbreak = document.createElement("div") + ui.tcbreak.className = "draw-break" ui.fate = [] for (let fc = 0; fc <= 18; ++fc) @@ -543,9 +545,27 @@ function on_update() { ui.hand[pow].replaceChildren() for (let c of view.hand[pow]) { if ((c & 15) === 0) - ui.hand[pow].append(ui.tc_back[c>>7][back[c>>7]++]) + ui.hand[pow].appendChild(ui.tc_back[c>>7][back[c>>7]++]) else - ui.hand[pow].append(ui.tc[c]) + ui.hand[pow].appendChild(ui.tc[c]) + } + } + + if (false) { + if (view.draw) { + ui.draw_panel.classList.remove("hide") + ui.draw.replaceChildren() + for (let c of view.draw) + ui.draw.appendChild(ui.tc[c]) + } else { + ui.draw_panel.classList.add("hide") + } + } else { + if (view.draw) { + if (view.hand[view.power].length > 0) + ui.hand[view.power].appendChild(ui.tcbreak) + for (let c of view.draw) + ui.hand[view.power].appendChild(ui.tc[c]) } } @@ -576,6 +596,7 @@ function on_update() { action_button("next", "Next") action_button("done", "Done") + action_button("end_cards", "End cards") action_button("end_setup", "End setup") action_button("end_recruit", "End recruit") action_button("end_movement", "End movement") @@ -363,14 +363,16 @@ function is_protected_from_reconquest(s) { /* STATE */ -function turn_power_draw(pow) { +function turn_power_draw() { let n = 0 - if (game.scenario === 1 && pow === P_PRUSSIA) { - n = 2 + if (game.scenario === 1 && game.power === P_PRUSSIA) { + if (set_has(game.fate, FC_LORD_BUTE) || set_has(game.fate, FC_POEMS)) + return 1 + return 2 } - switch (pow) { + switch (game.power) { case P_PRUSSIA: n = 7 if (set_has(game.fate, FC_LORD_BUTE)) @@ -785,16 +787,54 @@ function draw_next_tc() { } function goto_tactical_cards() { - let pow = game.power - let n = turn_power_draw(pow) + let n = turn_power_draw() log("Draw " + n + " TC.") + game.draw = [] for (let i = 0; i < n; ++i) - set_add(game.hand[pow], draw_next_tc()) + set_add(game.draw, draw_next_tc()) + + game.state = "tactical_cards" +} + +function should_power_discard_tc() { + if (game.power === P_FRANCE) + return true + if (game.scenario === 1 && game.power === P_PRUSSIA) + return true + return false +} + +states.tactical_cards = { + prompt() { + view.draw = game.draw + if (should_power_discard_tc()) { + prompt("Drew " + game.draw.length + " TCs. Discard one of them.") + for (let c of game.draw) + gen_action_card(c) + } else { + prompt("Drew " + game.draw.length + " TCs.") + view.actions.end_cards = 1 + } + }, + card(c) { + push_undo() + set_delete(game.draw, c) + end_tactical_cards() + }, + end_cards() { + end_tactical_cards() + }, +} + +function end_tactical_cards() { + for (let c of game.draw) + set_add(game.hand[game.power], c) + delete game.draw // MARIA: supply is before movement - + goto_movement() } @@ -2200,7 +2240,7 @@ exports.setup = function (seed, scenario, options) { active: "Frederick", power: P_PRUSSIA, - turn: 5, + turn: 0, step: 0, clock: null, fate: [], |