@civ-clone/base-unit-action-goto 0.1.2 → 0.1.4

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/GoTo.d.ts CHANGED
@@ -6,7 +6,8 @@ import Tile from '@civ-clone/core-world/Tile';
6
6
  import Unit from '@civ-clone/core-unit/Unit';
7
7
  export declare const generateKey: (unit: Unit) => string;
8
8
  export declare class GoTo extends Action {
9
- #private;
9
+ private _pathFinderRegistry;
10
+ private _strategyNoteRegistry;
10
11
  constructor(
11
12
  from: Tile,
12
13
  to: Tile,
package/GoTo.js CHANGED
@@ -1,16 +1,4 @@
1
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 _GoTo_pathFinderRegistry, _GoTo_strategyNoteRegistry;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.GoTo = exports.generateKey = void 0;
16
4
  const PathFinderRegistry_1 = require("@civ-clone/core-world-path/PathFinderRegistry");
@@ -30,13 +18,11 @@ exports.generateKey = generateKey;
30
18
  class GoTo extends Action_1.default {
31
19
  constructor(from, to, unit, ruleRegistry = RuleRegistry_1.instance, pathFinderRegistry = PathFinderRegistry_1.instance, strategyNoteRegistry = StrategyNoteRegistry_1.instance) {
32
20
  super(from, to, unit, ruleRegistry);
33
- _GoTo_pathFinderRegistry.set(this, void 0);
34
- _GoTo_strategyNoteRegistry.set(this, void 0);
35
- __classPrivateFieldSet(this, _GoTo_pathFinderRegistry, pathFinderRegistry, "f");
36
- __classPrivateFieldSet(this, _GoTo_strategyNoteRegistry, strategyNoteRegistry, "f");
21
+ this._pathFinderRegistry = pathFinderRegistry;
22
+ this._strategyNoteRegistry = strategyNoteRegistry;
37
23
  }
38
24
  perform() {
39
- const [PathFinder] = __classPrivateFieldGet(this, _GoTo_pathFinderRegistry, "f").entries();
25
+ const [PathFinder] = this._pathFinderRegistry.entries();
40
26
  if (!PathFinder) {
41
27
  throw new NoPathFinderAvailable_1.default();
42
28
  }
@@ -47,7 +33,7 @@ class GoTo extends Action_1.default {
47
33
  this.unit().setBusy();
48
34
  // remove the current `Tile` so that the next shift will be the target.
49
35
  path.shift();
50
- __classPrivateFieldGet(this, _GoTo_strategyNoteRegistry, "f").replace(new StrategyNote_1.StrategyNote((0, exports.generateKey)(this.unit()), path));
36
+ this._strategyNoteRegistry.replace(new StrategyNote_1.StrategyNote((0, exports.generateKey)(this.unit()), path));
51
37
  (0, moveAlongPath_1.default)(this.unit(), path);
52
38
  this.unit().setBusy(new GoTo_1.default(new Criterion_1.default(() => this.unit().tile() === path.end()), new Effect_1.default(() => {
53
39
  this.unit().setActive();
@@ -57,6 +43,5 @@ class GoTo extends Action_1.default {
57
43
  }
58
44
  }
59
45
  exports.GoTo = GoTo;
60
- _GoTo_pathFinderRegistry = new WeakMap(), _GoTo_strategyNoteRegistry = new WeakMap();
61
46
  exports.default = GoTo;
62
47
  //# sourceMappingURL=GoTo.js.map
package/GoTo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"GoTo.js","sourceRoot":"","sources":["GoTo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sFAGuD;AACvD,oEAG2C;AAC3C,wEAG+C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AY,EAAE,CAAC,OAAO,CAAC,eAAK,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;CACF;AA1DD,oBA0DC;AAED,kBAAe,IAAI,CAAC"}
package/GoTo.ts CHANGED
@@ -28,8 +28,8 @@ import moveAlongPath from './lib/moveAlongPath';
28
28
  export const generateKey = (unit: Unit) => generateRawKey(unit, 'currentPath');
29
29
 
30
30
  export class GoTo extends Action {
31
- #pathFinderRegistry: PathFinderRegistry;
32
- #strategyNoteRegistry: StrategyNoteRegistry;
31
+ private _pathFinderRegistry: PathFinderRegistry;
32
+ private _strategyNoteRegistry: StrategyNoteRegistry;
33
33
 
34
34
  constructor(
35
35
  from: Tile,
@@ -41,12 +41,12 @@ export class GoTo extends Action {
41
41
  ) {
42
42
  super(from, to, unit, ruleRegistry);
43
43
 
44
- this.#pathFinderRegistry = pathFinderRegistry;
45
- this.#strategyNoteRegistry = strategyNoteRegistry;
44
+ this._pathFinderRegistry = pathFinderRegistry;
45
+ this._strategyNoteRegistry = strategyNoteRegistry;
46
46
  }
47
47
 
48
48
  perform(): void {
49
- const [PathFinder] = this.#pathFinderRegistry.entries();
49
+ const [PathFinder] = this._pathFinderRegistry.entries();
50
50
 
51
51
  if (!PathFinder) {
52
52
  throw new NoPathFinderAvailable();
@@ -67,7 +67,7 @@ export class GoTo extends Action {
67
67
  // remove the current `Tile` so that the next shift will be the target.
68
68
  path.shift();
69
69
 
70
- this.#strategyNoteRegistry.replace(
70
+ this._strategyNoteRegistry.replace(
71
71
  new StrategyNote(generateKey(this.unit()), path)
72
72
  );
73
73
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civ-clone/base-unit-action-goto",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:civ-clone/base-unit-action-goto.git",
6
6
  "keywords": [
@@ -24,6 +24,7 @@
24
24
  "dependencies": {
25
25
  "@civ-clone/base-unit-action-move": "^0.1.1",
26
26
  "@civ-clone/base-unit-action-no-orders": "^0.1.0",
27
+ "@civ-clone/core-game": "^0.1.1",
27
28
  "@civ-clone/core-player": "^0.1.0",
28
29
  "@civ-clone/core-rule": "^0.1.2",
29
30
  "@civ-clone/core-strategy": "^0.1.0",
@@ -1 +1,3 @@
1
- export {};
1
+ import { Game } from '@civ-clone/core-game';
2
+ export declare const register: (game: Game) => void;
3
+ export default register;
package/registerRules.js CHANGED
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const RuleRegistry_1 = require("@civ-clone/core-rule/RuleRegistry");
3
+ exports.register = void 0;
4
4
  const turn_start_1 = require("./Rules/Player/turn-start");
5
- RuleRegistry_1.instance.register(...(0, turn_start_1.default)());
5
+ const core_game_1 = require("@civ-clone/core-game");
6
+ const register = (game) => game.rules.register(...(0, turn_start_1.default)(game.strategyNotes, game.units));
7
+ exports.register = register;
8
+ // The plugin loader imports each package for this side effect. Until it passes
9
+ // a `Game` of its own, dropping it would produce a game with silently absent
10
+ // rules — no error, just wrong behaviour.
11
+ (0, exports.register)(core_game_1.defaultGame);
12
+ exports.default = exports.register;
6
13
  //# sourceMappingURL=registerRules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerRules.js","sourceRoot":"","sources":["registerRules.ts"],"names":[],"mappings":";;AAAA,oEAAqF;AACrF,0DAAkD;AAElD,uBAAoB,CAAC,QAAQ,CAAC,GAAG,IAAA,oBAAS,GAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"registerRules.js","sourceRoot":"","sources":["registerRules.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAClD,oDAAyD;AAElD,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAQ,EAAE,CAC3C,IAAI,CAAC,KAAK,CAAC,QAAQ,CACjB,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAC7C,CAAC;AAHS,QAAA,QAAQ,YAGjB;AAEJ,+EAA+E;AAC/E,6EAA6E;AAC7E,0CAA0C;AAC1C,IAAA,gBAAQ,EAAC,uBAAW,CAAC,CAAC;AAEtB,kBAAe,gBAAQ,CAAA"}
package/registerRules.ts CHANGED
@@ -1,4 +1,12 @@
1
- import { instance as ruleRegistryInstance } from '@civ-clone/core-rule/RuleRegistry';
2
1
  import turnStart from './Rules/Player/turn-start';
2
+ import { Game, defaultGame } from '@civ-clone/core-game';
3
3
 
4
- ruleRegistryInstance.register(...turnStart());
4
+ export const register = (game: Game): void =>
5
+ game.rules.register(...turnStart(game.strategyNotes, game.units));
6
+
7
+ // The plugin loader imports each package for this side effect. Until it passes
8
+ // a `Game` of its own, dropping it would produce a game with silently absent
9
+ // rules — no error, just wrong behaviour.
10
+ register(defaultGame);
11
+
12
+ export default register;
package/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "declaration": true,
4
4
  "lib": [
5
- "es2019"
5
+ "es2020"
6
6
  ],
7
7
  "module": "commonjs",
8
8
  "sourceMap": true,
@@ -13,4 +13,4 @@
13
13
  "node_modules",
14
14
  "tests/*.test.ts"
15
15
  ]
16
- }
16
+ }