Fix Cyclic Dependency Error (#43)
This commit is contained in:
parent
76a1273128
commit
50c51738aa
@ -20,11 +20,9 @@ export default async function handle(command: Command) {
|
||||
|
||||
if (!planeID) return c.log("Usage: /scene <planeID>");
|
||||
|
||||
Interface.target.player.db.posData = {
|
||||
floorID: planeID.StartFloorID,
|
||||
planeID: planeID.PlaneID,
|
||||
pos: Interface.target.player.db.posData.pos
|
||||
};
|
||||
// Update scene information on player.
|
||||
Interface.target.player.db.posData.planeID = planeID!.PlaneID;
|
||||
Interface.target.player.db.posData.floorID = planeID!.StartFloorID;
|
||||
await Interface.target.player.save()
|
||||
|
||||
//ty for tamilpp25 scene
|
||||
|
@ -43,7 +43,11 @@ interface PlayerI {
|
||||
posData: {
|
||||
floorID: number;
|
||||
planeID: number;
|
||||
pos: Vector;
|
||||
pos: {
|
||||
x: number,
|
||||
y: number,
|
||||
z: number
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +56,7 @@ export default class Player {
|
||||
public readonly scene: Scene;
|
||||
private inventory!: Inventory;
|
||||
|
||||
private constructor(readonly session: Session, public db: PlayerI) {
|
||||
private constructor(readonly session: Session, public readonly db: PlayerI) {
|
||||
this.uid = db._id;
|
||||
this.scene = new Scene(this);
|
||||
}
|
||||
@ -155,34 +159,25 @@ 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
|
||||
}
|
||||
} as PlayerI;
|
||||
|
||||
const LINEUPS = 6;
|
||||
for (let i = 0; i < LINEUPS; i++) {
|
||||
const copy = {
|
||||
...baseLineup,
|
||||
const l : LineupI = {
|
||||
avatarList: [1001],
|
||||
extraLineupType: ExtraLineupType.LINEUP_NONE,
|
||||
index: i,
|
||||
name: `Team ${i}`
|
||||
isVirtual: false,
|
||||
leaderSlot: 0,
|
||||
mp: 100,
|
||||
name: `Team ${i}`,
|
||||
planeId: 10001
|
||||
};
|
||||
dataObj.lineup.lineups[i] = copy;
|
||||
dataObj.lineup.lineups[i] = l;
|
||||
}
|
||||
|
||||
const player = new Player(session, dataObj);
|
||||
|
||||
await Avatar.addAvatarToPlayer(player, 1001);
|
||||
// await Avatar.create(uid, 1001, 0);
|
||||
|
||||
|
||||
// Save to database and return.
|
||||
await db.set("players", dataObj);
|
||||
|
@ -11,31 +11,6 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
// Replace avatar in the player's lineup.
|
||||
const slot = body.slot ?? 0;
|
||||
session.player.db.lineup.lineups[session.player.db.lineup.curIndex].avatarList[slot] = body.baseAvatarId;
|
||||
|
||||
/*
|
||||
|
||||
let lineup = await session.player.getLineup();
|
||||
const avatarList = [];
|
||||
|
||||
// What in the fuck is the purpose of this loop supposed to be?!
|
||||
for (const avatarId in lineup) {
|
||||
const avatar = await Avatar.fromUID(session.player.db._id, Number(avatarId));
|
||||
if (avatar.length === 0) return session.c.warn(`Avatar ${body.baseAvatarId} not found`);
|
||||
if (avatar) avatarList.push(avatar[0]);
|
||||
}
|
||||
|
||||
lineup.avatarList[slot] = {
|
||||
avatarType: AvatarType.AVATAR_FORMAL_TYPE,
|
||||
hp: 10000,
|
||||
id: body.baseAvatarId,
|
||||
satiety: 100,
|
||||
slot,
|
||||
sp: 10000
|
||||
};
|
||||
if (body.extraLineupType) lineup.extraLineupType = body.extraLineupType;
|
||||
session.player.setLineup(lineup);
|
||||
*/
|
||||
|
||||
await session.player.save();
|
||||
|
||||
session.send(SyncLineupNotify, {
|
||||
|
@ -23,7 +23,11 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
entity.pos = motion.pos;
|
||||
if (entity instanceof ActorEntity) {
|
||||
entity.mapLayer = entityMotion.mapLayer;
|
||||
session.player.db.posData.pos = motion.pos!;
|
||||
session.player.db.posData.pos = {
|
||||
x: motion.pos.x,
|
||||
y: motion.pos.y,
|
||||
z: motion.pos.z
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user