better JSON serializer

This commit is contained in:
biglyderv 2024-11-25 14:14:20 -05:00
parent 53193fbb60
commit 6ffbc44ab0
2 changed files with 32 additions and 15 deletions

View file

@ -147,13 +147,17 @@ class Game extends GameBasic {
let that = this;
let entList = JSON.parse(data);
entList = entList.map((y, i) => {
entList = entList.map((j, i) => {
if (i == entList.length - 1) {
that.width = y[0];
that.height = y[1];
that.width = j[0];
that.height = j[1];
return undefined;
}
if (!j) return undefined;
let y = j; //(typeof j == 'string') ? JSON.parse(j) : j;
let type = (Object.keys(legalTypes).indexOf(y[0]) == -1) ? Player : legalTypes[y[0]];
let props = new type().serverProps;
@ -186,7 +190,6 @@ class Game extends GameBasic {
let matchingPlayer = entList.filter(x => x && x.you == you)
if (matchingPlayer.length == 0) {
matchingPlayer = entList.filter(x => x && x.isYou);
}