From 0fae284f79b1c934e58214cf5f88cad4cab6b03b Mon Sep 17 00:00:00 2001 From: Frans Bongers Date: Wed, 19 Mar 2025 21:55:43 +0100 Subject: refactor: FrontId to number --- rules.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 9dedb5b..40cde75 100644 --- a/rules.js +++ b/rules.js @@ -410,28 +410,28 @@ function setup(seed, _scenario, options) { }, engine: [], faction_turn: null, - fronts: { - a: { + fronts: [ + { value: -2, contributions: [], status: null, }, - m: { + { value: -2, contributions: [], status: null, }, - n: { + { value: -2, contributions: [], status: null, }, - s: { + { value: -2, contributions: [], status: null, }, - }, + ], glory: [], first_player: null, hands: { @@ -2551,7 +2551,7 @@ function defeat_on_a_front(front_id) { log_br(); log('Defeat on ' + get_front_name(front_id) + '!'); log_br(); - if (front_id === 'm' || get_defeated_front_count() == 2) { + if (front_id === data_1.MADRID || get_defeated_front_count() == 2) { game_over('Fascist', 'All players lose the game!'); return; } @@ -2745,7 +2745,7 @@ function get_fronts_closest_to(target) { return []; } const targetValue = target === 'd' ? Math.min(...values) : Math.max(...values); - return Object.keys(game.fronts).filter((frontId) => game.fronts[frontId].value === targetValue); + return game.fronts.findIndex((front) => front.value === targetValue); } function log_br() { if (game.log.length > 0 && game.log[game.log.length - 1] !== '') -- cgit v1.2.3