@civ-clone/library-unit 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Actions/SetHomeCity.d.ts +17 -0
- package/Actions/SetHomeCity.js +36 -0
- package/Actions/SetHomeCity.js.map +1 -0
- package/Actions/SetHomeCity.ts +38 -0
- package/Actions.d.ts +1 -0
- package/Actions.js +3 -1
- package/Actions.js.map +1 -1
- package/Actions.ts +1 -0
- package/package.json +5 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CityRegistry } from '@civ-clone/core-city/CityRegistry';
|
|
2
|
+
import { RuleRegistry } from '@civ-clone/core-rule/RuleRegistry';
|
|
3
|
+
import Action from '@civ-clone/core-unit/Action';
|
|
4
|
+
import Tile from '@civ-clone/core-world/Tile';
|
|
5
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
6
|
+
export declare class SetHomeCity extends Action {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(
|
|
9
|
+
from: Tile,
|
|
10
|
+
to: Tile,
|
|
11
|
+
unit: Unit,
|
|
12
|
+
ruleRegistry?: RuleRegistry,
|
|
13
|
+
cityRegistry?: CityRegistry
|
|
14
|
+
);
|
|
15
|
+
perform(...args: any[]): void;
|
|
16
|
+
}
|
|
17
|
+
export default SetHomeCity;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _SetHomeCity_cityRegistry;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SetHomeCity = void 0;
|
|
16
|
+
const CityRegistry_1 = require("@civ-clone/core-city/CityRegistry");
|
|
17
|
+
const RuleRegistry_1 = require("@civ-clone/core-rule/RuleRegistry");
|
|
18
|
+
const Action_1 = require("@civ-clone/core-unit/Action");
|
|
19
|
+
class SetHomeCity extends Action_1.default {
|
|
20
|
+
constructor(from, to, unit, ruleRegistry = RuleRegistry_1.instance, cityRegistry = CityRegistry_1.instance) {
|
|
21
|
+
super(from, to, unit, ruleRegistry);
|
|
22
|
+
_SetHomeCity_cityRegistry.set(this, void 0);
|
|
23
|
+
__classPrivateFieldSet(this, _SetHomeCity_cityRegistry, cityRegistry, "f");
|
|
24
|
+
}
|
|
25
|
+
perform(...args) {
|
|
26
|
+
const targetCity = __classPrivateFieldGet(this, _SetHomeCity_cityRegistry, "f").getByTile(this.from());
|
|
27
|
+
if (!targetCity) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.unit().setCity(targetCity);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.SetHomeCity = SetHomeCity;
|
|
34
|
+
_SetHomeCity_cityRegistry = new WeakMap();
|
|
35
|
+
exports.default = SetHomeCity;
|
|
36
|
+
//# sourceMappingURL=SetHomeCity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetHomeCity.js","sourceRoot":"","sources":["SetHomeCity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAG2C;AAC3C,oEAG2C;AAC3C,wDAAiD;AAIjD,MAAa,WAAY,SAAQ,gBAAM;IAGrC,YACE,IAAU,EACV,EAAQ,EACR,IAAU,EACV,eAA6B,uBAAoB,EACjD,eAA6B,uBAAoB;QAEjD,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QATtC,4CAA4B;QAW1B,uBAAA,IAAI,6BAAiB,YAAY,MAAA,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,GAAG,IAAW;QACpB,MAAM,UAAU,GAAG,uBAAA,IAAI,iCAAc,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAE7D,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;CACF;AAvBD,kCAuBC;;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CityRegistry,
|
|
3
|
+
instance as cityRegistryInstance,
|
|
4
|
+
} from '@civ-clone/core-city/CityRegistry';
|
|
5
|
+
import {
|
|
6
|
+
RuleRegistry,
|
|
7
|
+
instance as ruleRegistryInstance,
|
|
8
|
+
} from '@civ-clone/core-rule/RuleRegistry';
|
|
9
|
+
import Action from '@civ-clone/core-unit/Action';
|
|
10
|
+
import Tile from '@civ-clone/core-world/Tile';
|
|
11
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
12
|
+
|
|
13
|
+
export class SetHomeCity extends Action {
|
|
14
|
+
#cityRegistry: CityRegistry;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
from: Tile,
|
|
18
|
+
to: Tile,
|
|
19
|
+
unit: Unit,
|
|
20
|
+
ruleRegistry: RuleRegistry = ruleRegistryInstance,
|
|
21
|
+
cityRegistry: CityRegistry = cityRegistryInstance
|
|
22
|
+
) {
|
|
23
|
+
super(from, to, unit, ruleRegistry);
|
|
24
|
+
|
|
25
|
+
this.#cityRegistry = cityRegistry;
|
|
26
|
+
}
|
|
27
|
+
perform(...args: any[]): void {
|
|
28
|
+
const targetCity = this.#cityRegistry.getByTile(this.from());
|
|
29
|
+
|
|
30
|
+
if (!targetCity) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.unit().setCity(targetCity);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default SetHomeCity;
|
package/Actions.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { Move } from './Actions/Move';
|
|
|
17
17
|
export { NoOrders } from './Actions/NoOrders';
|
|
18
18
|
export { Pillage } from './Actions/Pillage';
|
|
19
19
|
export { PlantForest } from './Actions/PlantForest';
|
|
20
|
+
export { SetHomeCity } from './Actions/SetHomeCity';
|
|
20
21
|
export { Sleep } from './Actions/Sleep';
|
|
21
22
|
export { SneakAttack } from './Actions/SneakAttack';
|
|
22
23
|
export { SneakCaptureCity } from './Actions/SneakCaptureCity';
|
package/Actions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Unload = exports.SneakCaptureCity = exports.SneakAttack = exports.Sleep = exports.PlantForest = exports.Pillage = exports.NoOrders = exports.Move = exports.GoTo = exports.FoundCity = exports.Fortify = exports.Embark = exports.Disembark = exports.Disband = exports.ClearSwamp = exports.ClearJungle = exports.ClearForest = exports.CaptureCity = exports.BuildRoad = exports.BuildRailroad = exports.BuildMine = exports.BuildIrrigation = exports.Attack = void 0;
|
|
3
|
+
exports.Unload = exports.SneakCaptureCity = exports.SneakAttack = exports.Sleep = exports.SetHomeCity = exports.PlantForest = exports.Pillage = exports.NoOrders = exports.Move = exports.GoTo = exports.FoundCity = exports.Fortify = exports.Embark = exports.Disembark = exports.Disband = exports.ClearSwamp = exports.ClearJungle = exports.ClearForest = exports.CaptureCity = exports.BuildRoad = exports.BuildRailroad = exports.BuildMine = exports.BuildIrrigation = exports.Attack = void 0;
|
|
4
4
|
var Attack_1 = require("./Actions/Attack");
|
|
5
5
|
Object.defineProperty(exports, "Attack", { enumerable: true, get: function () { return Attack_1.Attack; } });
|
|
6
6
|
var BuildIrrigation_1 = require("./Actions/BuildIrrigation");
|
|
@@ -39,6 +39,8 @@ var Pillage_1 = require("./Actions/Pillage");
|
|
|
39
39
|
Object.defineProperty(exports, "Pillage", { enumerable: true, get: function () { return Pillage_1.Pillage; } });
|
|
40
40
|
var PlantForest_1 = require("./Actions/PlantForest");
|
|
41
41
|
Object.defineProperty(exports, "PlantForest", { enumerable: true, get: function () { return PlantForest_1.PlantForest; } });
|
|
42
|
+
var SetHomeCity_1 = require("./Actions/SetHomeCity");
|
|
43
|
+
Object.defineProperty(exports, "SetHomeCity", { enumerable: true, get: function () { return SetHomeCity_1.SetHomeCity; } });
|
|
42
44
|
var Sleep_1 = require("./Actions/Sleep");
|
|
43
45
|
Object.defineProperty(exports, "Sleep", { enumerable: true, get: function () { return Sleep_1.Sleep; } });
|
|
44
46
|
var SneakAttack_1 = require("./Actions/SneakAttack");
|
package/Actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actions.js","sourceRoot":"","sources":["Actions.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAAjC,gGAAA,MAAM,OAAA;AACf,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,iDAAgD;AAAvC,sGAAA,SAAS,OAAA;AAClB,yDAAwD;AAA/C,8GAAA,aAAa,OAAA;AACtB,iDAAgD;AAAvC,sGAAA,SAAS,OAAA;AAClB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,mDAAkD;AAAzC,wGAAA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,uCAAsC;AAA7B,4FAAA,IAAI,OAAA;AACb,uCAAsC;AAA7B,4FAAA,IAAI,OAAA;AACb,+CAA8C;AAArC,oGAAA,QAAQ,OAAA;AACjB,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,yCAAwC;AAA/B,8FAAA,KAAK,OAAA;AACd,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,oHAAA,gBAAgB,OAAA;AACzB,2CAA0C;AAAjC,gGAAA,MAAM,OAAA"}
|
package/Actions.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { Move } from './Actions/Move';
|
|
|
17
17
|
export { NoOrders } from './Actions/NoOrders';
|
|
18
18
|
export { Pillage } from './Actions/Pillage';
|
|
19
19
|
export { PlantForest } from './Actions/PlantForest';
|
|
20
|
+
export { SetHomeCity } from './Actions/SetHomeCity';
|
|
20
21
|
export { Sleep } from './Actions/Sleep';
|
|
21
22
|
export { SneakAttack } from './Actions/SneakAttack';
|
|
22
23
|
export { SneakCaptureCity } from './Actions/SneakCaptureCity';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civ-clone/library-unit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"repository": "git@github.com:civ-clone/library-unit.git",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -79,6 +79,9 @@
|
|
|
79
79
|
"@civ-clone/base-unit-type-naval-transport": "^0.1.0",
|
|
80
80
|
"@civ-clone/base-unit-type-worker": "^0.1.0",
|
|
81
81
|
"@civ-clone/base-unit-warrior": "^0.1.0",
|
|
82
|
-
"@civ-clone/core-
|
|
82
|
+
"@civ-clone/core-city": "^0.1.0",
|
|
83
|
+
"@civ-clone/core-unit": "^0.1.0",
|
|
84
|
+
"@civ-clone/core-unit-transport": "^0.1.0",
|
|
85
|
+
"@civ-clone/core-world": "^0.1.0"
|
|
83
86
|
}
|
|
84
87
|
}
|