From 3de12fe760ce99a27ed0dcdb87308c0bb4d04522 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 13 May 2023 22:12:08 +0200 Subject: Lots of logging! --- rules.js | 139 +++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 77 insertions(+), 62 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index fa55b52..dba7cbb 100644 --- a/rules.js +++ b/rules.js @@ -346,10 +346,16 @@ function recycle_card(c) { function add_political_vp(side, amount) { if (side === COMMUNE) { - logi("Commune +" + amount + " Political VP.") + if (amount > 0) + log("Commune +" + amount + " Political VP.") + else + log("Commune " + amount + " Political VP.") game.political_vp += amount } else { - logi("Versailles +" + amount + " Political VP.") + if (amount > 0) + log("Versailles +" + amount + " Political VP.") + else + log("Versailles " + amount + " Political VP.") game.political_vp -= amount } game.political_vp = Math.min(5, Math.max(-5, game.political_vp)) @@ -357,10 +363,16 @@ function add_political_vp(side, amount) { function add_military_vp(side, amount) { if (side === COMMUNE) { - logi("Commune +" + amount + " Military VP.") + if (amount > 0) + log("Commune +" + amount + " Military VP.") + else + log("Commune " + amount + " Military VP.") game.military_vp += amount } else { - logi("Versailles +" + amount + " Military VP.") + if (amount > 0) + log("Versailles +" + amount + " Military VP.") + else + log("Versailles " + amount + " Military VP.") game.military_vp -= amount } game.military_vp = Math.min(5, Math.max(-5, game.military_vp)) @@ -971,7 +983,6 @@ function end_choose_objective_card() { // === INITIATIVE PHASE === function goto_initiative_phase() { - log_h2("Initiative Phase") let c_level = commune_political_vp() - game.red_momentum let v_level = versailles_political_vp() - game.blue_momentum if (c_level >= v_level) @@ -989,12 +1000,12 @@ states.initiative_phase = { view.actions.versailles = 1 }, commune() { - log("Initiative: Commune.") + log("Initiative to Commune.") game.initiative = COMMUNE end_initiative_phase() }, versailles() { - log("Initiative: Versailles.") + log("Initiative to Versailles.") game.initiative = VERSAILLES end_initiative_phase() }, @@ -1045,7 +1056,6 @@ function resume_strategy_phase() { if (game.red_hand.length === 1 && game.blue_hand.length === 1) { goto_set_aside_cards() } else { - log_sep() clear_undo() game.active = enemy_player() game.state = "strategy_phase" @@ -1111,28 +1121,28 @@ states.play_card = { }, event() { push_undo() - log_h4(game.active + " - Event") + log_h3(game.active + " - Event") logi("C" + game.what) discard_card(game.what) goto_play_event(game.what) }, political() { push_undo() - log_h4(game.active + " - Operations") + log_h3(game.active + " - Operations") logi("C" + game.what) discard_card(game.what) goto_operations(card_ops[game.what], POLITICAL) }, military() { push_undo() - log_h4(game.active + " - Operations") + log_h3(game.active + " - Operations") logi("C" + game.what) discard_card(game.what) goto_operations(card_ops[game.what], MILITARY) }, momentum() { push_undo() - log_h4(game.active + " - Momentum") + log_h3(game.active + " - Momentum") logi("C" + game.what) if (game.censorship) recycle_card(game.what) @@ -1176,7 +1186,7 @@ states.play_discard = { }, card(c) { push_undo() - log_h4(game.active + " - Discarded Event") + log_h3(game.active + " - Discarded Event") logi("C" + c) logi("C" + game.what) discard_card(c) @@ -1193,7 +1203,7 @@ states.play_final_discard = { }, card(c) { push_undo() - log_h4(game.active + " - Final Crisis") + log_h3(game.active + " - Final Crisis") logi("C" + c) logi("C" + game.what) discard_final() @@ -1211,12 +1221,10 @@ states.play_final_ops = { }, political() { push_undo() - log("4 Ops.") goto_operations(4, POLITICAL) }, military() { push_undo() - log("4 Ops.") goto_operations(4, MILITARY) }, } @@ -1637,7 +1645,6 @@ function goto_set_aside_cards() { // === PIVOTAL SPACE BONUS ACTIONS === function goto_pivotal_space_bonus_actions() { - clear_undo() log_h2("Pivotal Bonus Actions") update_presence_and_control() game.spaces = PIVOTAL.filter(s => is_commune_control(s) || is_versailles_control(s)) @@ -1645,6 +1652,7 @@ function goto_pivotal_space_bonus_actions() { } function resume_pivotal_space_bonus_actions() { + clear_undo() assess_crisis_breach_all() game.active = game.initiative if (game.spaces.length > 0) @@ -1665,7 +1673,6 @@ states.pivotal_space_bonus_actions = { } function goto_bonus_action(s) { - log_h3("S" + s) array_remove_item(game.spaces, s) game.where = s game.state = "bonus_action" @@ -1673,6 +1680,7 @@ function goto_bonus_action(s) { game.active = COMMUNE else game.active = VERSAILLES + log_h3(DIMENSION_NAME[s] + " - " + game.active) } states.bonus_action = { @@ -1690,23 +1698,23 @@ states.bonus_action = { }, de_escalate() { push_undo() - log_h4(game.active + " - De-escalated") + // log("De-escalated.") game.state = "de_escalate_1" }, spread_influence() { push_undo() - log_h4(game.active + " - Spread Influence") + // log("Spread Influence.") game.who = -1 game.count = 2 game.state = "spread_influence" }, turncoat() { push_undo() - log_h4(game.active + " - Turncoat") + // log("Turncoat.") game.state = "turncoat" }, pass() { - log_h4(game.active + " - Passed") + log("Passed.") resume_pivotal_space_bonus_actions() }, } @@ -1796,15 +1804,14 @@ states.turncoat = { // === CRISIS DIMENSION SCORING === -function score_control(s, name, cf, vf, arg) { - log(name + ":") +function score_control(s, cf, vf, arg) { if (is_political_space(s)) { if (cf(arg)) { add_political_vp(COMMUNE, 1) } else if (vf(arg)) { add_political_vp(VERSAILLES, 1) } else { - logi("Nobody") + log("Nobody.") } } else { if (cf(arg)) { @@ -1812,7 +1819,7 @@ function score_control(s, name, cf, vf, arg) { } else if (vf(arg)) { add_military_vp(VERSAILLES, 1) } else { - logi("Nobody") + log("Nobody.") } } } @@ -1834,13 +1841,8 @@ states.crisis_dimension_scoring = { }, space(s) { array_remove_item(game.spaces, s) - score_control( - s, - DIMENSION_NAME[s], - is_commune_control_dimension, - is_versailles_control_dimension, - DIMENSION_SPACES[s] - ) + log_h3(DIMENSION_NAME[s]) + score_control(s, is_commune_control_dimension, is_versailles_control_dimension, DIMENSION_SPACES[s]) if (game.spaces.length === 0) end_crisis_dimension_scoring() }, @@ -1862,11 +1864,14 @@ function goto_objective_card_scoring() { game.active = game.initiative game.count = 3 game.state = "objective_card_scoring" + + /* log("Commune Objective:") logi("C" + commune_objective_card()) log("Versailles Objective:") logi("C" + versailles_objective_card()) log_br() + */ } states.objective_card_scoring = { @@ -1878,11 +1883,18 @@ states.objective_card_scoring = { gen_action_space(versailles_objective_space()) }, space(s) { - score_control(s, "S" + s, is_commune_control, is_versailles_control, s) - if (s === commune_objective_space()) + if (s === commune_objective_space()) { + log_h3("S" + s) + logi("C" + commune_objective_card()) + score_control(s, is_commune_control, is_versailles_control, s) game.count ^= 1 - if (s === versailles_objective_space()) + } + if (s === versailles_objective_space()) { + log_h3("S" + s) + logi("C" + versailles_objective_card()) + score_control(s, is_commune_control, is_versailles_control, s) game.count ^= 2 + } if (game.count === 0) goto_objective_card_events() }, @@ -1891,12 +1903,14 @@ states.objective_card_scoring = { function goto_objective_card_events() { if (!is_commune_control(commune_objective_space())) { log_br() - log("Commune removed C" + commune_objective_card()) + log_h3("Commune - Removed") + logi("C" + commune_objective_card()) game.red_objective = 0 } if (!is_versailles_control(versailles_objective_space())) { log_br() - log("Versailles removed C" + versailles_objective_card()) + log_h3("Versailles - Removed") + logi("C" + versailles_objective_card()) game.blue_objective = 0 } resume_objective_card_events() @@ -1933,8 +1947,7 @@ states.objective_card_events = { game.red_objective = 0 game.red_fulfilled += 1 game.active = COMMUNE - log_sep() - log("Commune - Objective") + log_h3("Commune - Objective") logi("C" + c) goto_play_event(c) } @@ -1942,8 +1955,7 @@ states.objective_card_events = { game.blue_objective = 0 game.blue_fulfilled += 1 game.active = VERSAILLES - log_sep() - log("Versailles - Objective") + log_h3("Versailles - Objective") logi("C" + c) goto_play_event(c) } @@ -1969,6 +1981,21 @@ function goto_final_crisis() { game.active = "Both" game.state = "final_crisis_discard" + resume_final_crisis_discard() +} + +function resume_final_crisis_discard() { + if (game.red_hand.length > game.round && game.blue_hand.length > game.round) + game.active = "Both" + else if (game.red_hand.length > game.round) + game.active = COMMUNE + else if (game.blue_hand.length > game.round) + game.active = VERSAILLES + else { + clear_undo() + game.round = 4 + goto_initiative_phase() + } } states.final_crisis_discard = { @@ -1991,17 +2018,7 @@ states.final_crisis_discard = { array_remove_item(game.red_hand, c) if (player === VERSAILLES) array_remove_item(game.blue_hand, c) - if (game.red_hand.length > game.round && game.blue_hand.length > game.round) - game.active = "Both" - else if (game.red_hand.length > game.round) - game.active = COMMUNE - else if (game.blue_hand.length > game.round) - game.active = VERSAILLES - else { - clear_undo() - game.round = 4 - goto_initiative_phase() - } + resume_final_crisis_discard() }, } @@ -2029,7 +2046,6 @@ states.final_crisis_events = { }, card(c) { game.final_active = game.active - log_h2(game.active) discard_card(c) if (game.active === VERSAILLES && is_commune_card(c)) { game.what = c @@ -2042,7 +2058,8 @@ states.final_crisis_events = { game.state = "final_crisis_opponent_event" } else { - log("Played C" + c + ".") + log_h3(game.active + " - Event") + logi("C" + c) goto_play_event(c) } }, @@ -2057,10 +2074,13 @@ states.final_crisis_opponent_event = { view.actions.pass = 1 }, event() { - log("Played C" + game.what + ".") + log_h3(game.active + " - Event") + logi("C" + game.what) goto_play_event(game.what) }, pass() { + log_h3(game.active + " - Pass") + logi("C" + game.what) end_card_play() }, } @@ -3205,12 +3225,6 @@ function log_h2(msg) { function log_h3(msg) { log_br() log(".h3 " + msg) - log_br() -} - -function log_h4(msg) { - log_br() - log(".h4 " + msg) } function log_sep() { @@ -3598,6 +3612,7 @@ CODE[38] = [ // Victor Hugo ] CODE[39] = [ // Léon Gambetta + [ vm_prompt, "Replace up to 1 in Institutional." ], [ vm_replace_up_to, 1, INSTITUTIONAL ], [ vm_if, ()=>(game.active === COMMUNE) ], [ vm_decrease_prussian_collaboration ], -- cgit v1.2.3