@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.
- package/dist/OdinOptions.js +1 -4
- package/dist/OdinRules.js +47 -73
- package/dist/OdinSetup.js +18 -43
- package/dist/PlayerId.js +1 -2
- package/dist/index.js +3 -9
- package/dist/material/Card.js +6 -11
- package/dist/material/LocationType.js +4 -7
- package/dist/material/MaterialType.js +2 -5
- package/dist/rules/BasePlayerTurn.js +15 -51
- package/dist/rules/ChangePlayerRule.js +21 -53
- package/dist/rules/CustomMoveType.js +2 -5
- package/dist/rules/DealCardsRule.js +40 -119
- package/dist/rules/EndOfRoundRule.js +48 -145
- package/dist/rules/Memory.js +2 -5
- package/dist/rules/PickCardRule.js +30 -87
- package/dist/rules/PlayCardsRule.d.ts +1 -0
- package/dist/rules/PlayCardsRule.js +115 -234
- package/dist/rules/RuleId.js +2 -5
- package/dist/rules/Sort.js +2 -5
- package/dist/rules/helper/EndHelper.js +6 -35
- package/dist/rules/helper/ScoreHelper.js +17 -46
- package/dist/rules/helper/SortHelper.js +6 -34
- package/package.json +3 -2
- package/dist/ChangePlayerRule.d.ts +0 -6
- package/dist/ChangePlayerRule.js +0 -62
package/dist/OdinOptions.js
CHANGED
package/dist/OdinRules.js
CHANGED
|
@@ -1,78 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
68
|
-
return new
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
75
|
-
}
|
|
76
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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';
|
package/dist/material/Card.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
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
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
12
|
+
})(MiddleOfTable || (MiddleOfTable = {}));
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
4
|
+
})(MaterialType || (MaterialType = {}));
|
|
@@ -1,52 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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:
|
|
11
|
+
type: LocationType.Discard
|
|
34
12
|
}));
|
|
35
13
|
}
|
|
36
|
-
|
|
14
|
+
const nextTable = this.nextTable;
|
|
37
15
|
if (nextTable.length) {
|
|
38
16
|
moves.push(nextTable.moveItemsAtOnce({
|
|
39
|
-
type:
|
|
40
|
-
id:
|
|
17
|
+
type: LocationType.MiddleOfTable,
|
|
18
|
+
id: MiddleOfTable.Current
|
|
41
19
|
}));
|
|
42
20
|
}
|
|
43
|
-
moves.push(this.startPlayerTurn(
|
|
21
|
+
moves.push(this.startPlayerTurn(RuleId.PlayCards, this.nextPlayer));
|
|
44
22
|
return moves;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
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
|
|
7
|
+
})(CustomMoveType || (CustomMoveType = {}));
|
|
@@ -1,130 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
11
|
+
moves.push(...this.dealToPlayersAndGo());
|
|
70
12
|
return moves;
|
|
71
13
|
}
|
|
72
14
|
moves.push(discard.moveItemsAtOnce({
|
|
73
|
-
type:
|
|
15
|
+
type: LocationType.Deck
|
|
74
16
|
}));
|
|
75
|
-
moves.push(this.material(
|
|
17
|
+
moves.push(this.material(MaterialType.Card).shuffle());
|
|
76
18
|
return moves;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!
|
|
19
|
+
}
|
|
20
|
+
afterItemMove(move) {
|
|
21
|
+
if (!isShuffleItemType(MaterialType.Card)(move))
|
|
80
22
|
return [];
|
|
81
23
|
return this.dealToPlayersAndGo();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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(
|
|
39
|
+
moves.push(this.startPlayerTurn(RuleId.PlayCards, this.remind(Memory.FirstPlayer)));
|
|
109
40
|
return moves;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return this.material(
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
}
|