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>");
|
if (!planeID) return c.log("Usage: /scene <planeID>");
|
||||||
|
|
||||||
Interface.target.player.db.posData = {
|
// Update scene information on player.
|
||||||
floorID: planeID.StartFloorID,
|
Interface.target.player.db.posData.planeID = planeID!.PlaneID;
|
||||||
planeID: planeID.PlaneID,
|
Interface.target.player.db.posData.floorID = planeID!.StartFloorID;
|
||||||
pos: Interface.target.player.db.posData.pos
|
|
||||||
};
|
|
||||||
await Interface.target.player.save()
|
await Interface.target.player.save()
|
||||||
|
|
||||||
//ty for tamilpp25 scene
|
//ty for tamilpp25 scene
|
||||||
|
@ -43,7 +43,11 @@ interface PlayerI {
|
|||||||
posData: {
|
posData: {
|
||||||
floorID: number;
|
floorID: number;
|
||||||
planeID: number;
|
planeID: number;
|
||||||
pos: Vector;
|
pos: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +56,7 @@ export default class Player {
|
|||||||
public readonly scene: Scene;
|
public readonly scene: Scene;
|
||||||
private inventory!: Inventory;
|
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.uid = db._id;
|
||||||
this.scene = new Scene(this);
|
this.scene = new Scene(this);
|
||||||
}
|
}
|
||||||
@ -155,34 +159,25 @@ 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 = 6;
|
const LINEUPS = 6;
|
||||||
for (let i = 0; i < LINEUPS; i++) {
|
for (let i = 0; i < LINEUPS; i++) {
|
||||||
const copy = {
|
const l : LineupI = {
|
||||||
...baseLineup,
|
avatarList: [1001],
|
||||||
|
extraLineupType: ExtraLineupType.LINEUP_NONE,
|
||||||
index: i,
|
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);
|
const player = new Player(session, dataObj);
|
||||||
|
|
||||||
await Avatar.addAvatarToPlayer(player, 1001);
|
await Avatar.addAvatarToPlayer(player, 1001);
|
||||||
// await Avatar.create(uid, 1001, 0);
|
|
||||||
|
|
||||||
|
|
||||||
// Save to database and return.
|
// Save to database and return.
|
||||||
await db.set("players", dataObj);
|
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.
|
// Replace avatar in the player's lineup.
|
||||||
const slot = body.slot ?? 0;
|
const slot = body.slot ?? 0;
|
||||||
session.player.db.lineup.lineups[session.player.db.lineup.curIndex].avatarList[slot] = body.baseAvatarId;
|
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();
|
await session.player.save();
|
||||||
|
|
||||||
session.send(SyncLineupNotify, {
|
session.send(SyncLineupNotify, {
|
||||||
|
@ -23,7 +23,11 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
entity.pos = motion.pos;
|
entity.pos = motion.pos;
|
||||||
if (entity instanceof ActorEntity) {
|
if (entity instanceof ActorEntity) {
|
||||||
entity.mapLayer = entityMotion.mapLayer;
|
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