fix: purchased weapons are now active in game
This commit is contained in:
1 parent
eab6fef606
commit
36e13a6354
1 file changed
+24
-1
+24
-1
@@ -246,6 +246,28 @@ function aiBuy(player) {
|
|||||||
|
|
||||||
function initPlayers() {
|
function initPlayers() {
|
||||||
const playerCount = selectedPlayers;
|
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++) {
|
for (let i=0; i<playerCount; i++) {
|
||||||
const [color, borderColor] = PLAYER_COLORS[i];
|
const [color, borderColor] = PLAYER_COLORS[i];
|
||||||
players.push({
|
players.push({
|
||||||
@@ -254,7 +276,7 @@ function initPlayers() {
|
|||||||
x:0, y:0, a:0,
|
x:0, y:0, a:0,
|
||||||
c: color, cb: borderColor,
|
c: color, cb: borderColor,
|
||||||
p: PLAYER_INITIAL_POWER,
|
p: PLAYER_INITIAL_POWER,
|
||||||
tools: PLAYER_STARTING_TOOLS.map(x => ({...x})),
|
tools: [{type: 'parachute', ammo: 0}],
|
||||||
weapons: PLAYER_STARTING_WEAPONS.map(x => ({...x})),
|
weapons: PLAYER_STARTING_WEAPONS.map(x => ({...x})),
|
||||||
currentWeapon: 0,
|
currentWeapon: 0,
|
||||||
energy: PLAYER_MAX_ENERGY,
|
energy: PLAYER_MAX_ENERGY,
|
||||||
@@ -269,6 +291,7 @@ function initPlayers() {
|
|||||||
wins: 0,
|
wins: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
players = shuffle(players);
|
players = shuffle(players);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user