-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitRegistry.js
26 lines (26 loc) · 958 Bytes
/
UnitRegistry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.instance = exports.UnitRegistry = void 0;
const EntityRegistry_1 = require("@civ-clone/core-registry/EntityRegistry");
const Unit_1 = require("./Unit");
class UnitRegistry extends EntityRegistry_1.EntityRegistry {
constructor() {
super(Unit_1.default);
}
getByCity(city) {
return this.filter((unit) => unit.city() === city && !unit.destroyed());
}
getByPlayer(player, includeDestroyed = false) {
if (includeDestroyed) {
return this.getBy('player', player);
}
return this.filter((unit) => unit.player() === player && !unit.destroyed());
}
getByTile(tile) {
return this.filter((unit) => unit.tile() === tile && !unit.destroyed());
}
}
exports.UnitRegistry = UnitRegistry;
exports.instance = new UnitRegistry();
exports.default = UnitRegistry;
//# sourceMappingURL=UnitRegistry.js.map