diff --git a/src/db/Player.ts b/src/db/Player.ts index 338dc35..7b3bd68 100644 --- a/src/db/Player.ts +++ b/src/db/Player.ts @@ -115,18 +115,7 @@ export default class Player { }, lineup: { curIndex: 0, - 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 - } - } + lineups: {} }, posData: { floorID: 10001001, @@ -135,6 +124,28 @@ export default class Player { banned: false } 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); return new Player(dataObj); } diff --git a/src/server/packets/PlayerLoginCsReq.ts b/src/server/packets/PlayerLoginCsReq.ts index ee8a12a..667c023 100644 --- a/src/server/packets/PlayerLoginCsReq.ts +++ b/src/server/packets/PlayerLoginCsReq.ts @@ -46,20 +46,26 @@ export default async function handle(session: Session, packet: Packet) { if (!plr.db.lineup) { 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 = { curIndex: 0, - 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 - } - } + lineups: {} + } + for (let i = 0; i <= LINEUPS; i++) { + let copy = baseLineup; + copy.index = slot++; + plr.db.lineup.lineups[i] = copy; } plr.save(); }