@gamepark/rules-api 6.29.1 → 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.
- package/dist/material/location/strategy/StackingStrategy.d.ts +12 -0
- package/dist/material/location/strategy/StackingStrategy.js +32 -0
- package/dist/material/location/strategy/StackingStrategy.js.map +1 -0
- package/dist/material/location/strategy/index.d.ts +2 -1
- package/dist/material/location/strategy/index.js +4 -1
- package/dist/material/location/strategy/index.js.map +1 -1
- package/dist/material/rules/SimultaneousRule.d.ts +6 -1
- package/dist/material/rules/SimultaneousRule.js.map +1 -1
- package/package.json +1 -1
|
@@ -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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AC,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"}
|
|
@@ -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("./
|
|
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":"
|
|
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"}
|
|
@@ -14,7 +14,12 @@ export declare abstract class SimultaneousRule<Player extends number = number, M
|
|
|
14
14
|
* See {@link Rules.getLegalMoves}
|
|
15
15
|
*/
|
|
16
16
|
getLegalMoves(player: Player): MaterialMove<Player, MaterialType, LocationType>[];
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* This function is only called for players which are still active. It must return the legal move of given player.
|
|
19
|
+
* @param player Player to consider
|
|
20
|
+
* @return the legal moves of the player
|
|
21
|
+
*/
|
|
22
|
+
abstract getActivePlayerLegalMoves(player: Player): MaterialMove<Player, MaterialType, LocationType>[];
|
|
18
23
|
/**
|
|
19
24
|
* This function is called immediately after a {@link EndPlayerTurn} has been played.
|
|
20
25
|
* @param _move The move which has just been played
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimultaneousRule.js","sourceRoot":"","sources":["../../../src/material/rules/SimultaneousRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,kCAA2E;AAC3E,yDAAuD;AAEvD;;GAEG;AACH;IACU,oCAAqD;IAD/D;;QAGE,mBAAa,GAAG,2BAAmB,CAAC,aAAa,CAAA;;
|
|
1
|
+
{"version":3,"file":"SimultaneousRule.js","sourceRoot":"","sources":["../../../src/material/rules/SimultaneousRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,kCAA2E;AAC3E,yDAAuD;AAEvD;;GAEG;AACH;IACU,oCAAqD;IAD/D;;QAGE,mBAAa,GAAG,2BAAmB,CAAC,aAAa,CAAA;;IAuCnD,CAAC;IArCC;;OAEG;IACH,uCAAY,GAAZ,UAAa,MAAc;;QACzB,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,0CAAE,OAAO,0CAAE,QAAQ,CAAC,MAAM,CAAC,mCAAI,KAAK,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,wCAAa,GAAb,UAAc,MAAc;QAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAChF,CAAC;IASD;;;;;OAKG;IACH,0CAAe,GAAf,UAAgB,KAA4B,EAAE,QAA0B;QACtE,OAAO,EAAE,CAAA;IACX,CAAC;IAQH,uBAAC;AAAD,CAAC,AA1CD,CACU,qCAAiB,GAyC1B;AA1CqB,4CAAgB;AA4CtC;;;;GAIG;AACH,SAAgB,kBAAkB,CAChC,IAAiC;IAEjC,OAAO,IAAI,KAAK,SAAS,IAAI,OAAQ,IAAkC,CAAC,wBAAwB,KAAK,UAAU,CAAA;AACjH,CAAC;AAJD,gDAIC"}
|