diff --git a/src/main.js b/src/main.js index 1c53f02..8c032f6 100644 --- a/src/main.js +++ b/src/main.js @@ -246,28 +246,51 @@ function aiBuy(player) { function initPlayers() { const playerCount = selectedPlayers; - for (let i=0; i ({...x})), - weapons: PLAYER_STARTING_WEAPONS.map(x => ({...x})), - currentWeapon: 0, - energy: PLAYER_MAX_ENERGY, - shield: {type:'springShield', energy:SHIELD_TYPES.springShield.energy}, - ai: i !== 0 ? sample(Object.keys(AI_TYPES)) : undefined, - parachute: null, - fallHeight: 0, - score: 0, - kills: 0, - deaths: 0, - shotsFired: 0, - wins: 0, - }); + const existingPlayers = players.length === playerCount ? players : []; + + if (existingPlayers.length === playerCount) { + for (let i=0; i ({...x})), + currentWeapon: 0, + energy: PLAYER_MAX_ENERGY, + shield: {type:'springShield', energy:SHIELD_TYPES.springShield.energy}, + ai: i !== 0 ? sample(Object.keys(AI_TYPES)) : undefined, + parachute: null, + fallHeight: 0, + score: 0, + kills: 0, + deaths: 0, + shotsFired: 0, + wins: 0, + }); + } } players = shuffle(players);