galvanic corrosion rewrite
commit this before something goes horribly wrong
This commit is contained in:
39
src/server/instances/Instance.ts
Normal file
39
src/server/instances/Instance.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import type Profile from "../profiles/profile.ts";
|
||||
import { RoomLocation } from "./base.ts";
|
||||
|
||||
export class Instance {
|
||||
|
||||
#createdAt = new Date();
|
||||
|
||||
#players: Set<Profile> = new Set();
|
||||
|
||||
#instanceId: number;
|
||||
#location: RoomLocation;
|
||||
|
||||
constructor(options: {
|
||||
id: number,
|
||||
location: RoomLocation,
|
||||
}
|
||||
) {
|
||||
this.#instanceId = options.id;
|
||||
this.#location = options.location;
|
||||
}
|
||||
|
||||
getPlayers() {
|
||||
return this.#players.values().toArray();
|
||||
}
|
||||
playerIsHere(profile: Profile) {
|
||||
return this.getPlayers().find(prof => prof.same(profile)) ? true : false;
|
||||
}
|
||||
removePlayer(profile: Profile) {
|
||||
this.#players.delete(profile);
|
||||
}
|
||||
addPlayer(profile: Profile) {
|
||||
this.#players.add(profile);
|
||||
}
|
||||
|
||||
getCreatedAt() {
|
||||
return this.#createdAt;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user