Automatic lineup ccreating

This commit is contained in:
memetrollsXD 2022-08-02 16:35:06 +02:00
parent 67d43bc0a1
commit d3b6b3c2d7
No known key found for this signature in database
GPG Key ID: 105C2F3417AC32CD
2 changed files with 41 additions and 24 deletions

View File

@ -115,18 +115,7 @@ export default class Player {
}, },
lineup: { lineup: {
curIndex: 0, curIndex: 0,
lineups: { lineups: {}
0: {
avatarList: [1001],
extraLineupType: ExtraLineupType.LINEUP_NONE,
index: 0,
isVirtual: false,
leaderSlot: 0,
mp: 100, // ?? Not sure what this is
name: "Default Lineup",
planeId: 10001
}
}
}, },
posData: { posData: {
floorID: 10001001, floorID: 10001001,
@ -135,6 +124,28 @@ export default class Player {
banned: false banned: false
} as PlayerI } as PlayerI
const baseLineup = {
avatarList: [1001],
extraLineupType: ExtraLineupType.LINEUP_NONE,
index: 0,
isVirtual: false,
leaderSlot: 0,
mp: 100, // ?? Not sure what this is
name: "",
planeId: 10001
}
const LINEUPS = 4;
let slot = 0;
dataObj.lineup = {
curIndex: 0,
lineups: {}
}
for (let i = 0; i <= LINEUPS; i++) {
let copy = baseLineup;
copy.index = slot++;
dataObj.lineup.lineups[i] = copy;
}
await db.set("players", dataObj); await db.set("players", dataObj);
return new Player(dataObj); return new Player(dataObj);
} }

View File

@ -46,20 +46,26 @@ export default async function handle(session: Session, packet: Packet) {
if (!plr.db.lineup) { if (!plr.db.lineup) {
Avatar.create(plr.db._id); Avatar.create(plr.db._id);
const baseLineup = {
avatarList: [1001],
extraLineupType: ExtraLineupType.LINEUP_NONE,
index: 0,
isVirtual: false,
leaderSlot: 0,
mp: 100, // ?? Not sure what this is
name: "",
planeId: 10001
}
const LINEUPS = 4;
let slot = 0;
plr.db.lineup = { plr.db.lineup = {
curIndex: 0, curIndex: 0,
lineups: { lineups: {}
0: { }
avatarList: [1001], for (let i = 0; i <= LINEUPS; i++) {
extraLineupType: ExtraLineupType.LINEUP_NONE, let copy = baseLineup;
index: 0, copy.index = slot++;
isVirtual: false, plr.db.lineup.lineups[i] = copy;
leaderSlot: 0,
mp: 100, // ?? Not sure what this is
name: "Default Lineup",
planeId: 10001
}
}
} }
plr.save(); plr.save();
} }