monopoly-shared-model
Version:
Shared model for Monopoly
40 lines • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Serializable_1 = require("../Serializable");
class Box extends Serializable_1.Serializable {
constructor(index, name, type) {
super();
this.index = index;
this.name = name;
this.type = type;
this.playerNames = [];
}
getIndex() {
return this.index;
}
getName() {
return this.name;
}
getType() {
return this.type;
}
getPlayerNames() {
return this.playerNames;
}
playerArrive(player) {
if (!this.hasPlayer(player)) {
this.playerNames.push(player.getName());
}
}
playerLeave(player) {
const playerIndex = this.playerNames.findIndex((p) => p === player.getName());
if (playerIndex > -1) {
this.playerNames.splice(playerIndex, 1);
}
}
hasPlayer(player) {
return this.playerNames.includes(player.getName());
}
}
exports.Box = Box;
//# sourceMappingURL=Box.js.map