@gamepark/rules-api 6.29.2 → 6.29.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.
@@ -0,0 +1,12 @@
1
+ import { Material, MaterialItem } from '../../items';
2
+ import { LocationStrategy } from './LocationStrategy';
3
+ /**
4
+ * This strategy will only work on items with the same location.x and location.y, to maintain a positive sequence on location.z,
5
+ * for example to easily stack scoring pawns when they are on the same spot.
6
+ */
7
+ export declare class StackingStrategy implements LocationStrategy {
8
+ private delegate;
9
+ addItem(material: Material, item: MaterialItem): void;
10
+ moveItem(material: Material, item: MaterialItem, index: number): void;
11
+ removeItem(material: Material, item: MaterialItem): void;
12
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StackingStrategy = void 0;
4
+ var PositiveSequenceStrategy_1 = require("./PositiveSequenceStrategy");
5
+ /**
6
+ * This strategy will only work on items with the same location.x and location.y, to maintain a positive sequence on location.z,
7
+ * for example to easily stack scoring pawns when they are on the same spot.
8
+ */
9
+ var StackingStrategy = /** @class */ (function () {
10
+ function StackingStrategy() {
11
+ this.delegate = new PositiveSequenceStrategy_1.PositiveSequenceStrategy('z');
12
+ }
13
+ StackingStrategy.prototype.addItem = function (material, item) {
14
+ this.delegate.addItem(material.location(function (l) { return l.x === item.location.x && l.y === item.location.y; }), item);
15
+ };
16
+ StackingStrategy.prototype.moveItem = function (material, item, index) {
17
+ var itemBefore = material.getItem(index);
18
+ if (itemBefore.location.x === item.location.x && itemBefore.location.y === itemBefore.location.y) {
19
+ this.delegate.moveItem(material, item, index);
20
+ }
21
+ else {
22
+ this.delegate.removeItem(material.index(function (i) { return i !== index; }).location(function (l) { return l.x === itemBefore.location.x && l.y === itemBefore.location.y; }), itemBefore);
23
+ this.delegate.addItem(material.location(function (l) { return l.x === item.location.x && l.y === item.location.y; }), item);
24
+ }
25
+ };
26
+ StackingStrategy.prototype.removeItem = function (material, item) {
27
+ this.delegate.removeItem(material.location(function (l) { return l.x === item.location.x && l.y === item.location.y; }), item);
28
+ };
29
+ return StackingStrategy;
30
+ }());
31
+ exports.StackingStrategy = StackingStrategy;
32
+ //# sourceMappingURL=StackingStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StackingStrategy.js","sourceRoot":"","sources":["../../../../src/material/location/strategy/StackingStrategy.ts"],"names":[],"mappings":";;;AAEA,uEAAqE;AAErE;;;GAGG;AACH;IAAA;QACU,aAAQ,GAAG,IAAI,mDAAwB,CAAC,GAAG,CAAC,CAAA;IAmBtD,CAAC;IAjBC,kCAAO,GAAP,UAAQ,QAAkB,EAAE,IAAkB;QAC5C,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAlD,CAAkD,CAAC,EAAE,IAAI,CAAC,CAAA;IACzG,CAAC;IAED,mCAAQ,GAAR,UAAS,QAAkB,EAAE,IAAkB,EAAE,KAAa;QAC5D,IAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1C,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YACjG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;QAC/C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,KAAK,EAAX,CAAW,CAAC,CAAC,QAAQ,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,EAA9D,CAA8D,CAAC,EAAE,UAAU,CAAC,CAAA;YACpJ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAlD,CAAkD,CAAC,EAAE,IAAI,CAAC,CAAA;QACzG,CAAC;IACH,CAAC;IAED,qCAAU,GAAV,UAAW,QAAkB,EAAE,IAAkB;QAC/C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAlD,CAAkD,CAAC,EAAE,IAAI,CAAC,CAAA;IAC5G,CAAC;IACH,uBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,4CAAgB"}
@@ -1,4 +1,5 @@
1
1
  export * from './FillGapStrategy';
2
2
  export * from './LocationStrategy';
3
3
  export * from './PositiveSequenceStrategy';
4
- export * from './StakingStrategy';
4
+ export * from './StackingStrategy';
5
+ export { StackingStrategy as StakingStrategy } from './StackingStrategy';
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.StakingStrategy = void 0;
17
18
  __exportStar(require("./FillGapStrategy"), exports);
18
19
  __exportStar(require("./LocationStrategy"), exports);
19
20
  __exportStar(require("./PositiveSequenceStrategy"), exports);
20
- __exportStar(require("./StakingStrategy"), exports);
21
+ __exportStar(require("./StackingStrategy"), exports);
22
+ var StackingStrategy_1 = require("./StackingStrategy"); // TODO: remove once every game using the badly spelled name are fixed
23
+ Object.defineProperty(exports, "StakingStrategy", { enumerable: true, get: function () { return StackingStrategy_1.StackingStrategy; } });
21
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/material/location/strategy/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,qDAAkC;AAClC,6DAA0C;AAC1C,oDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/material/location/strategy/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,qDAAkC;AAClC,6DAA0C;AAC1C,qDAAkC;AAClC,uDAAwE,CAAC,sEAAsE;AAAtI,mHAAA,gBAAgB,OAAmB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamepark/rules-api",
3
- "version": "6.29.2",
3
+ "version": "6.29.3",
4
4
  "description": "API to implement the rules of a board game",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",