From f50a03985fe30cc327ab86cc34da9b6e616a449e Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 12 May 2023 01:12:03 +0200 Subject: Code style cleanups. --- rules.js | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/rules.js b/rules.js index 2273f33..801978f 100644 --- a/rules.js +++ b/rules.js @@ -5,8 +5,8 @@ // TODO: event prompts // TODO: clean up logging -const COMMUNE = "Commune"; -const VERSAILLES = "Versailles"; +const COMMUNE = "Commune" +const VERSAILLES = "Versailles" var game, view, states = {} @@ -24,11 +24,7 @@ const last_commune_disc = 37 const first_versailles_disc = 38 const last_versailles_disc = 39 -const crisis_names = [ - "Escalation", - "Tension", - "Final Crisis", -] +const crisis_names = [ "Escalation", "Tension", "Final Crisis" ] const card_names = [ "Initiative", @@ -137,13 +133,13 @@ const space_names = [ "Prussian Collaboration 3", ] -const RED_CUBE_POOL = [14, 15, 16] -const RED_CRISIS_TRACK = [17, 18, 19, 20] -const RED_BONUS_CUBES = [21, 22, 23] +const RED_CUBE_POOL = [ 14, 15, 16 ] +const RED_CRISIS_TRACK = [ 17, 18, 19, 20 ] +const RED_BONUS_CUBES = [ 21, 22, 23 ] const BLUE_CUBE_POOL = 24 -const BLUE_CRISIS_TRACK = [25, 26, 27, 28] -const BLUE_BONUS_CUBES = [29, 30, 31] -const PRUSSIAN_COLLABORATION = [32, 33, 34] +const BLUE_CRISIS_TRACK = [ 25, 26, 27, 28 ] +const BLUE_BONUS_CUBES = [ 29, 30, 31 ] +const PRUSSIAN_COLLABORATION = [ 32, 33, 34 ] const OUT_OF_PLAY = -1 @@ -423,7 +419,8 @@ function can_play_event(c) { if (c === 8) { if (count_available_versailles_cubes() < 2) return false - let n = count_versailles_cubes(BUTTE_MONTMARTRE) + + let n = + count_versailles_cubes(BUTTE_MONTMARTRE) + count_versailles_cubes(BUTTE_AUX_CAILLES) + count_versailles_cubes(PERE_LACHAISE) if (n > 12 - 2) @@ -508,7 +505,7 @@ function update_presence_and_control() { function is_present(s) { if (game.active === COMMUNE) - return game.presence & (1 << (s)) + return game.presence & (1 << s) return game.presence & (1 << (s + space_count)) } @@ -517,7 +514,7 @@ function is_commune_control(s) { return false if (s === PRUSSIAN_OCCUPIED_TERRITORY) return false - return game.control & (1 << (s)) + return game.control & (1 << s) } function is_versailles_control(s) { @@ -728,7 +725,7 @@ function can_replace_cube_in_any(list) { return false } -function can_place_cube(s, removed=0) { +function can_place_cube(s, removed = 0) { return find_available_cube(removed) >= 0 && count_friendly_cubes(s) < 4 } @@ -769,7 +766,7 @@ function move_piece(p, s) { game.pieces[p] = s } -function place_cube(s, removed=0) { +function place_cube(s, removed = 0) { game.pieces[find_available_cube(removed)] = s } @@ -783,7 +780,7 @@ function replace_cube(p) { place_cube(s) } -function find_available_cube(removed=0) { +function find_available_cube(removed = 0) { let p = -1 if (game.active === COMMUNE) { if (removed) { @@ -1722,7 +1719,7 @@ states.spread_influence = { }, done() { resume_pivotal_space_bonus_actions() - } + }, } states.turncoat = { @@ -1781,10 +1778,13 @@ states.crisis_dimension_scoring = { }, space(s) { array_remove_item(game.spaces, s) - score_control(s, DIMENSION_NAME[s], + score_control( + s, + DIMENSION_NAME[s], is_commune_control_dimension, is_versailles_control_dimension, - DIMENSION_SPACES[s]) + DIMENSION_SPACES[s] + ) if (game.spaces.length === 0) end_crisis_dimension_scoring() }, @@ -2942,7 +2942,7 @@ exports.is_checkpoint = function (a, b) { return a.round !== b.round } -exports.view = function(state, player) { +exports.view = function (state, player) { game = state view = { @@ -3047,9 +3047,9 @@ exports.resign = function (state, player) { game = state if (game.state !== "game_over") { if (player === COMMUNE) - goto_game_over(VERSAILLES, "Commune resigned."); + goto_game_over(VERSAILLES, "Commune resigned.") if (player === VERSAILLES) - goto_game_over(COMMUNE, "Versailles resigned."); + goto_game_over(COMMUNE, "Versailles resigned.") } return game } -- cgit v1.2.3