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
+24 -1
+24 -1
View File
@@ -246,6 +246,28 @@ function aiBuy(player) {
function initPlayers() {
const playerCount = selectedPlayers;
const existingPlayers = players.length === playerCount ? players : [];
if (existingPlayers.length === playerCount) {
for (let i=0; i<playerCount; i++) {
const player = existingPlayers[i];
player.dead = false;
player.x = 0;
player.y = 0;
player.a = 0;
player.p = PLAYER_INITIAL_POWER;
player.currentWeapon = 0;
player.energy = PLAYER_MAX_ENERGY;
player.shield = {type:'springShield', energy:SHIELD_TYPES.springShield.energy};
player.parachute = null;
player.fallHeight = 0;
player.kills = 0;
player.deaths = 0;
player.shotsFired = 0;
}
players = existingPlayers;
} else {
players = [];
for (let i=0; i<playerCount; i++) {
const [color, borderColor] = PLAYER_COLORS[i];
players.push({
@@ -254,7 +276,7 @@ function initPlayers() {
x:0, y:0, a:0,
c: color, cb: borderColor,
p: PLAYER_INITIAL_POWER,
tools: PLAYER_STARTING_TOOLS.map(x => ({...x})),
tools: [{type: 'parachute', ammo: 0}],
weapons: PLAYER_STARTING_WEAPONS.map(x => ({...x})),
currentWeapon: 0,
energy: PLAYER_MAX_ENERGY,
@@ -269,6 +291,7 @@ function initPlayers() {
wins: 0,
});
}
}
players = shuffle(players);