diff options
-rw-r--r-- | play.html | 24 | ||||
-rw-r--r-- | play.js | 86 | ||||
-rw-r--r-- | rules.js | 5 |
3 files changed, 105 insertions, 10 deletions
@@ -182,13 +182,19 @@ <option value="15">Turn 12</option> </select> <p> - <label id="a_politics_label"><input type="checkbox" name="a_phase" value="1" id="a_phase_politics">Politics</label> <label><input type="checkbox" name="a_phase" value="4" id="a_phase_movement">Movement</label> <label><input type="checkbox" name="a_phase" value="16" id="a_phase_combat">Combat</label> <label><input type="checkbox" name="a_phase" value="8" id="a_phase_retreat">Retreat</label> - <label id="a_hussars_label"><br><input type="checkbox" name="a_phase" value="2" id="a_phase_hussars">Hussars</label> + <label><input type="checkbox" name="a_phase" value="2" id="a_phase_hussars">Hussars</label> + <label><input type="checkbox" name="a_phase" value="32" id="a_phase_supply">Supply</label> + <br> + <label><input type="checkbox" name="a_phase" value="1" id="a_phase_politics">Politics</label> + <label><input type="checkbox" name="a_phase" value="64" id="a_phase_winter">Winter</label> + <label><input type="checkbox" name="a_phase" value="128" id="a_phase_election">Election</label> + <label><input type="checkbox" name="a_phase" value="256" id="a_phase_silesia">Silesia</label> + <label><input type="checkbox" name="a_phase" value="512" id="a_phase_military">Military objectives</label> <p> - <textarea name="a_promise" placeholder="Promise..." rows=3 cols=40></textarea> + <textarea name="a_promise" placeholder="Promise..." rows=3 cols=50></textarea> <p style="text-align:center"> - ❦ - @@ -217,13 +223,19 @@ <option value="15">Turn 12</option> </select> <p> - <label id="b_politics_label"><input type="checkbox" name="b_phase" value="1" id="b_phase_politics">Politics</label> <label><input type="checkbox" name="b_phase" value="4" id="b_phase_movement">Movement</label> <label><input type="checkbox" name="b_phase" value="16" id="b_phase_combat">Combat</label> <label><input type="checkbox" name="b_phase" value="8" id="b_phase_retreat">Retreat</label> - <label id="b_hussars_label"><br><input type="checkbox" name="b_phase" value="2" id="b_phase_hussars">Hussars</label> + <label><input type="checkbox" name="b_phase" value="2" id="b_phase_hussars">Hussars</label> + <label><input type="checkbox" name="b_phase" value="32" id="b_phase_supply">Supply</label> + <br> + <label><input type="checkbox" name="b_phase" value="1" id="b_phase_politics">Politics</label> + <label><input type="checkbox" name="b_phase" value="64" id="b_phase_winter">Winter</label> + <label><input type="checkbox" name="b_phase" value="128" id="b_phase_election">Election</label> + <label><input type="checkbox" name="b_phase" value="256" id="b_phase_silesia">Silesia</label> + <label><input type="checkbox" name="b_phase" value="512" id="b_phase_military">Military objectives</label> <p> - <textarea name="b_promise" placeholder="Promise..." rows=3 cols=40></textarea> + <textarea name="b_promise" placeholder="Promise..." rows=3 cols=50></textarea> <br> <br> @@ -126,6 +126,11 @@ const V_HUSSARS = 2 const V_MOVEMENT = 4 const V_RETREAT = 8 const V_COMBAT = 16 +const V_SUPPLY = 32 +const V_WINTER = 64 +const V_ELECTION = 128 +const V_SILESIA = 256 +const V_MILITARY = 512 const SPADES = 0 const CLUBS = 1 @@ -1872,9 +1877,14 @@ function phase_list(phase) { let list = [] if (phase & V_POLITICS) list.push("politics") if (phase & V_HUSSARS) list.push("hussars") + if (phase & V_SUPPLY) list.push("supply") if (phase & V_MOVEMENT) list.push("movement") if (phase & V_COMBAT) list.push("combat") if (phase & V_RETREAT) list.push("retreat") + if (phase & V_WINTER) list.push("winter") + if (phase & V_ELECTION) list.push("election") + if (phase & V_SILESIA) list.push("silesia") + if (phase & V_MILITARY) list.push("m.objectives") return list.join(" ") } @@ -1940,13 +1950,71 @@ function update_deal_list(deals, elt, title) { } } +function toggle_deal_option(element, pred) { + element.parentElement.classList.toggle("hide", !pred) +} + +function should_validate_hussars(power) { + // place hussars + return power === P_AUSTRIA +} + +function should_validate_supply(power) { + // spend supply cards for hussars + return ( + power === P_PRUSSIA || + power === P_FRANCE || + power === P_BAVARIA || + (power === P_SAXONY && is_saxony_prussian()) + ) +} + +function should_validate_election(power) { + // Election is over! + if (view.flags & (F_EMPEROR_FRANCE | F_EMPEROR_AUSTRIA) !== 0) + return false + // PA and Austria never have a choice! + if (power === P_AUSTRIA || power === P_PRAGMATIC) + return false + return true +} + +function should_validate_military(power) { + if (view.flags & F_FRANCE_REDUCED) + return false + if (power !== P_FRANCE) + return false + return true +} + +function should_validate_silesia(power) { + if (view.flags & F_SILESIA_ANNEXED) + return false + if (power !== P_PRUSSIA && power !== P_AUSTRIA) + return false + return true +} + function update_deal_options() { let a_power = window.propose_deal_form.elements.a_power.value | 0 let b_power = window.propose_deal_form.elements.b_power.value | 0 - window.a_hussars_label.classList.toggle("hide", a_power !== P_AUSTRIA) - window.b_hussars_label.classList.toggle("hide", b_power !== P_AUSTRIA) - window.a_politics_label.classList.toggle("hide", all_minor_powers.includes(a_power)) - window.b_politics_label.classList.toggle("hide", all_minor_powers.includes(b_power)) + + toggle_deal_option(window.a_phase_politics, !all_minor_powers.includes(a_power)) + toggle_deal_option(window.b_phase_politics, !all_minor_powers.includes(b_power)) + + toggle_deal_option(window.a_phase_hussars, should_validate_hussars(a_power)) + toggle_deal_option(window.b_phase_hussars, should_validate_hussars(b_power)) + toggle_deal_option(window.a_phase_supply, should_validate_supply(a_power)) + toggle_deal_option(window.b_phase_supply, should_validate_supply(b_power)) + + toggle_deal_option(window.a_phase_election, should_validate_election(a_power)) + toggle_deal_option(window.b_phase_election, should_validate_election(b_power)) + + toggle_deal_option(window.a_phase_silesia, should_validate_silesia(a_power)) + toggle_deal_option(window.b_phase_silesia, should_validate_silesia(b_power)) + + toggle_deal_option(window.a_phase_military, should_validate_military(a_power)) + toggle_deal_option(window.b_phase_military, should_validate_military(b_power)) } function propose_deal() { @@ -1959,12 +2027,22 @@ function propose_deal() { window.b_phase_politics.checked = false window.a_phase_hussars.checked = false window.b_phase_hussars.checked = false + window.a_phase_supply.checked = false + window.b_phase_supply.checked = false window.a_phase_movement.checked = false window.b_phase_movement.checked = false window.a_phase_retreat.checked = false window.b_phase_retreat.checked = false window.a_phase_combat.checked = false window.b_phase_combat.checked = false + window.a_phase_winter.checked = false + window.b_phase_winter.checked = false + window.a_phase_election.checked = false + window.b_phase_election.checked = false + window.a_phase_military.checked = false + window.b_phase_military.checked = false + window.a_phase_silesia.checked = false + window.b_phase_silesia.checked = false form.a_power.value = view.power switch (view.power) { @@ -117,6 +117,11 @@ const V_HUSSARS = 2 const V_MOVEMENT = 4 const V_RETREAT = 8 const V_COMBAT = 16 +const V_SUPPLY = 32 +const V_WINTER = 64 +const V_ELECTION = 128 +const V_SILESIA = 256 +const V_MILITARY = 512 const SPADES = 0 const CLUBS = 1 |