@civ-clone/core-strategy 0.1.1 → 0.1.2

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/Strategy.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface IStrategy {
6
6
  priority(action: PlayerAction): Priority;
7
7
  }
8
8
  export declare class Strategy implements IStrategy {
9
- #private;
9
+ private _ruleRegistry;
10
10
  constructor(ruleRegistry?: RuleRegistry);
11
11
  /**
12
12
  * Checks to see if the `action` can be handled, returns `true` if it is, `false` otherwise.
package/Strategy.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 _Strategy_ruleRegistry;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.Strategy = void 0;
16
4
  const RuleRegistry_1 = require("@civ-clone/core-rule/RuleRegistry");
@@ -18,8 +6,7 @@ const Priority_1 = require("@civ-clone/core-rule/Priority");
18
6
  const Priority_2 = require("./Rules/Priority");
19
7
  class Strategy {
20
8
  constructor(ruleRegistry = RuleRegistry_1.instance) {
21
- _Strategy_ruleRegistry.set(this, void 0);
22
- __classPrivateFieldSet(this, _Strategy_ruleRegistry, ruleRegistry, "f");
9
+ this._ruleRegistry = ruleRegistry;
23
10
  }
24
11
  /**
25
12
  * Checks to see if the `action` can be handled, returns `true` if it is, `false` otherwise.
@@ -30,15 +17,14 @@ class Strategy {
30
17
  priority(action) {
31
18
  return new Priority_1.default(
32
19
  // This takes the highest priority (lowest value) from all the applicable `PriorityRule`s
33
- Math.min(...__classPrivateFieldGet(this, _Strategy_ruleRegistry, "f")
20
+ Math.min(...this._ruleRegistry
34
21
  .process(Priority_2.default, action, this)
35
22
  .map((priority) => priority.value()), Infinity));
36
23
  }
37
24
  ruleRegistry() {
38
- return __classPrivateFieldGet(this, _Strategy_ruleRegistry, "f");
25
+ return this._ruleRegistry;
39
26
  }
40
27
  }
41
28
  exports.Strategy = Strategy;
42
- _Strategy_ruleRegistry = new WeakMap();
43
29
  exports.default = Strategy;
44
30
  //# sourceMappingURL=Strategy.js.map
package/Strategy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Strategy.js","sourceRoot":"","sources":["Strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAG2C;AAE3C,4DAAqD;AACrD,+CAA4C;AAO5C,MAAa,QAAQ;IAGnB,YAAY,eAA6B,uBAAoB;QAF7D,yCAA4B;QAG1B,uBAAA,IAAI,0BAAiB,YAAY,MAAA,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,MAAoB;QAC1B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,QAAQ,CAAC,MAAoB;QAC3B,OAAO,IAAI,kBAAQ;QACjB,yFAAyF;QACzF,IAAI,CAAC,GAAG,CACN,GAAG,uBAAA,IAAI,8BAAc;aAClB,OAAO,CAAC,kBAAY,EAAE,MAAM,EAAE,IAAI,CAAC;aACnC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EACtC,QAAQ,CACT,CACF,CAAC;IACJ,CAAC;IAES,YAAY;QACpB,OAAO,uBAAA,IAAI,8BAAc,CAAC;IAC5B,CAAC;CACF;AA7BD,4BA6BC;;AAED,kBAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Strategy.js","sourceRoot":"","sources":["Strategy.ts"],"names":[],"mappings":";;;AAAA,oEAG2C;AAE3C,4DAAqD;AACrD,+CAA4C;AAO5C,MAAa,QAAQ;IAGnB,YAAY,eAA6B,uBAAoB;QAC3D,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,MAAoB;QAC1B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,QAAQ,CAAC,MAAoB;QAC3B,OAAO,IAAI,kBAAQ;QACjB,yFAAyF;QACzF,IAAI,CAAC,GAAG,CACN,GAAG,IAAI,CAAC,aAAa;aAClB,OAAO,CAAC,kBAAY,EAAE,MAAM,EAAE,IAAI,CAAC;aACnC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EACtC,QAAQ,CACT,CACF,CAAC;IACJ,CAAC;IAES,YAAY;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF;AA7BD,4BA6BC;AAED,kBAAe,QAAQ,CAAC"}
package/Strategy.ts CHANGED
@@ -12,10 +12,10 @@ export interface IStrategy {
12
12
  }
13
13
 
14
14
  export class Strategy implements IStrategy {
15
- #ruleRegistry: RuleRegistry;
15
+ private _ruleRegistry: RuleRegistry;
16
16
 
17
17
  constructor(ruleRegistry: RuleRegistry = ruleRegistryInstance) {
18
- this.#ruleRegistry = ruleRegistry;
18
+ this._ruleRegistry = ruleRegistry;
19
19
  }
20
20
 
21
21
  /**
@@ -29,7 +29,7 @@ export class Strategy implements IStrategy {
29
29
  return new Priority(
30
30
  // This takes the highest priority (lowest value) from all the applicable `PriorityRule`s
31
31
  Math.min(
32
- ...this.#ruleRegistry
32
+ ...this._ruleRegistry
33
33
  .process(PriorityRule, action, this)
34
34
  .map((priority) => priority.value()),
35
35
  Infinity
@@ -38,7 +38,7 @@ export class Strategy implements IStrategy {
38
38
  }
39
39
 
40
40
  protected ruleRegistry(): RuleRegistry {
41
- return this.#ruleRegistry;
41
+ return this._ruleRegistry;
42
42
  }
43
43
  }
44
44
 
package/StrategyNote.d.ts CHANGED
@@ -4,7 +4,8 @@ export interface IStrategyNote<Value = any> {
4
4
  value(): Value;
5
5
  }
6
6
  export declare class StrategyNote<Value = any> implements IStrategyNote<Value> {
7
- #private;
7
+ private _key;
8
+ private _value;
8
9
  constructor(key: string, value: Value);
9
10
  key(): string;
10
11
  value(): Value;
package/StrategyNote.js CHANGED
@@ -1,35 +1,20 @@
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 _StrategyNote_key, _StrategyNote_value;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.generateKey = exports.StrategyNote = void 0;
16
4
  const DataObject_1 = require("@civ-clone/core-data-object/DataObject");
17
5
  class StrategyNote {
18
6
  constructor(key, value) {
19
- _StrategyNote_key.set(this, void 0);
20
- _StrategyNote_value.set(this, void 0);
21
- __classPrivateFieldSet(this, _StrategyNote_key, key, "f");
22
- __classPrivateFieldSet(this, _StrategyNote_value, value, "f");
7
+ this._key = key;
8
+ this._value = value;
23
9
  }
24
10
  key() {
25
- return __classPrivateFieldGet(this, _StrategyNote_key, "f");
11
+ return this._key;
26
12
  }
27
13
  value() {
28
- return __classPrivateFieldGet(this, _StrategyNote_value, "f");
14
+ return this._value;
29
15
  }
30
16
  }
31
17
  exports.StrategyNote = StrategyNote;
32
- _StrategyNote_key = new WeakMap(), _StrategyNote_value = new WeakMap();
33
18
  const generateKey = (...items) => items
34
19
  .map((item) => item instanceof DataObject_1.DataObject
35
20
  ? item.id()
@@ -1 +1 @@
1
- {"version":3,"file":"StrategyNote.js","sourceRoot":"","sources":["StrategyNote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAGgD;AAOhD,MAAa,YAAY;IAIvB,YAAY,GAAW,EAAE,KAAY;QAHrC,oCAAa;QACb,sCAAc;QAGZ,uBAAA,IAAI,qBAAQ,GAAG,MAAA,CAAC;QAChB,uBAAA,IAAI,uBAAU,KAAK,MAAA,CAAC;IACtB,CAAC;IAEM,GAAG;QACR,OAAO,uBAAA,IAAI,yBAAK,CAAC;IACnB,CAAC;IAEM,KAAK;QACV,OAAO,uBAAA,IAAI,2BAAO,CAAC;IACrB,CAAC;CACF;AAhBD,oCAgBC;;AAEM,MAAM,WAAW,GAEV,CAAC,GAAG,KAA2C,EAAE,EAAE,CAC/D,KAAK;KACF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,YAAY,uBAAU;IACxB,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE;IACX,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ;QAC1B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CACpB;KACA,IAAI,CAAC,GAAG,CAAC,CAAC;AAXF,QAAA,WAAW,eAWT;AAEf,kBAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"StrategyNote.js","sourceRoot":"","sources":["StrategyNote.ts"],"names":[],"mappings":";;;AAAA,uEAGgD;AAOhD,MAAa,YAAY;IAIvB,YAAY,GAAW,EAAE,KAAY;QACnC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,GAAG;QACR,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAhBD,oCAgBC;AAEM,MAAM,WAAW,GAEV,CAAC,GAAG,KAA2C,EAAE,EAAE,CAC/D,KAAK;KACF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,YAAY,uBAAU;IACxB,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE;IACX,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ;QAC1B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CACpB;KACA,IAAI,CAAC,GAAG,CAAC,CAAC;AAXF,QAAA,WAAW,eAWT;AAEf,kBAAe,YAAY,CAAC"}
package/StrategyNote.ts CHANGED
@@ -9,20 +9,20 @@ export interface IStrategyNote<Value = any> {
9
9
  }
10
10
 
11
11
  export class StrategyNote<Value = any> implements IStrategyNote<Value> {
12
- #key: string;
13
- #value: Value;
12
+ private _key: string;
13
+ private _value: Value;
14
14
 
15
15
  constructor(key: string, value: Value) {
16
- this.#key = key;
17
- this.#value = value;
16
+ this._key = key;
17
+ this._value = value;
18
18
  }
19
19
 
20
20
  public key(): string {
21
- return this.#key;
21
+ return this._key;
22
22
  }
23
23
 
24
24
  public value(): Value {
25
- return this.#value;
25
+ return this._value;
26
26
  }
27
27
  }
28
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civ-clone/core-strategy",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "repository": "git@github.com:civ-clone/core-strategy.git",
5
5
  "keywords": [
6
6
  "typescript",