expanding map

This commit is contained in:
biglyderv 2024-11-25 14:14:20 -05:00
parent 4602947942
commit e584361465
5 changed files with 27 additions and 10 deletions

View file

@ -147,11 +147,17 @@ class Game extends GameBasic {
let that = this;
let entList = JSON.parse(data);
entList = entList.map(y => {
entList = entList.map((y, i) => {
if (i == entList.length - 1) {
that.width = y[0];
that.height = y[1];
return undefined;
}
let type = (Object.keys(legalTypes).indexOf(y[0]) == -1) ? Player : legalTypes[y[0]];
let props = new type().serverProps;
let x = {};
for (let i in props) {
@ -176,11 +182,13 @@ class Game extends GameBasic {
return x;
})
let matchingPlayer = entList.filter(x => x.you == you)
entList = entList.filter(x => x);
let matchingPlayer = entList.filter(x => x && x.you == you)
if (matchingPlayer.length == 0) {
matchingPlayer = entList.filter(x => x.isYou);
matchingPlayer = entList.filter(x => x && x.isYou);
}
this.player = Object.assign(this.player || new Player(false, false), matchingPlayer[0]);