fix: purchased weapons are now active in game

This commit is contained in:
catarrh committed 2026-07-24 23:31:48 +03:00
1 parent eab6fef606
commit 36e13a6354
1 file changed
+45 -22
+45 -22
View File
@@ -246,28 +246,51 @@ function aiBuy(player) {
function initPlayers() { function initPlayers() {
const playerCount = selectedPlayers; const playerCount = selectedPlayers;
for (let i=0; i<playerCount; i++) { const existingPlayers = players.length === playerCount ? players : [];
const [color, borderColor] = PLAYER_COLORS[i];
players.push({ if (existingPlayers.length === playerCount) {
name: `Player ${i+1}`, for (let i=0; i<playerCount; i++) {
dead: false, const player = existingPlayers[i];
x:0, y:0, a:0, player.dead = false;
c: color, cb: borderColor, player.x = 0;
p: PLAYER_INITIAL_POWER, player.y = 0;
tools: PLAYER_STARTING_TOOLS.map(x => ({...x})), player.a = 0;
weapons: PLAYER_STARTING_WEAPONS.map(x => ({...x})), player.p = PLAYER_INITIAL_POWER;
currentWeapon: 0, player.currentWeapon = 0;
energy: PLAYER_MAX_ENERGY, player.energy = PLAYER_MAX_ENERGY;
shield: {type:'springShield', energy:SHIELD_TYPES.springShield.energy}, player.shield = {type:'springShield', energy:SHIELD_TYPES.springShield.energy};
ai: i !== 0 ? sample(Object.keys(AI_TYPES)) : undefined, player.parachute = null;
parachute: null, player.fallHeight = 0;
fallHeight: 0, player.kills = 0;
score: 0, player.deaths = 0;
kills: 0, player.shotsFired = 0;
deaths: 0, }
shotsFired: 0, players = existingPlayers;
wins: 0, } else {
}); players = [];
for (let i=0; i<playerCount; i++) {
const [color, borderColor] = PLAYER_COLORS[i];
players.push({
name: `Player ${i+1}`,
dead: false,
x:0, y:0, a:0,
c: color, cb: borderColor,
p: PLAYER_INITIAL_POWER,
tools: [{type: 'parachute', ammo: 0}],
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,
});
}
} }
players = shuffle(players); players = shuffle(players);