forked from noxious/server
movement shit
This commit is contained in:
parent
f791f1d5d8
commit
2728a9faf7
@ -30,7 +30,7 @@ class CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async processCommand(command: string): Promise<void> {
|
private async processCommand(command: string): Promise<void> {
|
||||||
const [cmd, ...args] = command.trim().toLowerCase().split(' ');
|
const [cmd, ...args] = command.trim().split(' ');
|
||||||
if (this.commands.has(cmd)) {
|
if (this.commands.has(cmd)) {
|
||||||
this.commands.get(cmd)?.(args, this.io as Server);
|
this.commands.get(cmd)?.(args, this.io as Server);
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,10 +44,8 @@ class ZoneManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Getter for loaded zones
|
// Getter for loaded zones
|
||||||
public getLoadedZones(): Zone[] {
|
public getLoadedZones(): TLoadedZone[] {
|
||||||
return this.loadedZones.map((loadedZone) => {
|
return this.loadedZones;
|
||||||
return loadedZone.zone;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public addCharacterToZone(zoneId: number, character: Character) {
|
public addCharacterToZone(zoneId: number, character: Character) {
|
||||||
@ -61,9 +59,11 @@ class ZoneManager {
|
|||||||
|
|
||||||
public removeCharacterFromZone(zoneId: number, characterId: number) {
|
public removeCharacterFromZone(zoneId: number, characterId: number) {
|
||||||
const loadedZone = this.loadedZones.find((loadedZone) => {
|
const loadedZone = this.loadedZones.find((loadedZone) => {
|
||||||
|
console.log('Checking zone', loadedZone.zone.id, zoneId);
|
||||||
return loadedZone.zone.id === zoneId;
|
return loadedZone.zone.id === zoneId;
|
||||||
});
|
});
|
||||||
if (loadedZone) {
|
if (loadedZone) {
|
||||||
|
console.log('Removing character from zone', characterId);
|
||||||
loadedZone.characters = loadedZone.characters.filter((character) => {
|
loadedZone.characters = loadedZone.characters.filter((character) => {
|
||||||
return character.id !== characterId;
|
return character.id !== characterId;
|
||||||
});
|
});
|
||||||
|
8
src/app/commands/listZones.ts
Normal file
8
src/app/commands/listZones.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Server } from "socket.io";
|
||||||
|
import ZoneManager from "../ZoneManager";
|
||||||
|
|
||||||
|
type CommandInput = string[]
|
||||||
|
|
||||||
|
export default function (input: CommandInput, io: Server) {
|
||||||
|
console.log(ZoneManager.getLoadedZones())
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user