@gamepark/odin 0.0.1
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/OdinOptions.d.ts +5 -0
- package/dist/OdinOptions.js +4 -0
- package/dist/OdinRules.d.ts +33 -0
- package/dist/OdinRules.js +71 -0
- package/dist/OdinSetup.d.ts +11 -0
- package/dist/OdinSetup.js +43 -0
- package/dist/PlayerId.d.ts +1 -0
- package/dist/PlayerId.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -0
- package/dist/material/Card.d.ts +66 -0
- package/dist/material/Card.js +73 -0
- package/dist/material/LocationType.d.ts +10 -0
- package/dist/material/LocationType.js +15 -0
- package/dist/material/MaterialType.d.ts +3 -0
- package/dist/material/MaterialType.js +7 -0
- package/dist/rules/BasePlayerTurn.d.ts +5 -0
- package/dist/rules/BasePlayerTurn.js +52 -0
- package/dist/rules/CustomMoveType.d.ts +5 -0
- package/dist/rules/CustomMoveType.js +9 -0
- package/dist/rules/DealCardsRule.d.ts +8 -0
- package/dist/rules/DealCardsRule.js +124 -0
- package/dist/rules/EndOfRoundRule.d.ts +10 -0
- package/dist/rules/EndOfRoundRule.js +107 -0
- package/dist/rules/Memory.d.ts +6 -0
- package/dist/rules/Memory.js +10 -0
- package/dist/rules/PickCardRule.d.ts +10 -0
- package/dist/rules/PickCardRule.js +78 -0
- package/dist/rules/PlayCardsRule.d.ts +19 -0
- package/dist/rules/PlayCardsRule.js +289 -0
- package/dist/rules/RuleId.d.ts +6 -0
- package/dist/rules/RuleId.js +10 -0
- package/dist/rules/Sort.d.ts +5 -0
- package/dist/rules/Sort.js +9 -0
- package/package.json +33 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
import { CustomMove, MaterialGame, MaterialMove, PlayMoveContext, PositiveSequenceStrategy, SecretMaterialRules, TimeLimit } from '@gamepark/rules-api';
|
2
|
+
import { LocationType } from './material/LocationType';
|
3
|
+
import { MaterialType } from './material/MaterialType';
|
4
|
+
import { PlayerId } from './PlayerId';
|
5
|
+
import { DealCardsRule } from './rules/DealCardsRule';
|
6
|
+
import { EndOfRoundRule } from './rules/EndOfRoundRule';
|
7
|
+
import { PickCardRule } from './rules/PickCardRule';
|
8
|
+
import { PlayCardsRule } from './rules/PlayCardsRule';
|
9
|
+
export declare class OdinRules extends SecretMaterialRules<PlayerId, MaterialType, LocationType> implements TimeLimit<MaterialGame<PlayerId, MaterialType, LocationType>, MaterialMove<PlayerId, MaterialType, LocationType>> {
|
10
|
+
rules: {
|
11
|
+
1: typeof PlayCardsRule;
|
12
|
+
4: typeof DealCardsRule;
|
13
|
+
2: typeof PickCardRule;
|
14
|
+
3: typeof EndOfRoundRule;
|
15
|
+
};
|
16
|
+
hidingStrategies: {
|
17
|
+
1: {
|
18
|
+
1: import("@gamepark/rules-api").HidingStrategy<number, number>;
|
19
|
+
2: <P extends number = number, L extends number = number>(item: import("@gamepark/rules-api").MaterialItem<P, L, any>, player?: P | undefined) => string[];
|
20
|
+
};
|
21
|
+
};
|
22
|
+
locationsStrategies: {
|
23
|
+
1: {
|
24
|
+
2: PositiveSequenceStrategy<number, number, number>;
|
25
|
+
1: PositiveSequenceStrategy<number, number, number>;
|
26
|
+
3: PositiveSequenceStrategy<number, number, number>;
|
27
|
+
4: PositiveSequenceStrategy<number, number, number>;
|
28
|
+
};
|
29
|
+
};
|
30
|
+
restoreTransientState(previousState: MaterialGame): void;
|
31
|
+
giveTime(): number;
|
32
|
+
onCustomMove(move: CustomMove, context: PlayMoveContext): MaterialMove<number, MaterialType, LocationType, number>[];
|
33
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
+
exports.OdinRules = void 0;
|
19
|
+
var rules_api_1 = require("@gamepark/rules-api");
|
20
|
+
var LocationType_1 = require("./material/LocationType");
|
21
|
+
var MaterialType_1 = require("./material/MaterialType");
|
22
|
+
var CustomMoveType_1 = require("./rules/CustomMoveType");
|
23
|
+
var DealCardsRule_1 = require("./rules/DealCardsRule");
|
24
|
+
var EndOfRoundRule_1 = require("./rules/EndOfRoundRule");
|
25
|
+
var Memory_1 = require("./rules/Memory");
|
26
|
+
var PickCardRule_1 = require("./rules/PickCardRule");
|
27
|
+
var PlayCardsRule_1 = require("./rules/PlayCardsRule");
|
28
|
+
var RuleId_1 = require("./rules/RuleId");
|
29
|
+
var OdinRules = (function (_super) {
|
30
|
+
__extends(OdinRules, _super);
|
31
|
+
function OdinRules() {
|
32
|
+
var _a, _b, _c, _d, _e;
|
33
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
34
|
+
_this.rules = (_a = {},
|
35
|
+
_a[RuleId_1.RuleId.PlayCards] = PlayCardsRule_1.PlayCardsRule,
|
36
|
+
_a[RuleId_1.RuleId.DealCards] = DealCardsRule_1.DealCardsRule,
|
37
|
+
_a[RuleId_1.RuleId.PickCard] = PickCardRule_1.PickCardRule,
|
38
|
+
_a[RuleId_1.RuleId.EndOfRound] = EndOfRoundRule_1.EndOfRoundRule,
|
39
|
+
_a);
|
40
|
+
_this.hidingStrategies = (_b = {},
|
41
|
+
_b[MaterialType_1.MaterialType.Card] = (_c = {},
|
42
|
+
_c[LocationType_1.LocationType.Deck] = rules_api_1.hideItemId,
|
43
|
+
_c[LocationType_1.LocationType.Hand] = rules_api_1.hideItemIdToOthers,
|
44
|
+
_c),
|
45
|
+
_b);
|
46
|
+
_this.locationsStrategies = (_d = {},
|
47
|
+
_d[MaterialType_1.MaterialType.Card] = (_e = {},
|
48
|
+
_e[LocationType_1.LocationType.Hand] = new rules_api_1.PositiveSequenceStrategy(),
|
49
|
+
_e[LocationType_1.LocationType.Deck] = new rules_api_1.PositiveSequenceStrategy(),
|
50
|
+
_e[LocationType_1.LocationType.MiddleOfTable] = new rules_api_1.PositiveSequenceStrategy(),
|
51
|
+
_e[LocationType_1.LocationType.Discard] = new rules_api_1.PositiveSequenceStrategy(),
|
52
|
+
_e),
|
53
|
+
_d);
|
54
|
+
return _this;
|
55
|
+
}
|
56
|
+
OdinRules.prototype.restoreTransientState = function (previousState) {
|
57
|
+
_super.prototype.restoreTransientState.call(this, previousState);
|
58
|
+
this.memorize(Memory_1.Memory.HandSort, previousState.memory[Memory_1.Memory.HandSort]);
|
59
|
+
};
|
60
|
+
OdinRules.prototype.giveTime = function () {
|
61
|
+
return 60;
|
62
|
+
};
|
63
|
+
OdinRules.prototype.onCustomMove = function (move, context) {
|
64
|
+
if (move.type === CustomMoveType_1.CustomMoveType.SortHand) {
|
65
|
+
this.memorize(Memory_1.Memory.HandSort, move.data);
|
66
|
+
}
|
67
|
+
return _super.prototype.onCustomMove.call(this, move, context);
|
68
|
+
};
|
69
|
+
return OdinRules;
|
70
|
+
}(rules_api_1.SecretMaterialRules));
|
71
|
+
exports.OdinRules = OdinRules;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { MaterialGameSetup } from '@gamepark/rules-api';
|
2
|
+
import { OdinOptions } from './OdinOptions';
|
3
|
+
import { OdinRules } from './OdinRules';
|
4
|
+
import { LocationType } from './material/LocationType';
|
5
|
+
import { MaterialType } from './material/MaterialType';
|
6
|
+
import { PlayerId } from './PlayerId';
|
7
|
+
export declare class OdinSetup extends MaterialGameSetup<PlayerId, MaterialType, LocationType, OdinOptions> {
|
8
|
+
Rules: typeof OdinRules;
|
9
|
+
setupMaterial(_options: OdinOptions): void;
|
10
|
+
start(): void;
|
11
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
+
exports.OdinSetup = void 0;
|
19
|
+
var rules_api_1 = require("@gamepark/rules-api");
|
20
|
+
var OdinRules_1 = require("./OdinRules");
|
21
|
+
var LocationType_1 = require("./material/LocationType");
|
22
|
+
var MaterialType_1 = require("./material/MaterialType");
|
23
|
+
var Memory_1 = require("./rules/Memory");
|
24
|
+
var RuleId_1 = require("./rules/RuleId");
|
25
|
+
var Card_1 = require("./material/Card");
|
26
|
+
var OdinSetup = (function (_super) {
|
27
|
+
__extends(OdinSetup, _super);
|
28
|
+
function OdinSetup() {
|
29
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
30
|
+
_this.Rules = OdinRules_1.OdinRules;
|
31
|
+
return _this;
|
32
|
+
}
|
33
|
+
OdinSetup.prototype.setupMaterial = function (_options) {
|
34
|
+
this.material(MaterialType_1.MaterialType.Card).createItems((0, rules_api_1.getEnumValues)(Card_1.Card).map(function (id) { return ({ id: id, location: { type: LocationType_1.LocationType.Deck } }); }));
|
35
|
+
this.material(MaterialType_1.MaterialType.Card).shuffle();
|
36
|
+
};
|
37
|
+
OdinSetup.prototype.start = function () {
|
38
|
+
this.memorize(Memory_1.Memory.FirstPlayer, this.game.players[0]);
|
39
|
+
this.startRule(RuleId_1.RuleId.DealCards);
|
40
|
+
};
|
41
|
+
return OdinSetup;
|
42
|
+
}(rules_api_1.MaterialGameSetup));
|
43
|
+
exports.OdinSetup = OdinSetup;
|
@@ -0,0 +1 @@
|
|
1
|
+
export type PlayerId = number;
|
package/dist/PlayerId.js
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.OdinSetup = exports.OdinOptionsSpec = exports.OdinRules = void 0;
|
4
|
+
var OdinRules_1 = require("./OdinRules");
|
5
|
+
Object.defineProperty(exports, "OdinRules", { enumerable: true, get: function () { return OdinRules_1.OdinRules; } });
|
6
|
+
var OdinOptions_1 = require("./OdinOptions");
|
7
|
+
Object.defineProperty(exports, "OdinOptionsSpec", { enumerable: true, get: function () { return OdinOptions_1.OdinOptionsSpec; } });
|
8
|
+
var OdinSetup_1 = require("./OdinSetup");
|
9
|
+
Object.defineProperty(exports, "OdinSetup", { enumerable: true, get: function () { return OdinSetup_1.OdinSetup; } });
|
@@ -0,0 +1,66 @@
|
|
1
|
+
export declare enum Card {
|
2
|
+
Blue1 = 11,
|
3
|
+
Blue2 = 12,
|
4
|
+
Blue3 = 13,
|
5
|
+
Blue4 = 14,
|
6
|
+
Blue5 = 15,
|
7
|
+
Blue6 = 16,
|
8
|
+
Blue7 = 17,
|
9
|
+
Blue8 = 18,
|
10
|
+
Blue9 = 19,
|
11
|
+
Red1 = 21,
|
12
|
+
Red2 = 22,
|
13
|
+
Red3 = 23,
|
14
|
+
Red4 = 24,
|
15
|
+
Red5 = 25,
|
16
|
+
Red6 = 26,
|
17
|
+
Red7 = 27,
|
18
|
+
Red8 = 28,
|
19
|
+
Red9 = 29,
|
20
|
+
Green1 = 31,
|
21
|
+
Green2 = 32,
|
22
|
+
Green3 = 33,
|
23
|
+
Green4 = 34,
|
24
|
+
Green5 = 35,
|
25
|
+
Green6 = 36,
|
26
|
+
Green7 = 37,
|
27
|
+
Green8 = 38,
|
28
|
+
Green9 = 39,
|
29
|
+
Orange1 = 41,
|
30
|
+
Orange2 = 42,
|
31
|
+
Orange3 = 43,
|
32
|
+
Orange4 = 44,
|
33
|
+
Orange5 = 45,
|
34
|
+
Orange6 = 46,
|
35
|
+
Orange7 = 47,
|
36
|
+
Orange8 = 48,
|
37
|
+
Orange9 = 49,
|
38
|
+
Pink1 = 51,
|
39
|
+
Pink2 = 52,
|
40
|
+
Pink3 = 53,
|
41
|
+
Pink4 = 54,
|
42
|
+
Pink5 = 55,
|
43
|
+
Pink6 = 56,
|
44
|
+
Pink7 = 57,
|
45
|
+
Pink8 = 58,
|
46
|
+
Pink9 = 59,
|
47
|
+
Brown1 = 61,
|
48
|
+
Brown2 = 62,
|
49
|
+
Brown3 = 63,
|
50
|
+
Brown4 = 64,
|
51
|
+
Brown5 = 65,
|
52
|
+
Brown6 = 66,
|
53
|
+
Brown7 = 67,
|
54
|
+
Brown8 = 68,
|
55
|
+
Brown9 = 69
|
56
|
+
}
|
57
|
+
export declare enum CardColor {
|
58
|
+
Blue = 1,
|
59
|
+
Red = 2,
|
60
|
+
Green = 3,
|
61
|
+
Orange = 4,
|
62
|
+
Pink = 5,
|
63
|
+
Brown = 6
|
64
|
+
}
|
65
|
+
export declare const getCardColor: (card: Card) => CardColor;
|
66
|
+
export declare const getCardValue: (card: Card) => number;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getCardValue = exports.getCardColor = exports.CardColor = exports.Card = void 0;
|
4
|
+
var Card;
|
5
|
+
(function (Card) {
|
6
|
+
Card[Card["Blue1"] = 11] = "Blue1";
|
7
|
+
Card[Card["Blue2"] = 12] = "Blue2";
|
8
|
+
Card[Card["Blue3"] = 13] = "Blue3";
|
9
|
+
Card[Card["Blue4"] = 14] = "Blue4";
|
10
|
+
Card[Card["Blue5"] = 15] = "Blue5";
|
11
|
+
Card[Card["Blue6"] = 16] = "Blue6";
|
12
|
+
Card[Card["Blue7"] = 17] = "Blue7";
|
13
|
+
Card[Card["Blue8"] = 18] = "Blue8";
|
14
|
+
Card[Card["Blue9"] = 19] = "Blue9";
|
15
|
+
Card[Card["Red1"] = 21] = "Red1";
|
16
|
+
Card[Card["Red2"] = 22] = "Red2";
|
17
|
+
Card[Card["Red3"] = 23] = "Red3";
|
18
|
+
Card[Card["Red4"] = 24] = "Red4";
|
19
|
+
Card[Card["Red5"] = 25] = "Red5";
|
20
|
+
Card[Card["Red6"] = 26] = "Red6";
|
21
|
+
Card[Card["Red7"] = 27] = "Red7";
|
22
|
+
Card[Card["Red8"] = 28] = "Red8";
|
23
|
+
Card[Card["Red9"] = 29] = "Red9";
|
24
|
+
Card[Card["Green1"] = 31] = "Green1";
|
25
|
+
Card[Card["Green2"] = 32] = "Green2";
|
26
|
+
Card[Card["Green3"] = 33] = "Green3";
|
27
|
+
Card[Card["Green4"] = 34] = "Green4";
|
28
|
+
Card[Card["Green5"] = 35] = "Green5";
|
29
|
+
Card[Card["Green6"] = 36] = "Green6";
|
30
|
+
Card[Card["Green7"] = 37] = "Green7";
|
31
|
+
Card[Card["Green8"] = 38] = "Green8";
|
32
|
+
Card[Card["Green9"] = 39] = "Green9";
|
33
|
+
Card[Card["Orange1"] = 41] = "Orange1";
|
34
|
+
Card[Card["Orange2"] = 42] = "Orange2";
|
35
|
+
Card[Card["Orange3"] = 43] = "Orange3";
|
36
|
+
Card[Card["Orange4"] = 44] = "Orange4";
|
37
|
+
Card[Card["Orange5"] = 45] = "Orange5";
|
38
|
+
Card[Card["Orange6"] = 46] = "Orange6";
|
39
|
+
Card[Card["Orange7"] = 47] = "Orange7";
|
40
|
+
Card[Card["Orange8"] = 48] = "Orange8";
|
41
|
+
Card[Card["Orange9"] = 49] = "Orange9";
|
42
|
+
Card[Card["Pink1"] = 51] = "Pink1";
|
43
|
+
Card[Card["Pink2"] = 52] = "Pink2";
|
44
|
+
Card[Card["Pink3"] = 53] = "Pink3";
|
45
|
+
Card[Card["Pink4"] = 54] = "Pink4";
|
46
|
+
Card[Card["Pink5"] = 55] = "Pink5";
|
47
|
+
Card[Card["Pink6"] = 56] = "Pink6";
|
48
|
+
Card[Card["Pink7"] = 57] = "Pink7";
|
49
|
+
Card[Card["Pink8"] = 58] = "Pink8";
|
50
|
+
Card[Card["Pink9"] = 59] = "Pink9";
|
51
|
+
Card[Card["Brown1"] = 61] = "Brown1";
|
52
|
+
Card[Card["Brown2"] = 62] = "Brown2";
|
53
|
+
Card[Card["Brown3"] = 63] = "Brown3";
|
54
|
+
Card[Card["Brown4"] = 64] = "Brown4";
|
55
|
+
Card[Card["Brown5"] = 65] = "Brown5";
|
56
|
+
Card[Card["Brown6"] = 66] = "Brown6";
|
57
|
+
Card[Card["Brown7"] = 67] = "Brown7";
|
58
|
+
Card[Card["Brown8"] = 68] = "Brown8";
|
59
|
+
Card[Card["Brown9"] = 69] = "Brown9";
|
60
|
+
})(Card = exports.Card || (exports.Card = {}));
|
61
|
+
var CardColor;
|
62
|
+
(function (CardColor) {
|
63
|
+
CardColor[CardColor["Blue"] = 1] = "Blue";
|
64
|
+
CardColor[CardColor["Red"] = 2] = "Red";
|
65
|
+
CardColor[CardColor["Green"] = 3] = "Green";
|
66
|
+
CardColor[CardColor["Orange"] = 4] = "Orange";
|
67
|
+
CardColor[CardColor["Pink"] = 5] = "Pink";
|
68
|
+
CardColor[CardColor["Brown"] = 6] = "Brown";
|
69
|
+
})(CardColor = exports.CardColor || (exports.CardColor = {}));
|
70
|
+
var getCardColor = function (card) { return Math.floor(card / 10); };
|
71
|
+
exports.getCardColor = getCardColor;
|
72
|
+
var getCardValue = function (card) { return card % 10; };
|
73
|
+
exports.getCardValue = getCardValue;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MiddleOfTable = exports.LocationType = void 0;
|
4
|
+
var LocationType;
|
5
|
+
(function (LocationType) {
|
6
|
+
LocationType[LocationType["Deck"] = 1] = "Deck";
|
7
|
+
LocationType[LocationType["Hand"] = 2] = "Hand";
|
8
|
+
LocationType[LocationType["MiddleOfTable"] = 3] = "MiddleOfTable";
|
9
|
+
LocationType[LocationType["Discard"] = 4] = "Discard";
|
10
|
+
})(LocationType = exports.LocationType || (exports.LocationType = {}));
|
11
|
+
var MiddleOfTable;
|
12
|
+
(function (MiddleOfTable) {
|
13
|
+
MiddleOfTable[MiddleOfTable["Current"] = 1] = "Current";
|
14
|
+
MiddleOfTable[MiddleOfTable["Next"] = 2] = "Next";
|
15
|
+
})(MiddleOfTable = exports.MiddleOfTable || (exports.MiddleOfTable = {}));
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MaterialType = void 0;
|
4
|
+
var MaterialType;
|
5
|
+
(function (MaterialType) {
|
6
|
+
MaterialType[MaterialType["Card"] = 1] = "Card";
|
7
|
+
})(MaterialType = exports.MaterialType || (exports.MaterialType = {}));
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
19
|
+
};
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
21
|
+
exports.BasePlayerTurn = void 0;
|
22
|
+
var rules_api_1 = require("@gamepark/rules-api");
|
23
|
+
var orderBy_1 = __importDefault(require("lodash/orderBy"));
|
24
|
+
var Memory_1 = require("./Memory");
|
25
|
+
var BasePlayerTurn = (function (_super) {
|
26
|
+
__extends(BasePlayerTurn, _super);
|
27
|
+
function BasePlayerTurn() {
|
28
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
29
|
+
}
|
30
|
+
Object.defineProperty(BasePlayerTurn.prototype, "nextPlayer", {
|
31
|
+
get: function () {
|
32
|
+
var _this = this;
|
33
|
+
var playerIndex = this.game.players.indexOf(this.firstPlayer);
|
34
|
+
var players = (0, orderBy_1.default)(this.game.players, function (id) {
|
35
|
+
var index = _this.game.players.indexOf(id);
|
36
|
+
return (index - playerIndex + _this.game.players.length) % _this.game.players.length;
|
37
|
+
});
|
38
|
+
return players[(players.indexOf(this.player) + 1) % players.length];
|
39
|
+
},
|
40
|
+
enumerable: false,
|
41
|
+
configurable: true
|
42
|
+
});
|
43
|
+
Object.defineProperty(BasePlayerTurn.prototype, "firstPlayer", {
|
44
|
+
get: function () {
|
45
|
+
return this.remind(Memory_1.Memory.FirstPlayer);
|
46
|
+
},
|
47
|
+
enumerable: false,
|
48
|
+
configurable: true
|
49
|
+
});
|
50
|
+
return BasePlayerTurn;
|
51
|
+
}(rules_api_1.PlayerTurnRule));
|
52
|
+
exports.BasePlayerTurn = BasePlayerTurn;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.CustomMoveType = void 0;
|
4
|
+
var CustomMoveType;
|
5
|
+
(function (CustomMoveType) {
|
6
|
+
CustomMoveType[CustomMoveType["Pass"] = 1] = "Pass";
|
7
|
+
CustomMoveType[CustomMoveType["TurnTempo"] = 2] = "TurnTempo";
|
8
|
+
CustomMoveType[CustomMoveType["SortHand"] = 3] = "SortHand";
|
9
|
+
})(CustomMoveType = exports.CustomMoveType || (exports.CustomMoveType = {}));
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ItemMove, MaterialMove, MaterialRulesPart } from '@gamepark/rules-api';
|
2
|
+
export declare class DealCardsRule extends MaterialRulesPart {
|
3
|
+
onRuleStart(): MaterialMove<number, number, number, number>[];
|
4
|
+
afterItemMove(move: ItemMove): MaterialMove[];
|
5
|
+
dealToPlayersAndGo(): MaterialMove[];
|
6
|
+
get deck(): import("@gamepark/rules-api").MaterialDeck<number, number, number>;
|
7
|
+
get discard(): import("@gamepark/rules-api").Material<number, number, number>;
|
8
|
+
}
|
@@ -0,0 +1,124 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
var __read = (this && this.__read) || function (o, n) {
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
19
|
+
if (!m) return o;
|
20
|
+
var i = m.call(o), r, ar = [], e;
|
21
|
+
try {
|
22
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
23
|
+
}
|
24
|
+
catch (error) { e = { error: error }; }
|
25
|
+
finally {
|
26
|
+
try {
|
27
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
28
|
+
}
|
29
|
+
finally { if (e) throw e.error; }
|
30
|
+
}
|
31
|
+
return ar;
|
32
|
+
};
|
33
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
34
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
35
|
+
if (ar || !(i in from)) {
|
36
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
37
|
+
ar[i] = from[i];
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
41
|
+
};
|
42
|
+
var __values = (this && this.__values) || function(o) {
|
43
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
44
|
+
if (m) return m.call(o);
|
45
|
+
if (o && typeof o.length === "number") return {
|
46
|
+
next: function () {
|
47
|
+
if (o && i >= o.length) o = void 0;
|
48
|
+
return { value: o && o[i++], done: !o };
|
49
|
+
}
|
50
|
+
};
|
51
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
52
|
+
};
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
54
|
+
exports.DealCardsRule = void 0;
|
55
|
+
var rules_api_1 = require("@gamepark/rules-api");
|
56
|
+
var LocationType_1 = require("../material/LocationType");
|
57
|
+
var MaterialType_1 = require("../material/MaterialType");
|
58
|
+
var Memory_1 = require("./Memory");
|
59
|
+
var RuleId_1 = require("./RuleId");
|
60
|
+
var DealCardsRule = (function (_super) {
|
61
|
+
__extends(DealCardsRule, _super);
|
62
|
+
function DealCardsRule() {
|
63
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
64
|
+
}
|
65
|
+
DealCardsRule.prototype.onRuleStart = function () {
|
66
|
+
var discard = this.discard;
|
67
|
+
var moves = [];
|
68
|
+
if (!discard.length) {
|
69
|
+
moves.push.apply(moves, __spreadArray([], __read(this.dealToPlayersAndGo()), false));
|
70
|
+
return moves;
|
71
|
+
}
|
72
|
+
moves.push(discard.moveItemsAtOnce({
|
73
|
+
type: LocationType_1.LocationType.Deck
|
74
|
+
}));
|
75
|
+
moves.push(this.material(MaterialType_1.MaterialType.Card).shuffle());
|
76
|
+
return moves;
|
77
|
+
};
|
78
|
+
DealCardsRule.prototype.afterItemMove = function (move) {
|
79
|
+
if (!(0, rules_api_1.isShuffleItemType)(MaterialType_1.MaterialType.Card)(move))
|
80
|
+
return [];
|
81
|
+
return this.dealToPlayersAndGo();
|
82
|
+
};
|
83
|
+
DealCardsRule.prototype.dealToPlayersAndGo = function () {
|
84
|
+
var e_1, _a;
|
85
|
+
var moves = [];
|
86
|
+
var deck = this.deck;
|
87
|
+
for (var i = 0; i < 9; i++) {
|
88
|
+
try {
|
89
|
+
for (var _b = (e_1 = void 0, __values(this.game.players)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
90
|
+
var player = _c.value;
|
91
|
+
moves.push.apply(moves, __spreadArray([], __read(deck.deal({
|
92
|
+
type: LocationType_1.LocationType.Hand,
|
93
|
+
player: player
|
94
|
+
})), false));
|
95
|
+
}
|
96
|
+
}
|
97
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
98
|
+
finally {
|
99
|
+
try {
|
100
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
101
|
+
}
|
102
|
+
finally { if (e_1) throw e_1.error; }
|
103
|
+
}
|
104
|
+
}
|
105
|
+
moves.push(this.startPlayerTurn(RuleId_1.RuleId.PlayCards, this.remind(Memory_1.Memory.FirstPlayer)));
|
106
|
+
return moves;
|
107
|
+
};
|
108
|
+
Object.defineProperty(DealCardsRule.prototype, "deck", {
|
109
|
+
get: function () {
|
110
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Deck).deck();
|
111
|
+
},
|
112
|
+
enumerable: false,
|
113
|
+
configurable: true
|
114
|
+
});
|
115
|
+
Object.defineProperty(DealCardsRule.prototype, "discard", {
|
116
|
+
get: function () {
|
117
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Discard);
|
118
|
+
},
|
119
|
+
enumerable: false,
|
120
|
+
configurable: true
|
121
|
+
});
|
122
|
+
return DealCardsRule;
|
123
|
+
}(rules_api_1.MaterialRulesPart));
|
124
|
+
exports.DealCardsRule = DealCardsRule;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ItemMove, MaterialMove, MaterialRulesPart } from '@gamepark/rules-api';
|
2
|
+
import { PlayerId } from '../PlayerId';
|
3
|
+
export declare class EndOfRoundRule extends MaterialRulesPart {
|
4
|
+
onRuleStart(): MaterialMove<number, number, number, number>[];
|
5
|
+
get deck(): import("@gamepark/rules-api").MaterialDeck<number, number, number>;
|
6
|
+
get groupToDeckMove(): MaterialMove<number, number, number, number>[];
|
7
|
+
afterItemMove(move: ItemMove): MaterialMove<number, number, number, number>[];
|
8
|
+
get newFirstPlayer(): PlayerId;
|
9
|
+
get firstPlayer(): number;
|
10
|
+
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
var __read = (this && this.__read) || function (o, n) {
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
19
|
+
if (!m) return o;
|
20
|
+
var i = m.call(o), r, ar = [], e;
|
21
|
+
try {
|
22
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
23
|
+
}
|
24
|
+
catch (error) { e = { error: error }; }
|
25
|
+
finally {
|
26
|
+
try {
|
27
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
28
|
+
}
|
29
|
+
finally { if (e) throw e.error; }
|
30
|
+
}
|
31
|
+
return ar;
|
32
|
+
};
|
33
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
34
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
35
|
+
if (ar || !(i in from)) {
|
36
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
37
|
+
ar[i] = from[i];
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
41
|
+
};
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
43
|
+
exports.EndOfRoundRule = void 0;
|
44
|
+
var rules_api_1 = require("@gamepark/rules-api");
|
45
|
+
var LocationType_1 = require("../material/LocationType");
|
46
|
+
var MaterialType_1 = require("../material/MaterialType");
|
47
|
+
var Memory_1 = require("./Memory");
|
48
|
+
var RuleId_1 = require("./RuleId");
|
49
|
+
var EndOfRoundRule = (function (_super) {
|
50
|
+
__extends(EndOfRoundRule, _super);
|
51
|
+
function EndOfRoundRule() {
|
52
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
53
|
+
}
|
54
|
+
EndOfRoundRule.prototype.onRuleStart = function () {
|
55
|
+
var moves = [];
|
56
|
+
moves.push.apply(moves, __spreadArray([], __read(this.groupToDeckMove), false));
|
57
|
+
return moves;
|
58
|
+
};
|
59
|
+
Object.defineProperty(EndOfRoundRule.prototype, "deck", {
|
60
|
+
get: function () {
|
61
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Deck).deck();
|
62
|
+
},
|
63
|
+
enumerable: false,
|
64
|
+
configurable: true
|
65
|
+
});
|
66
|
+
Object.defineProperty(EndOfRoundRule.prototype, "groupToDeckMove", {
|
67
|
+
get: function () {
|
68
|
+
var moves = [];
|
69
|
+
moves.push(this.material(MaterialType_1.MaterialType.Card)
|
70
|
+
.location(function (l) { return l.type !== LocationType_1.LocationType.Deck; })
|
71
|
+
.moveItemsAtOnce({
|
72
|
+
type: LocationType_1.LocationType.Deck
|
73
|
+
}));
|
74
|
+
return moves;
|
75
|
+
},
|
76
|
+
enumerable: false,
|
77
|
+
configurable: true
|
78
|
+
});
|
79
|
+
EndOfRoundRule.prototype.afterItemMove = function (move) {
|
80
|
+
var moves = [];
|
81
|
+
if ((0, rules_api_1.isMoveItemTypeAtOnce)(MaterialType_1.MaterialType.Card)(move) && move.location.type === LocationType_1.LocationType.Deck) {
|
82
|
+
moves.push(this.deck.shuffle());
|
83
|
+
}
|
84
|
+
if ((0, rules_api_1.isShuffleItemType)(MaterialType_1.MaterialType.Card)(move)) {
|
85
|
+
var newFirstPlayer = this.newFirstPlayer;
|
86
|
+
this.memorize(Memory_1.Memory.FirstPlayer, newFirstPlayer);
|
87
|
+
moves.push(this.startRule(RuleId_1.RuleId.DealCards));
|
88
|
+
}
|
89
|
+
return moves;
|
90
|
+
};
|
91
|
+
Object.defineProperty(EndOfRoundRule.prototype, "newFirstPlayer", {
|
92
|
+
get: function () {
|
93
|
+
return this.game.players[(this.game.players.indexOf(this.firstPlayer) + 1) % this.game.players.length];
|
94
|
+
},
|
95
|
+
enumerable: false,
|
96
|
+
configurable: true
|
97
|
+
});
|
98
|
+
Object.defineProperty(EndOfRoundRule.prototype, "firstPlayer", {
|
99
|
+
get: function () {
|
100
|
+
return this.remind(Memory_1.Memory.FirstPlayer);
|
101
|
+
},
|
102
|
+
enumerable: false,
|
103
|
+
configurable: true
|
104
|
+
});
|
105
|
+
return EndOfRoundRule;
|
106
|
+
}(rules_api_1.MaterialRulesPart));
|
107
|
+
exports.EndOfRoundRule = EndOfRoundRule;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Memory = void 0;
|
4
|
+
var Memory;
|
5
|
+
(function (Memory) {
|
6
|
+
Memory[Memory["PlayedCards"] = 1] = "PlayedCards";
|
7
|
+
Memory[Memory["FirstPlayer"] = 2] = "FirstPlayer";
|
8
|
+
Memory[Memory["LastPlayerThatPlay"] = 3] = "LastPlayerThatPlay";
|
9
|
+
Memory[Memory["HandSort"] = 4] = "HandSort";
|
10
|
+
})(Memory = exports.Memory || (exports.Memory = {}));
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { MaterialMove, MoveItem } from '@gamepark/rules-api';
|
2
|
+
import { BasePlayerTurn } from './BasePlayerTurn';
|
3
|
+
export declare class PickCardRule extends BasePlayerTurn {
|
4
|
+
onRuleStart(): MaterialMove<number, number, number, number>[];
|
5
|
+
getPlayerMoves(): MaterialMove[];
|
6
|
+
afterItemMove(move: MoveItem): MaterialMove<number, number, number, number>[];
|
7
|
+
goToNextRule(): MaterialMove<number, number, number, number>[];
|
8
|
+
get currentTable(): import("@gamepark/rules-api").Material<number, number, number>;
|
9
|
+
get nextTable(): import("@gamepark/rules-api").Material<number, number, number>;
|
10
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
+
exports.PickCardRule = void 0;
|
19
|
+
var rules_api_1 = require("@gamepark/rules-api");
|
20
|
+
var LocationType_1 = require("../material/LocationType");
|
21
|
+
var MaterialType_1 = require("../material/MaterialType");
|
22
|
+
var BasePlayerTurn_1 = require("./BasePlayerTurn");
|
23
|
+
var RuleId_1 = require("./RuleId");
|
24
|
+
var PickCardRule = (function (_super) {
|
25
|
+
__extends(PickCardRule, _super);
|
26
|
+
function PickCardRule() {
|
27
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
28
|
+
}
|
29
|
+
PickCardRule.prototype.onRuleStart = function () {
|
30
|
+
if (this.getPlayerMoves().length)
|
31
|
+
return [];
|
32
|
+
return this.goToNextRule();
|
33
|
+
};
|
34
|
+
PickCardRule.prototype.getPlayerMoves = function () {
|
35
|
+
return this.currentTable.moveItems({
|
36
|
+
type: LocationType_1.LocationType.Hand,
|
37
|
+
player: this.player
|
38
|
+
});
|
39
|
+
};
|
40
|
+
PickCardRule.prototype.afterItemMove = function (move) {
|
41
|
+
if (!(0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.Card)(move) || move.location.type !== LocationType_1.LocationType.Hand)
|
42
|
+
return [];
|
43
|
+
return this.goToNextRule();
|
44
|
+
};
|
45
|
+
PickCardRule.prototype.goToNextRule = function () {
|
46
|
+
var moves = [];
|
47
|
+
var currentTable = this.currentTable;
|
48
|
+
if (currentTable.length) {
|
49
|
+
moves.push(this.currentTable.moveItemsAtOnce({
|
50
|
+
type: LocationType_1.LocationType.Discard
|
51
|
+
}));
|
52
|
+
}
|
53
|
+
var nextTable = this.nextTable;
|
54
|
+
if (nextTable.length) {
|
55
|
+
moves.push(this.nextTable.moveItemsAtOnce({
|
56
|
+
id: LocationType_1.MiddleOfTable.Current
|
57
|
+
}));
|
58
|
+
}
|
59
|
+
moves.push(this.startPlayerTurn(RuleId_1.RuleId.PlayCards, this.nextPlayer));
|
60
|
+
return moves;
|
61
|
+
};
|
62
|
+
Object.defineProperty(PickCardRule.prototype, "currentTable", {
|
63
|
+
get: function () {
|
64
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.MiddleOfTable).locationId(LocationType_1.MiddleOfTable.Current);
|
65
|
+
},
|
66
|
+
enumerable: false,
|
67
|
+
configurable: true
|
68
|
+
});
|
69
|
+
Object.defineProperty(PickCardRule.prototype, "nextTable", {
|
70
|
+
get: function () {
|
71
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.MiddleOfTable).locationId(LocationType_1.MiddleOfTable.Next);
|
72
|
+
},
|
73
|
+
enumerable: false,
|
74
|
+
configurable: true
|
75
|
+
});
|
76
|
+
return PickCardRule;
|
77
|
+
}(BasePlayerTurn_1.BasePlayerTurn));
|
78
|
+
exports.PickCardRule = PickCardRule;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { CustomMove, ItemMove, MaterialItem, MaterialMove } from '@gamepark/rules-api';
|
2
|
+
import { Card } from '../material/Card';
|
3
|
+
import { BasePlayerTurn } from './BasePlayerTurn';
|
4
|
+
export declare class PlayCardsRule extends BasePlayerTurn {
|
5
|
+
getPlayerMoves(): MaterialMove<number, number, number, number>[];
|
6
|
+
get sort(): ((item: MaterialItem) => number)[];
|
7
|
+
get tableValue(): number;
|
8
|
+
onCustomMove(move: CustomMove): MaterialMove<number, number, number, number>[];
|
9
|
+
afterItemMove(move: ItemMove): MaterialMove<number, number, number, number>[];
|
10
|
+
goToNextPlayer(): MaterialMove<number, number, number, number>[];
|
11
|
+
afterPlaceCards(): MaterialMove<number, number, number, number>[];
|
12
|
+
get firstPlayer(): number;
|
13
|
+
get table(): import("@gamepark/rules-api").Material<number, number, number>;
|
14
|
+
get playableCards(): import("@gamepark/rules-api").Material<number, number, number>;
|
15
|
+
get hand(): import("@gamepark/rules-api").Material<number, number, number>;
|
16
|
+
kCombinations<T>(arr: T[], k: number): T[][];
|
17
|
+
concatCardValue(cards: Card[]): number;
|
18
|
+
getPlayableCombinations(hand: Card[], tableCount: number, tableValue: number): Card[][];
|
19
|
+
}
|
@@ -0,0 +1,289 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
var __read = (this && this.__read) || function (o, n) {
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
19
|
+
if (!m) return o;
|
20
|
+
var i = m.call(o), r, ar = [], e;
|
21
|
+
try {
|
22
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
23
|
+
}
|
24
|
+
catch (error) { e = { error: error }; }
|
25
|
+
finally {
|
26
|
+
try {
|
27
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
28
|
+
}
|
29
|
+
finally { if (e) throw e.error; }
|
30
|
+
}
|
31
|
+
return ar;
|
32
|
+
};
|
33
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
34
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
35
|
+
if (ar || !(i in from)) {
|
36
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
37
|
+
ar[i] = from[i];
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
41
|
+
};
|
42
|
+
var __values = (this && this.__values) || function(o) {
|
43
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
44
|
+
if (m) return m.call(o);
|
45
|
+
if (o && typeof o.length === "number") return {
|
46
|
+
next: function () {
|
47
|
+
if (o && i >= o.length) o = void 0;
|
48
|
+
return { value: o && o[i++], done: !o };
|
49
|
+
}
|
50
|
+
};
|
51
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
52
|
+
};
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
55
|
+
};
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
57
|
+
exports.PlayCardsRule = void 0;
|
58
|
+
var rules_api_1 = require("@gamepark/rules-api");
|
59
|
+
var groupBy_1 = __importDefault(require("lodash/groupBy"));
|
60
|
+
var isEqual_1 = __importDefault(require("lodash/isEqual"));
|
61
|
+
var orderBy_1 = __importDefault(require("lodash/orderBy"));
|
62
|
+
var uniqWith_1 = __importDefault(require("lodash/uniqWith"));
|
63
|
+
var Card_1 = require("../material/Card");
|
64
|
+
var LocationType_1 = require("../material/LocationType");
|
65
|
+
var MaterialType_1 = require("../material/MaterialType");
|
66
|
+
var BasePlayerTurn_1 = require("./BasePlayerTurn");
|
67
|
+
var CustomMoveType_1 = require("./CustomMoveType");
|
68
|
+
var Memory_1 = require("./Memory");
|
69
|
+
var RuleId_1 = require("./RuleId");
|
70
|
+
var PlayCardsRule = (function (_super) {
|
71
|
+
__extends(PlayCardsRule, _super);
|
72
|
+
function PlayCardsRule() {
|
73
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
74
|
+
}
|
75
|
+
PlayCardsRule.prototype.getPlayerMoves = function () {
|
76
|
+
var _this = this;
|
77
|
+
var playableCards = this.playableCards;
|
78
|
+
var table = this.table;
|
79
|
+
var tableSize = table.length;
|
80
|
+
var moves = [];
|
81
|
+
var combinations = this.getPlayableCombinations(playableCards.getItems().map(function (item) { return item.id; }), tableSize, this.tableValue);
|
82
|
+
var allHandCombination = this.getPlayableCombinations(playableCards.getItems().map(function (item) { return item.id; }), playableCards.length, this.tableValue);
|
83
|
+
if (allHandCombination.length) {
|
84
|
+
moves.push.apply(moves, __spreadArray([], __read(allHandCombination.map(function (c) {
|
85
|
+
var _a;
|
86
|
+
return (_a = _this.hand
|
87
|
+
.id(function (id) { return c.includes(id); }))
|
88
|
+
.sort.apply(_a, __spreadArray([], __read(_this.sort), false)).moveItemsAtOnce({
|
89
|
+
type: LocationType_1.LocationType.MiddleOfTable,
|
90
|
+
id: LocationType_1.MiddleOfTable.Next
|
91
|
+
});
|
92
|
+
})), false));
|
93
|
+
}
|
94
|
+
moves.push.apply(moves, __spreadArray([], __read(combinations.map(function (c) {
|
95
|
+
var _a;
|
96
|
+
return (_a = _this.hand
|
97
|
+
.id(function (id) { return c.includes(id); }))
|
98
|
+
.sort.apply(_a, __spreadArray([], __read(_this.sort), false)).moveItemsAtOnce({
|
99
|
+
type: LocationType_1.LocationType.MiddleOfTable,
|
100
|
+
id: LocationType_1.MiddleOfTable.Next
|
101
|
+
});
|
102
|
+
})), false));
|
103
|
+
if (table.length) {
|
104
|
+
moves.push(this.customMove(CustomMoveType_1.CustomMoveType.Pass));
|
105
|
+
}
|
106
|
+
return moves;
|
107
|
+
};
|
108
|
+
Object.defineProperty(PlayCardsRule.prototype, "sort", {
|
109
|
+
get: function () {
|
110
|
+
return [function (item) { return -(0, Card_1.getCardValue)(item.id); }, function (item) { return (0, Card_1.getCardColor)(item.id); }];
|
111
|
+
},
|
112
|
+
enumerable: false,
|
113
|
+
configurable: true
|
114
|
+
});
|
115
|
+
Object.defineProperty(PlayCardsRule.prototype, "tableValue", {
|
116
|
+
get: function () {
|
117
|
+
var table = this.table;
|
118
|
+
return !table.length ? 0 : this.concatCardValue(table.getItems().map(function (item) { return item.id; }));
|
119
|
+
},
|
120
|
+
enumerable: false,
|
121
|
+
configurable: true
|
122
|
+
});
|
123
|
+
PlayCardsRule.prototype.onCustomMove = function (move) {
|
124
|
+
if (!(0, rules_api_1.isCustomMoveType)(CustomMoveType_1.CustomMoveType.Pass)(move))
|
125
|
+
return [];
|
126
|
+
var moves = this.afterPlaceCards();
|
127
|
+
moves.push.apply(moves, __spreadArray([], __read(this.goToNextPlayer()), false));
|
128
|
+
return moves;
|
129
|
+
};
|
130
|
+
PlayCardsRule.prototype.afterItemMove = function (move) {
|
131
|
+
if (!(0, rules_api_1.isMoveItemTypeAtOnce)(MaterialType_1.MaterialType.Card)(move) || move.location.type !== LocationType_1.LocationType.MiddleOfTable)
|
132
|
+
return [];
|
133
|
+
var moves = this.afterPlaceCards();
|
134
|
+
this.memorize(Memory_1.Memory.LastPlayerThatPlay, this.player);
|
135
|
+
var isEndOfRound = this.hand.length === 0;
|
136
|
+
moves.push(this.customMove(CustomMoveType_1.CustomMoveType.TurnTempo, isEndOfRound));
|
137
|
+
if (this.hand.length === 0) {
|
138
|
+
moves.push(this.startRule(RuleId_1.RuleId.EndOfRound));
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
moves.push(this.startRule(RuleId_1.RuleId.PickCard));
|
142
|
+
}
|
143
|
+
return moves;
|
144
|
+
};
|
145
|
+
PlayCardsRule.prototype.goToNextPlayer = function () {
|
146
|
+
var next = this.nextPlayer;
|
147
|
+
var moves = [];
|
148
|
+
var lastPlayerThatPlay = this.remind(Memory_1.Memory.LastPlayerThatPlay);
|
149
|
+
if (lastPlayerThatPlay && next === lastPlayerThatPlay) {
|
150
|
+
this.forget(Memory_1.Memory.LastPlayerThatPlay);
|
151
|
+
var table = this.table;
|
152
|
+
if (table.length) {
|
153
|
+
moves.push(this.table.moveItemsAtOnce({
|
154
|
+
type: LocationType_1.LocationType.Discard
|
155
|
+
}));
|
156
|
+
}
|
157
|
+
moves.push(this.startPlayerTurn(RuleId_1.RuleId.PlayCards, next));
|
158
|
+
return moves;
|
159
|
+
}
|
160
|
+
else {
|
161
|
+
moves.push(this.startPlayerTurn(RuleId_1.RuleId.PlayCards, this.nextPlayer));
|
162
|
+
}
|
163
|
+
return moves;
|
164
|
+
};
|
165
|
+
PlayCardsRule.prototype.afterPlaceCards = function () {
|
166
|
+
var e_1, _a;
|
167
|
+
var moves = [];
|
168
|
+
var selected = this.material(MaterialType_1.MaterialType.Card).selected().getItems();
|
169
|
+
try {
|
170
|
+
for (var selected_1 = __values(selected), selected_1_1 = selected_1.next(); !selected_1_1.done; selected_1_1 = selected_1.next()) {
|
171
|
+
var item = selected_1_1.value;
|
172
|
+
delete item.selected;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
176
|
+
finally {
|
177
|
+
try {
|
178
|
+
if (selected_1_1 && !selected_1_1.done && (_a = selected_1.return)) _a.call(selected_1);
|
179
|
+
}
|
180
|
+
finally { if (e_1) throw e_1.error; }
|
181
|
+
}
|
182
|
+
return moves;
|
183
|
+
};
|
184
|
+
Object.defineProperty(PlayCardsRule.prototype, "firstPlayer", {
|
185
|
+
get: function () {
|
186
|
+
return this.remind(Memory_1.Memory.FirstPlayer);
|
187
|
+
},
|
188
|
+
enumerable: false,
|
189
|
+
configurable: true
|
190
|
+
});
|
191
|
+
Object.defineProperty(PlayCardsRule.prototype, "table", {
|
192
|
+
get: function () {
|
193
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.MiddleOfTable).locationId(LocationType_1.MiddleOfTable.Current);
|
194
|
+
},
|
195
|
+
enumerable: false,
|
196
|
+
configurable: true
|
197
|
+
});
|
198
|
+
Object.defineProperty(PlayCardsRule.prototype, "playableCards", {
|
199
|
+
get: function () {
|
200
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Hand).player(this.player);
|
201
|
+
},
|
202
|
+
enumerable: false,
|
203
|
+
configurable: true
|
204
|
+
});
|
205
|
+
Object.defineProperty(PlayCardsRule.prototype, "hand", {
|
206
|
+
get: function () {
|
207
|
+
return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Hand).player(this.player);
|
208
|
+
},
|
209
|
+
enumerable: false,
|
210
|
+
configurable: true
|
211
|
+
});
|
212
|
+
PlayCardsRule.prototype.kCombinations = function (arr, k) {
|
213
|
+
if (k === 0)
|
214
|
+
return [[]];
|
215
|
+
if (arr.length < k)
|
216
|
+
return [];
|
217
|
+
if (arr.length === k)
|
218
|
+
return [arr];
|
219
|
+
var _a = __read(arr), first = _a[0], rest = _a.slice(1);
|
220
|
+
return __spreadArray(__spreadArray([], __read(this.kCombinations(rest, k)), false), __read(this.kCombinations(rest, k - 1).map(function (comb) { return __spreadArray([first], __read(comb), false); })), false);
|
221
|
+
};
|
222
|
+
PlayCardsRule.prototype.concatCardValue = function (cards) {
|
223
|
+
var values = cards.map(function (card) { return (0, Card_1.getCardValue)(card); }).sort(function (a, b) { return (0, Card_1.getCardValue)(b) - (0, Card_1.getCardValue)(a); });
|
224
|
+
return parseInt(values.join(''), 10);
|
225
|
+
};
|
226
|
+
PlayCardsRule.prototype.getPlayableCombinations = function (hand, tableCount, tableValue) {
|
227
|
+
var e_2, _a, e_3, _b, e_4, _c, e_5, _d;
|
228
|
+
var results = [];
|
229
|
+
var byColor = (0, groupBy_1.default)(hand, function (card) { return card % 10; });
|
230
|
+
var byValue = (0, groupBy_1.default)(hand, function (card) { return Math.floor(card / 10); });
|
231
|
+
try {
|
232
|
+
for (var _e = __values([byColor, byValue]), _f = _e.next(); !_f.done; _f = _e.next()) {
|
233
|
+
var group = _f.value;
|
234
|
+
try {
|
235
|
+
for (var _g = (e_3 = void 0, __values(Object.values(group))), _h = _g.next(); !_h.done; _h = _g.next()) {
|
236
|
+
var cards = _h.value;
|
237
|
+
try {
|
238
|
+
for (var _j = (e_4 = void 0, __values([tableCount, tableCount + 1])), _k = _j.next(); !_k.done; _k = _j.next()) {
|
239
|
+
var count = _k.value;
|
240
|
+
if (cards.length >= count) {
|
241
|
+
try {
|
242
|
+
for (var _l = (e_5 = void 0, __values(this.kCombinations(cards, count))), _m = _l.next(); !_m.done; _m = _l.next()) {
|
243
|
+
var comb = _m.value;
|
244
|
+
if (this.concatCardValue(comb) > tableValue) {
|
245
|
+
results.push(comb);
|
246
|
+
}
|
247
|
+
}
|
248
|
+
}
|
249
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
250
|
+
finally {
|
251
|
+
try {
|
252
|
+
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
253
|
+
}
|
254
|
+
finally { if (e_5) throw e_5.error; }
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
}
|
259
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
260
|
+
finally {
|
261
|
+
try {
|
262
|
+
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
263
|
+
}
|
264
|
+
finally { if (e_4) throw e_4.error; }
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
269
|
+
finally {
|
270
|
+
try {
|
271
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
272
|
+
}
|
273
|
+
finally { if (e_3) throw e_3.error; }
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
278
|
+
finally {
|
279
|
+
try {
|
280
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
281
|
+
}
|
282
|
+
finally { if (e_2) throw e_2.error; }
|
283
|
+
}
|
284
|
+
var unique = (0, uniqWith_1.default)(results, function (a, b) { return (0, isEqual_1.default)((0, orderBy_1.default)(a), (0, orderBy_1.default)(b)); });
|
285
|
+
return unique;
|
286
|
+
};
|
287
|
+
return PlayCardsRule;
|
288
|
+
}(BasePlayerTurn_1.BasePlayerTurn));
|
289
|
+
exports.PlayCardsRule = PlayCardsRule;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.RuleId = void 0;
|
4
|
+
var RuleId;
|
5
|
+
(function (RuleId) {
|
6
|
+
RuleId[RuleId["PlayCards"] = 1] = "PlayCards";
|
7
|
+
RuleId[RuleId["PickCard"] = 2] = "PickCard";
|
8
|
+
RuleId[RuleId["EndOfRound"] = 3] = "EndOfRound";
|
9
|
+
RuleId[RuleId["DealCards"] = 4] = "DealCards";
|
10
|
+
})(RuleId = exports.RuleId || (exports.RuleId = {}));
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Sort = void 0;
|
4
|
+
var Sort;
|
5
|
+
(function (Sort) {
|
6
|
+
Sort[Sort["Color"] = 1] = "Color";
|
7
|
+
Sort[Sort["ValueAsc"] = 2] = "ValueAsc";
|
8
|
+
Sort[Sort["ValueDesc"] = 3] = "ValueDesc";
|
9
|
+
})(Sort = exports.Sort || (exports.Sort = {}));
|
package/package.json
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"name": "@gamepark/odin",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "The rules of Odin adapted for Game Park",
|
5
|
+
"sideEffects": false,
|
6
|
+
"main": "dist/index.js",
|
7
|
+
"types": "dist/index.d.ts",
|
8
|
+
"files": [
|
9
|
+
"dist"
|
10
|
+
],
|
11
|
+
"author": "Romain Fromi <romain@game-park.com> (https://game-park.com/)",
|
12
|
+
"license": "ISC",
|
13
|
+
"publishConfig": {
|
14
|
+
"access": "public"
|
15
|
+
},
|
16
|
+
"scripts": {
|
17
|
+
"build": "tsc",
|
18
|
+
"prepublishOnly": "tsc",
|
19
|
+
"publish": "lerna publish",
|
20
|
+
"lint": "eslint --fix"
|
21
|
+
},
|
22
|
+
"peerDependencies": {
|
23
|
+
"@gamepark/rules-api": ">=6.33",
|
24
|
+
"lodash": ">=4.17"
|
25
|
+
},
|
26
|
+
"devDependencies": {
|
27
|
+
"@gamepark/rules-api": "~6.37.1",
|
28
|
+
"@types/lodash": "^4.17.7",
|
29
|
+
"i18next": "^22.0.3",
|
30
|
+
"lodash": "^4.17.21"
|
31
|
+
},
|
32
|
+
"gitHead": "b29d409632381911a0d74c1b6756a80016d81d1e"
|
33
|
+
}
|