diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 256 |
1 files changed, 189 insertions, 67 deletions
@@ -1,6 +1,7 @@ "use strict" -const space_count = data.space_names.length +// TODO: layout cubes in spaces in two groups (max 4 each space) +// TODO: layout cubes on tracks/pools as one space let layout = [] let space_layout_cube = [] @@ -18,40 +19,142 @@ let ui = { round_marker: document.getElementById("round_marker"), } +const card_names = [ + "Initiative", + "Jules Ducatel", + "The Murder of Vincenzini", + "Brassardiers", + "Jules Ferry", + "Le Figaro", + "Général Louis Valentin", + "Général Espivent", + "Les Amis de l'Ordre", + "Socialist Newspaper Ban", + "Fortification of Mont-Valérien", + "Adolphe Thiers", + "Otto von Bismarck", + "Général Ernest de Cissey", + "Colonel de Lochner", + "Jules Favre", + "Hostage Decree", + "Maréchal Macmahon", + "Paule Minck", + "Walery Wroblewski", + "Banque de France", + "Le Réveil", + "Execution of Generals", + "Les Cantinières", + "Eugène Protot", + "Paul Cluseret", + "Gaston Crémieux", + "Luise Michel", + "Jaroslav Dombrowski", + "Raoul Rigault", + "Karl Marx", + "Blanquists", + "Général Lullier", + "Jules Vallès", + "Charles Delescluze", + "Conciliation", + "Georges Clemenceau", + "Archbishop Georges Darboy", + "Victor Hugo", + "Léon Gambetta", + "Elihu Washburne", + "Freemason Parade", + "Paris Cannons", + "Aux Barricades!", + "Commune's Stronghold", + "Fighting in Issy Village", + "Battle of Mont-Valérien", + "Raid on Château de Vincennes", + "Revolution in the Press", + "Pius IX", + "Socialist International", + "Royalists Dissension", + "Rise of Republicanism", + "Legitimacy", +] + +const space_names = [ + "National Assembly", + "Royalists", + "Republicans", + "Press", + "Catholic Church", + "Social Movements", + "Mont-Valérien", + "Fort D'Issy", + "Château de Vincennes", + "Butte Montmartre", + "Butte-Aux-Cailles", + "Père Lachaise", + "Prussian Occupied Territory", + "Versailles HQ", + "Red Cube Pool 1", + "Red Cube Pool 2", + "Red Cube Pool 3", + "Red Crisis Track Start", + "Red Crisis Track Escalation", + "Red Crisis Track Tension", + "Red Crisis Track Final Crisis", + "Red Bonus Cubes 1", + "Red Bonus Cubes 2", + "Red Bonus Cubes 3", + "Blue Cube Pool", + "Blue Crisis Track Start", + "Blue Crisis Track Escalation", + "Blue Crisis Track Tension", + "Blue Crisis Track Final Crisis", + "Blue Bonus Cubes 1", + "Blue Bonus Cubes 2", + "Blue Bonus Cubes 3", + "Prussian Collaboration 1", + "Prussian Collaboration 2", + "Prussian Collaboration 3", +] + +const space_count = space_names.length + // :r !python3 tools/genboxes.py const boxes = { - "Royalists": [318,1711,506,505], - "Republicans": [1960,1712,504,504], - "Catholic Church": [318,3146,505,505], - "Social Movements": [1960,3146,506,505], - "Fort d'Issy": [3374,3172,506,506], - "Butte-Aux-Cailles": [4153,2642,505,505], - "Père Lachaise": [4824,2364,506,505], - "Château de Vincennes": [5369,2599,504,507], - "Press": [1176,2908,447,448], - "National Assembly": [1168,1984,447,447], - "Butte Montmartre": [4208,1842,447,444], - "Mont-Valérien": [2868,2028,447,448], - "Versailles HQ": [2646,3398,404,380], - "Prussian Occupied Territory": [5190,1413,718,346], - "Red Crisis Track Start": [3928,244,361,448], - "Red Crisis Track Escalation": [4289,244,334,448], - "Red Crisis Track Tension": [4623,244,332,448], - "Red Crisis Track Final Crisis": [4955,244,332,448], - "Blue Crisis Track Start": [1728,244,354,446], - "Blue Crisis Track Escalation": [1394,244,334,446], - "Blue Crisis Track Tension": [1061,244,333,446], - "Blue Crisis Track Final Crisis": [728,244,333,446], - "Blue Objective Card": [479,3983,1088,218], - "Red Objective Card": [4454,3984,1088,218], - "Red Cube Pool": [4498,790,791,219], - "Blue Cube Pool": [720,790,791,219], - "Red Bonus Cubes 1": [4289,89,334,155], - "Red Bonus Cubes 2": [4623,89,332,155], - "Red Bonus Cubes 3": [4955,89,332,155], - "Blue Bonus Cubes 1": [1394,89,334,155], - "Blue Bonus Cubes 2": [1061,89,333,155], - "Blue Bonus Cubes 3": [728,89,333,155], + "Royalists": [80,428,126,126], + "Republicans": [490,428,126,126], + "Catholic Church": [80,786,126,126], + "Social Movements": [490,786,126,126], + "Fort D'Issy": [844,793,126,126], + "Butte-Aux-Cailles": [1038,660,126,126], + "Père Lachaise": [1206,591,126,126], + "Château de Vincennes": [1342,650,126,127], + "Press": [294,727,112,112], + "National Assembly": [292,496,112,112], + "Butte Montmartre": [1052,460,112,111], + "Mont-Valérien": [717,507,112,112], + "Versailles HQ": [662,850,101,95], + "Prussian Occupied Territory": [1298,353,180,86], + "Red Crisis Track Start": [982,61,90,112], + "Red Crisis Track Escalation": [1072,61,84,112], + "Red Crisis Track Tension": [1156,61,83,112], + "Red Crisis Track Final Crisis": [1239,61,83,112], + "Blue Crisis Track Start": [432,61,88,112], + "Blue Crisis Track Escalation": [348,61,84,112], + "Blue Crisis Track Tension": [265,61,83,112], + "Blue Crisis Track Final Crisis": [182,61,83,112], + "Blue Objective Card": [120,996,272,54], + "Red Objective Card": [1114,996,272,54], + "Blue Cube Pool": [180,198,198,55], + "Red Bonus Cubes 1": [1072,22,84,39], + "Red Bonus Cubes 2": [1156,22,83,39], + "Red Bonus Cubes 3": [1239,22,83,39], + "Blue Bonus Cubes 1": [348,22,84,39], + "Blue Bonus Cubes 2": [265,22,83,39], + "Blue Bonus Cubes 3": [182,22,83,39], + "Red Cube Pool 1": [787,330,115,39], + "Red Cube Pool 2": [902,330,136,39], + "Red Cube Pool 3": [1038,330,157,40], + "Prussian Collaboration 1": [600,330,115,39], + "Prussian Collaboration 2": [463,330,136,39], + "Prussian Collaboration 3": [306,330,157,39], } function is_card_action(action, card) { @@ -60,14 +163,8 @@ function is_card_action(action, card) { return false } -function is_cube_action(i) { - if (view.actions && view.actions.cube && view.actions.cube.includes(i)) - return true - return false -} - -function is_disc_action(i) { - if (view.actions && view.actions.disc && view.actions.disc.includes(i)) +function is_piece_action(i) { + if (view.actions && view.actions.piece && view.actions.piece.includes(i)) return true return false } @@ -95,14 +192,14 @@ function on_click_space(evt) { function on_click_cube(evt) { if (evt.button === 0) { - if (send_action('cube', evt.target.my_cube)) + if (send_action('piece', evt.target.my_cube)) evt.stopPropagation() } } function on_click_disc(evt) { if (evt.button === 0) { - if (send_action('disc', evt.target.my_disc)) + if (send_action('piece', evt.target.my_disc)) evt.stopPropagation() } } @@ -134,13 +231,14 @@ function build_user_interface() { elt.className = "piece disc red" else elt.className = "piece disc blue" - elt.my_disc = i + elt.my_disc = i + 36 elt.addEventListener("mousedown", on_click_disc) + document.getElementById("pieces").appendChild(elt) } for (let i = 0; i < space_count; ++i) { - let name = data.space_names[i] - let r = boxes[name] + let name = space_names[i] + let [x, y, w, h] = boxes[name] elt = ui.spaces[i] = document.createElement("div") elt.className = "space" elt.my_space = i @@ -149,10 +247,6 @@ function build_user_interface() { elt.addEventListener("mouseenter", on_focus_space) elt.addEventListener("mouseleave", on_blur) let bw = 8 - let x = Math.round(r[0] / 4) - let y = Math.round(r[1] / 4) - let w = Math.round(r[2] / 4) - let h = Math.round(r[3] / 4) elt.style.top = y + "px" elt.style.left = x + "px" elt.style.width = (w - bw * 2) + "px" @@ -185,12 +279,14 @@ function layout_cubes(list, xorig, yorig) { } function layout_disc(s, disc) { - if (s > 0) + if (s > 0) { disc.classList.remove("hide") + disc.style.left = (space_layout_disc[s].x - 50 - 12) + "px" + disc.style.top = (space_layout_disc[s].y - 20 - 8) + "px" + disc.style.zIndex = 51; + } else disc.classList.add("hide") - disc.style.left = (space_layout_disc[s].x - 50 - 12) + "px" - disc.style.top = (space_layout_disc[s].y - 20 - 8) + "px" } function on_focus_card_tip(card_number) { @@ -203,7 +299,7 @@ function on_blur_card_tip() { function sub_card_name(match, p1, offset, string) { let c = p1 | 0 - let n = data.cards[c].name + let n = card_names[c] return `<span class="tip" onmouseenter="on_focus_card_tip(${c})" onmouseleave="on_blur_card_tip()">${n}</span>` } @@ -240,10 +336,10 @@ function on_log(text) { } function on_update() { - if (view.active_card) - document.getElementById("active_card").className = `card card_${view.active_card}` + if (view.discard) + document.getElementById("discarded_card").className = `card card_${view.discard}` else - document.getElementById("active_card").className = `card card_strategy_back` + document.getElementById("discarded_card").className = `card card_strategy_back` if (view.initiative === "Commune") document.getElementById("commune_info").textContent = "\u2756" @@ -267,28 +363,42 @@ function on_update() { for (let c of view.hand) document.getElementById("hand").appendChild(ui.cards[c]) - for (let i = 0; i < space_count; ++i) + for (let i = 0; i < space_names.length; ++i) layout[i] = [] for (let i = 0; i < 36; ++i) { - layout[view.cubes[i]].push(ui.cubes[i]) - ui.cubes[i].classList.toggle("action", is_cube_action(i)) + if (view.pieces[i] >= 0) { + layout[view.pieces[i]].push(ui.cubes[i]) + ui.cubes[i].classList.remove("hide"); + ui.cubes[i].classList.toggle("action", is_piece_action(i)) + } + else { + ui.cubes[i].classList.add("hide"); + } } for (let i = 0; i < space_count; ++i) { layout_cubes(layout[i], space_layout_cube[i].x, space_layout_cube[i].y) ui.spaces[i].classList.toggle("action", is_space_action(i)) } for (let i = 0; i < 4; ++i) { - layout_disc(view.discs[i], ui.discs[i]) - ui.discs[i].classList.toggle("action", is_cube_action(i)) + layout_disc(view.pieces[36+i], ui.discs[i]) + ui.discs[i].classList.toggle("action", is_piece_action(36+i)) } for (let i = 1; i < ui.cards.length; ++i) { ui.cards[i].classList.toggle("action", is_card_action('card', i)) } - action_button("commune", "Commune") - action_button("versailles", "Versailles") - action_button("undo", "Undo") + action_button("commune", "Commune"); + action_button("versailles", "Versailles"); + + action_button("spend", "Spend"); + action_button("draw", "Draw"); + + action_button("end_remove", "End Remove"); + action_button("end_turn", "End Turn"); + + action_button("done", "Done"); + action_button("undo", "Undo"); } /* CARD ACTION MENU */ @@ -327,6 +437,16 @@ function on_card_ops() { hide_popup_menu() } +function on_card_ops_political() { + if (send_action('card_ops_political', current_popup_card)) + hide_popup_menu() +} + +function on_card_ops_military() { + if (send_action('card_ops_military', current_popup_card)) + hide_popup_menu() +} + function on_card_use_discarded() { if (send_action('card_use_discarded', current_popup_card)) hide_popup_menu() @@ -347,8 +467,10 @@ function on_click_card(evt) { let menu = [] if (is_card_action('card_event', card)) menu.push('card_event') - if (is_card_action('card_ops', card)) - menu.push('card_ops') + if (is_card_action('card_ops_political', card)) + menu.push('card_ops_political') + if (is_card_action('card_ops_military', card)) + menu.push('card_ops_military') if (is_card_action('card_use_discarded', card)) menu.push('card_use_discarded') if (is_card_action('card_advance_momentum', card)) |