Binato/server/objects/Slot.ts

48 lines
1,004 B
TypeScript
Raw Normal View History

2022-11-23 00:48:28 +00:00
import { Mods } from "../enums/Mods";
2022-11-21 23:26:20 +00:00
import { SlotStatus } from "../enums/SlotStatus";
2023-09-10 12:59:22 +01:00
import User from "./User";
2022-11-21 23:26:20 +00:00
2023-09-10 12:59:22 +01:00
export default class Slot {
2022-11-23 00:48:28 +00:00
public readonly slotId:number;
2022-11-21 23:26:20 +00:00
public status:SlotStatus;
2022-11-20 23:37:39 +00:00
public team:number;
2022-11-23 00:48:28 +00:00
public player?:User;
public mods:Mods;
2022-11-20 23:37:39 +00:00
2022-11-23 00:48:28 +00:00
public constructor(slotId:number, status:SlotStatus, team:number, player?:User, mods:Mods = Mods.None) {
this.slotId = slotId;
2022-11-21 23:26:20 +00:00
this.status = status;
this.team = team;
this.player = player;
this.mods = mods;
2022-11-20 23:37:39 +00:00
}
2022-11-23 00:48:28 +00:00
public transferFrom(slot:Slot) : Slot {
this.status = slot.status;
this.team = slot.team;
this.player = slot.player;
this.mods = slot.mods;
slot.reset();
return this;
}
public transferTo(slot:Slot) : Slot {
slot.status = this.status;
slot.team = this.team;
slot.player = this.player;
slot.mods = this.mods;
this.reset();
return slot;
}
public reset() : Slot {
this.status = SlotStatus.Empty;
this.team = 0;
this.player = undefined;
this.mods = Mods.None;
return this;
}
2022-11-19 01:06:03 +00:00
}