@gamepark/odin 0.0.8 → 1.1.0

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.
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OdinOptionsSpec = void 0;
4
- exports.OdinOptionsSpec = {};
1
+ export const OdinOptionsSpec = {};
package/dist/OdinRules.js CHANGED
@@ -1,78 +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);
1
+ import { FillGapStrategy, hideItemId, hideItemIdToOthers, PositiveSequenceStrategy, SecretMaterialRules } from '@gamepark/rules-api';
2
+ import { LocationType } from './material/LocationType';
3
+ import { MaterialType } from './material/MaterialType';
4
+ import { ChangePlayerRule } from './rules/ChangePlayerRule';
5
+ import { CustomMoveType } from './rules/CustomMoveType';
6
+ import { DealCardsRule } from './rules/DealCardsRule';
7
+ import { EndOfRoundRule } from './rules/EndOfRoundRule';
8
+ import { ScoreHelper } from './rules/helper/ScoreHelper';
9
+ import { Memory } from './rules/Memory';
10
+ import { PickCardRule } from './rules/PickCardRule';
11
+ import { PlayCardsRule } from './rules/PlayCardsRule';
12
+ import { RuleId } from './rules/RuleId';
13
+ export class OdinRules extends SecretMaterialRules {
14
+ rules = {
15
+ [RuleId.PlayCards]: PlayCardsRule,
16
+ [RuleId.DealCards]: DealCardsRule,
17
+ [RuleId.PickCard]: PickCardRule,
18
+ [RuleId.ChangePlayer]: ChangePlayerRule,
19
+ [RuleId.EndOfRound]: EndOfRoundRule
8
20
  };
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 __());
21
+ hidingStrategies = {
22
+ [MaterialType.Card]: {
23
+ [LocationType.Deck]: hideItemId,
24
+ [LocationType.Hand]: hideItemIdToOthers
25
+ }
15
26
  };
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 ChangePlayerRule_1 = require("./rules/ChangePlayerRule");
23
- var CustomMoveType_1 = require("./rules/CustomMoveType");
24
- var DealCardsRule_1 = require("./rules/DealCardsRule");
25
- var EndOfRoundRule_1 = require("./rules/EndOfRoundRule");
26
- var ScoreHelper_1 = require("./rules/helper/ScoreHelper");
27
- var Memory_1 = require("./rules/Memory");
28
- var PickCardRule_1 = require("./rules/PickCardRule");
29
- var PlayCardsRule_1 = require("./rules/PlayCardsRule");
30
- var RuleId_1 = require("./rules/RuleId");
31
- var OdinRules = (function (_super) {
32
- __extends(OdinRules, _super);
33
- function OdinRules() {
34
- var _a, _b, _c, _d, _e;
35
- var _this = _super !== null && _super.apply(this, arguments) || this;
36
- _this.rules = (_a = {},
37
- _a[RuleId_1.RuleId.PlayCards] = PlayCardsRule_1.PlayCardsRule,
38
- _a[RuleId_1.RuleId.DealCards] = DealCardsRule_1.DealCardsRule,
39
- _a[RuleId_1.RuleId.PickCard] = PickCardRule_1.PickCardRule,
40
- _a[RuleId_1.RuleId.ChangePlayer] = ChangePlayerRule_1.ChangePlayerRule,
41
- _a[RuleId_1.RuleId.EndOfRound] = EndOfRoundRule_1.EndOfRoundRule,
42
- _a);
43
- _this.hidingStrategies = (_b = {},
44
- _b[MaterialType_1.MaterialType.Card] = (_c = {},
45
- _c[LocationType_1.LocationType.Deck] = rules_api_1.hideItemId,
46
- _c[LocationType_1.LocationType.Hand] = rules_api_1.hideItemIdToOthers,
47
- _c),
48
- _b);
49
- _this.locationsStrategies = (_d = {},
50
- _d[MaterialType_1.MaterialType.Card] = (_e = {},
51
- _e[LocationType_1.LocationType.Hand] = new rules_api_1.PositiveSequenceStrategy(),
52
- _e[LocationType_1.LocationType.Deck] = new rules_api_1.PositiveSequenceStrategy(),
53
- _e[LocationType_1.LocationType.MiddleOfTable] = new rules_api_1.FillGapStrategy(),
54
- _e[LocationType_1.LocationType.Discard] = new rules_api_1.PositiveSequenceStrategy(),
55
- _e),
56
- _d);
57
- _this.rankByLowerScore = true;
58
- return _this;
59
- }
60
- OdinRules.prototype.restoreTransientState = function (previousState) {
61
- _super.prototype.restoreTransientState.call(this, previousState);
62
- this.memorize(Memory_1.Memory.HandSort, previousState.memory[Memory_1.Memory.HandSort]);
27
+ locationsStrategies = {
28
+ [MaterialType.Card]: {
29
+ [LocationType.Hand]: new PositiveSequenceStrategy(),
30
+ [LocationType.Deck]: new PositiveSequenceStrategy(),
31
+ [LocationType.MiddleOfTable]: new FillGapStrategy(),
32
+ [LocationType.Discard]: new PositiveSequenceStrategy()
33
+ }
63
34
  };
64
- OdinRules.prototype.giveTime = function () {
35
+ restoreTransientState(previousState) {
36
+ super.restoreTransientState(previousState);
37
+ this.memorize(Memory.HandSort, previousState.memory[Memory.HandSort]);
38
+ }
39
+ giveTime() {
65
40
  return 30;
66
- };
67
- OdinRules.prototype.getScore = function (playerId) {
68
- return new ScoreHelper_1.ScoreHelper(this.game, playerId).score;
69
- };
70
- OdinRules.prototype.onCustomMove = function (move, context) {
71
- if (move.type === CustomMoveType_1.CustomMoveType.SortHand) {
72
- this.memorize(Memory_1.Memory.HandSort, move.data);
41
+ }
42
+ getScore(playerId) {
43
+ return new ScoreHelper(this.game, playerId).score;
44
+ }
45
+ rankByLowerScore = true;
46
+ onCustomMove(move, context) {
47
+ if (move.type === CustomMoveType.SortHand) {
48
+ this.memorize(Memory.HandSort, move.data);
73
49
  }
74
- return _super.prototype.onCustomMove.call(this, move, context);
75
- };
76
- return OdinRules;
77
- }(rules_api_1.SecretMaterialRules));
78
- exports.OdinRules = OdinRules;
50
+ return super.onCustomMove(move, context);
51
+ }
52
+ }
package/dist/OdinSetup.js CHANGED
@@ -1,44 +1,19 @@
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;
1
+ import { getEnumValues, MaterialGameSetup } from '@gamepark/rules-api';
2
+ import { OdinRules } from './OdinRules';
3
+ import { LocationType } from './material/LocationType';
4
+ import { MaterialType } from './material/MaterialType';
5
+ import { Memory } from './rules/Memory';
6
+ import { RuleId } from './rules/RuleId';
7
+ import { Card } from './material/Card';
8
+ export class OdinSetup extends MaterialGameSetup {
9
+ Rules = OdinRules;
10
+ setupMaterial(_options) {
11
+ this.material(MaterialType.Card).createItems(getEnumValues(Card).map((id) => ({ id, location: { type: LocationType.Deck } })));
12
+ this.material(MaterialType.Card).shuffle();
32
13
  }
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.memorize(Memory_1.Memory.Round, 1);
40
- this.startRule(RuleId_1.RuleId.DealCards);
41
- };
42
- return OdinSetup;
43
- }(rules_api_1.MaterialGameSetup));
44
- exports.OdinSetup = OdinSetup;
14
+ start() {
15
+ this.memorize(Memory.FirstPlayer, this.game.players[0]);
16
+ this.memorize(Memory.Round, 1);
17
+ this.startRule(RuleId.DealCards);
18
+ }
19
+ }
package/dist/PlayerId.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/index.js CHANGED
@@ -1,9 +1,3 @@
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; } });
1
+ export { OdinRules } from './OdinRules';
2
+ export { OdinOptionsSpec } from './OdinOptions';
3
+ export { OdinSetup } from './OdinSetup';
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCardValue = exports.getCardColor = exports.CardColor = exports.Card = void 0;
4
- var Card;
1
+ export var Card;
5
2
  (function (Card) {
6
3
  Card[Card["Blue1"] = 11] = "Blue1";
7
4
  Card[Card["Blue2"] = 12] = "Blue2";
@@ -57,8 +54,8 @@ var Card;
57
54
  Card[Card["Brown7"] = 67] = "Brown7";
58
55
  Card[Card["Brown8"] = 68] = "Brown8";
59
56
  Card[Card["Brown9"] = 69] = "Brown9";
60
- })(Card = exports.Card || (exports.Card = {}));
61
- var CardColor;
57
+ })(Card || (Card = {}));
58
+ export var CardColor;
62
59
  (function (CardColor) {
63
60
  CardColor[CardColor["Blue"] = 1] = "Blue";
64
61
  CardColor[CardColor["Red"] = 2] = "Red";
@@ -66,8 +63,6 @@ var CardColor;
66
63
  CardColor[CardColor["Orange"] = 4] = "Orange";
67
64
  CardColor[CardColor["Pink"] = 5] = "Pink";
68
65
  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;
66
+ })(CardColor || (CardColor = {}));
67
+ export const getCardColor = (card) => Math.floor(card / 10);
68
+ export const getCardValue = (card) => card % 10;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MiddleOfTable = exports.LocationType = void 0;
4
- var LocationType;
1
+ export var LocationType;
5
2
  (function (LocationType) {
6
3
  LocationType[LocationType["Deck"] = 1] = "Deck";
7
4
  LocationType[LocationType["Hand"] = 2] = "Hand";
8
5
  LocationType[LocationType["MiddleOfTable"] = 3] = "MiddleOfTable";
9
6
  LocationType[LocationType["Discard"] = 4] = "Discard";
10
- })(LocationType = exports.LocationType || (exports.LocationType = {}));
11
- var MiddleOfTable;
7
+ })(LocationType || (LocationType = {}));
8
+ export var MiddleOfTable;
12
9
  (function (MiddleOfTable) {
13
10
  MiddleOfTable[MiddleOfTable["Current"] = 1] = "Current";
14
11
  MiddleOfTable[MiddleOfTable["Next"] = 2] = "Next";
15
- })(MiddleOfTable = exports.MiddleOfTable || (exports.MiddleOfTable = {}));
12
+ })(MiddleOfTable || (MiddleOfTable = {}));
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MaterialType = void 0;
4
- var MaterialType;
1
+ export var MaterialType;
5
2
  (function (MaterialType) {
6
3
  MaterialType[MaterialType["Card"] = 1] = "Card";
7
- })(MaterialType = exports.MaterialType || (exports.MaterialType = {}));
4
+ })(MaterialType || (MaterialType = {}));
@@ -1,52 +1,16 @@
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;
1
+ import { PlayerTurnRule } from '@gamepark/rules-api';
2
+ import orderBy from 'lodash/orderBy';
3
+ import { Memory } from './Memory';
4
+ export class BasePlayerTurn extends PlayerTurnRule {
5
+ get nextPlayer() {
6
+ const playerIndex = this.game.players.indexOf(this.firstPlayer);
7
+ const players = orderBy(this.game.players, (id) => {
8
+ const index = this.game.players.indexOf(id);
9
+ return (index - playerIndex + this.game.players.length) % this.game.players.length;
10
+ });
11
+ return players[(players.indexOf(this.player) + 1) % players.length];
29
12
  }
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;
13
+ get firstPlayer() {
14
+ return this.remind(Memory.FirstPlayer);
15
+ }
16
+ }
@@ -1,62 +1,30 @@
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.ChangePlayerRule = void 0;
19
- var LocationType_1 = require("../material/LocationType");
20
- var MaterialType_1 = require("../material/MaterialType");
21
- var BasePlayerTurn_1 = require("./BasePlayerTurn");
22
- var RuleId_1 = require("./RuleId");
23
- var ChangePlayerRule = (function (_super) {
24
- __extends(ChangePlayerRule, _super);
25
- function ChangePlayerRule() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- ChangePlayerRule.prototype.onRuleStart = function () {
29
- var moves = [];
30
- var currentTable = this.currentTable;
1
+ import { LocationType, MiddleOfTable } from '../material/LocationType';
2
+ import { MaterialType } from '../material/MaterialType';
3
+ import { BasePlayerTurn } from './BasePlayerTurn';
4
+ import { RuleId } from './RuleId';
5
+ export class ChangePlayerRule extends BasePlayerTurn {
6
+ onRuleStart() {
7
+ const moves = [];
8
+ const currentTable = this.currentTable;
31
9
  if (currentTable.length) {
32
10
  moves.push(this.currentTable.moveItemsAtOnce({
33
- type: LocationType_1.LocationType.Discard
11
+ type: LocationType.Discard
34
12
  }));
35
13
  }
36
- var nextTable = this.nextTable;
14
+ const nextTable = this.nextTable;
37
15
  if (nextTable.length) {
38
16
  moves.push(nextTable.moveItemsAtOnce({
39
- type: LocationType_1.LocationType.MiddleOfTable,
40
- id: LocationType_1.MiddleOfTable.Current
17
+ type: LocationType.MiddleOfTable,
18
+ id: MiddleOfTable.Current
41
19
  }));
42
20
  }
43
- moves.push(this.startPlayerTurn(RuleId_1.RuleId.PlayCards, this.nextPlayer));
21
+ moves.push(this.startPlayerTurn(RuleId.PlayCards, this.nextPlayer));
44
22
  return moves;
45
- };
46
- Object.defineProperty(ChangePlayerRule.prototype, "currentTable", {
47
- get: function () {
48
- return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.MiddleOfTable).locationId(LocationType_1.MiddleOfTable.Current);
49
- },
50
- enumerable: false,
51
- configurable: true
52
- });
53
- Object.defineProperty(ChangePlayerRule.prototype, "nextTable", {
54
- get: function () {
55
- return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.MiddleOfTable).locationId(LocationType_1.MiddleOfTable.Next);
56
- },
57
- enumerable: false,
58
- configurable: true
59
- });
60
- return ChangePlayerRule;
61
- }(BasePlayerTurn_1.BasePlayerTurn));
62
- exports.ChangePlayerRule = ChangePlayerRule;
23
+ }
24
+ get currentTable() {
25
+ return this.material(MaterialType.Card).location(LocationType.MiddleOfTable).locationId(MiddleOfTable.Current);
26
+ }
27
+ get nextTable() {
28
+ return this.material(MaterialType.Card).location(LocationType.MiddleOfTable).locationId(MiddleOfTable.Next);
29
+ }
30
+ }
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomMoveType = void 0;
4
- var CustomMoveType;
1
+ export var CustomMoveType;
5
2
  (function (CustomMoveType) {
6
3
  CustomMoveType[CustomMoveType["Pass"] = 1] = "Pass";
7
4
  CustomMoveType[CustomMoveType["TurnTempo"] = 2] = "TurnTempo";
8
5
  CustomMoveType[CustomMoveType["SortHand"] = 3] = "SortHand";
9
6
  CustomMoveType[CustomMoveType["PlaceAllCards"] = 4] = "PlaceAllCards";
10
- })(CustomMoveType = exports.CustomMoveType || (exports.CustomMoveType = {}));
7
+ })(CustomMoveType || (CustomMoveType = {}));
@@ -1,130 +1,51 @@
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 = [];
1
+ import { isShuffleItemType, MaterialRulesPart } from '@gamepark/rules-api';
2
+ import { LocationType } from '../material/LocationType';
3
+ import { MaterialType } from '../material/MaterialType';
4
+ import { Memory } from './Memory';
5
+ import { RuleId } from './RuleId';
6
+ export class DealCardsRule extends MaterialRulesPart {
7
+ onRuleStart() {
8
+ const discard = this.discard;
9
+ const moves = [];
68
10
  if (!discard.length) {
69
- moves.push.apply(moves, __spreadArray([], __read(this.dealToPlayersAndGo()), false));
11
+ moves.push(...this.dealToPlayersAndGo());
70
12
  return moves;
71
13
  }
72
14
  moves.push(discard.moveItemsAtOnce({
73
- type: LocationType_1.LocationType.Deck
15
+ type: LocationType.Deck
74
16
  }));
75
- moves.push(this.material(MaterialType_1.MaterialType.Card).shuffle());
17
+ moves.push(this.material(MaterialType.Card).shuffle());
76
18
  return moves;
77
- };
78
- DealCardsRule.prototype.afterItemMove = function (move) {
79
- if (!(0, rules_api_1.isShuffleItemType)(MaterialType_1.MaterialType.Card)(move))
19
+ }
20
+ afterItemMove(move) {
21
+ if (!isShuffleItemType(MaterialType.Card)(move))
80
22
  return [];
81
23
  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
- var hand = this.getPlayerHand(player);
92
- if (hand.length + i >= 9)
93
- continue;
94
- moves.push.apply(moves, __spreadArray([], __read(deck.deal({
95
- type: LocationType_1.LocationType.Hand,
96
- player: player
97
- })), false));
98
- }
99
- }
100
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
101
- finally {
102
- try {
103
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
104
- }
105
- finally { if (e_1) throw e_1.error; }
24
+ }
25
+ dealToPlayersAndGo() {
26
+ const moves = [];
27
+ const deck = this.deck;
28
+ for (let i = 0; i < 9; i++) {
29
+ for (const player of this.game.players) {
30
+ const hand = this.getPlayerHand(player);
31
+ if (hand.length + i >= 9)
32
+ continue;
33
+ moves.push(...deck.deal({
34
+ type: LocationType.Hand,
35
+ player: player
36
+ }));
106
37
  }
107
38
  }
108
- moves.push(this.startPlayerTurn(RuleId_1.RuleId.PlayCards, this.remind(Memory_1.Memory.FirstPlayer)));
39
+ moves.push(this.startPlayerTurn(RuleId.PlayCards, this.remind(Memory.FirstPlayer)));
109
40
  return moves;
110
- };
111
- DealCardsRule.prototype.getPlayerHand = function (player) {
112
- return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Hand).player(player);
113
- };
114
- Object.defineProperty(DealCardsRule.prototype, "deck", {
115
- get: function () {
116
- return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Deck).deck();
117
- },
118
- enumerable: false,
119
- configurable: true
120
- });
121
- Object.defineProperty(DealCardsRule.prototype, "discard", {
122
- get: function () {
123
- return this.material(MaterialType_1.MaterialType.Card).location(LocationType_1.LocationType.Discard);
124
- },
125
- enumerable: false,
126
- configurable: true
127
- });
128
- return DealCardsRule;
129
- }(rules_api_1.MaterialRulesPart));
130
- exports.DealCardsRule = DealCardsRule;
41
+ }
42
+ getPlayerHand(player) {
43
+ return this.material(MaterialType.Card).location(LocationType.Hand).player(player);
44
+ }
45
+ get deck() {
46
+ return this.material(MaterialType.Card).location(LocationType.Deck).deck();
47
+ }
48
+ get discard() {
49
+ return this.material(MaterialType.Card).location(LocationType.Discard);
50
+ }
51
+ }