diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 86 |
1 files changed, 82 insertions, 4 deletions
@@ -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) { |