@gamepark/zenith 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.
Files changed (125) hide show
  1. package/dist/PlayerId.d.ts +1 -0
  2. package/dist/PlayerId.js +2 -0
  3. package/dist/TeamColor.d.ts +9 -0
  4. package/dist/TeamColor.js +16 -0
  5. package/dist/ZenithOptions.d.ts +5 -0
  6. package/dist/ZenithOptions.js +4 -0
  7. package/dist/ZenithRules.d.ts +68 -0
  8. package/dist/ZenithRules.js +128 -0
  9. package/dist/ZenithSetup.d.ts +24 -0
  10. package/dist/ZenithSetup.js +316 -0
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.js +9 -0
  13. package/dist/material/Agent.d.ts +93 -0
  14. package/dist/material/Agent.js +98 -0
  15. package/dist/material/Agents.d.ts +102 -0
  16. package/dist/material/Agents.js +2305 -0
  17. package/dist/material/Bonus.d.ts +12 -0
  18. package/dist/material/Bonus.js +34 -0
  19. package/dist/material/Bonuses.d.ts +14 -0
  20. package/dist/material/Bonuses.js +63 -0
  21. package/dist/material/Credit.d.ts +6 -0
  22. package/dist/material/Credit.js +11 -0
  23. package/dist/material/Faction.d.ts +6 -0
  24. package/dist/material/Faction.js +11 -0
  25. package/dist/material/Influence.d.ts +8 -0
  26. package/dist/material/Influence.js +13 -0
  27. package/dist/material/LocationType.d.ts +23 -0
  28. package/dist/material/LocationType.js +27 -0
  29. package/dist/material/MaterialType.d.ts +12 -0
  30. package/dist/material/MaterialType.js +16 -0
  31. package/dist/material/effect/Effect.d.ts +144 -0
  32. package/dist/material/effect/Effect.js +14 -0
  33. package/dist/material/effect/EffectType.d.ts +23 -0
  34. package/dist/material/effect/EffectType.js +27 -0
  35. package/dist/rules/CustomMoveType.d.ts +8 -0
  36. package/dist/rules/CustomMoveType.js +12 -0
  37. package/dist/rules/DiscardActionRule.d.ts +8 -0
  38. package/dist/rules/DiscardActionRule.js +84 -0
  39. package/dist/rules/Memory.d.ts +25 -0
  40. package/dist/rules/Memory.js +19 -0
  41. package/dist/rules/MulliganRule.d.ts +12 -0
  42. package/dist/rules/MulliganRule.js +138 -0
  43. package/dist/rules/PlayCardRule.d.ts +15 -0
  44. package/dist/rules/PlayCardRule.js +147 -0
  45. package/dist/rules/RefillRule.d.ts +17 -0
  46. package/dist/rules/RefillRule.js +211 -0
  47. package/dist/rules/RuleId.d.ts +27 -0
  48. package/dist/rules/RuleId.js +31 -0
  49. package/dist/rules/discard-action/DiplomacyActions.d.ts +3 -0
  50. package/dist/rules/discard-action/DiplomacyActions.js +39 -0
  51. package/dist/rules/discard-action/DiplomacyBoardRule.d.ts +9 -0
  52. package/dist/rules/discard-action/DiplomacyBoardRule.js +68 -0
  53. package/dist/rules/discard-action/TechnologyActions.d.ts +3 -0
  54. package/dist/rules/discard-action/TechnologyActions.js +187 -0
  55. package/dist/rules/discard-action/TechnologyBoardRule.d.ts +8 -0
  56. package/dist/rules/discard-action/TechnologyBoardRule.js +109 -0
  57. package/dist/rules/effect/ChoiceRule.d.ts +12 -0
  58. package/dist/rules/effect/ChoiceRule.js +91 -0
  59. package/dist/rules/effect/ConditionalRule.d.ts +17 -0
  60. package/dist/rules/effect/ConditionalRule.js +197 -0
  61. package/dist/rules/effect/DevelopTechnologyRule.d.ts +11 -0
  62. package/dist/rules/effect/DevelopTechnologyRule.js +133 -0
  63. package/dist/rules/effect/DiscardRule.d.ts +18 -0
  64. package/dist/rules/effect/DiscardRule.js +107 -0
  65. package/dist/rules/effect/EffectRule.d.ts +27 -0
  66. package/dist/rules/effect/EffectRule.js +161 -0
  67. package/dist/rules/effect/ExileRule.d.ts +22 -0
  68. package/dist/rules/effect/ExileRule.js +182 -0
  69. package/dist/rules/effect/GiveCreditRule.d.ts +13 -0
  70. package/dist/rules/effect/GiveCreditRule.js +79 -0
  71. package/dist/rules/effect/GiveInfluenceRule.d.ts +10 -0
  72. package/dist/rules/effect/GiveInfluenceRule.js +119 -0
  73. package/dist/rules/effect/GiveLeaderBadgeRule.d.ts +9 -0
  74. package/dist/rules/effect/GiveLeaderBadgeRule.js +54 -0
  75. package/dist/rules/effect/GiveZenithiumRule.d.ts +9 -0
  76. package/dist/rules/effect/GiveZenithiumRule.js +85 -0
  77. package/dist/rules/effect/MobilizeRule.d.ts +18 -0
  78. package/dist/rules/effect/MobilizeRule.js +117 -0
  79. package/dist/rules/effect/ResetInfluenceRule.d.ts +9 -0
  80. package/dist/rules/effect/ResetInfluenceRule.js +63 -0
  81. package/dist/rules/effect/SpendCreditRule.d.ts +16 -0
  82. package/dist/rules/effect/SpendCreditRule.js +109 -0
  83. package/dist/rules/effect/SpendZenithiumRule.d.ts +17 -0
  84. package/dist/rules/effect/SpendZenithiumRule.js +116 -0
  85. package/dist/rules/effect/StealCreditRule.d.ts +7 -0
  86. package/dist/rules/effect/StealCreditRule.js +67 -0
  87. package/dist/rules/effect/TakeBonusRule.d.ts +11 -0
  88. package/dist/rules/effect/TakeBonusRule.js +98 -0
  89. package/dist/rules/effect/TakeLeaderBadgeRule.d.ts +9 -0
  90. package/dist/rules/effect/TakeLeaderBadgeRule.js +102 -0
  91. package/dist/rules/effect/TakeTechnologyBonusTokenRule.d.ts +11 -0
  92. package/dist/rules/effect/TakeTechnologyBonusTokenRule.js +122 -0
  93. package/dist/rules/effect/TransferRule.d.ts +19 -0
  94. package/dist/rules/effect/TransferRule.js +104 -0
  95. package/dist/rules/effect/WinCreditRule.d.ts +13 -0
  96. package/dist/rules/effect/WinCreditRule.js +142 -0
  97. package/dist/rules/effect/WinInfluenceRule.d.ts +23 -0
  98. package/dist/rules/effect/WinInfluenceRule.js +328 -0
  99. package/dist/rules/effect/WinZenithiumRule.d.ts +9 -0
  100. package/dist/rules/effect/WinZenithiumRule.js +92 -0
  101. package/dist/rules/effect/index.d.ts +19 -0
  102. package/dist/rules/effect/index.js +35 -0
  103. package/dist/rules/helper/BonusHelper.d.ts +15 -0
  104. package/dist/rules/helper/BonusHelper.js +86 -0
  105. package/dist/rules/helper/CreditHelper.d.ts +9 -0
  106. package/dist/rules/helper/CreditHelper.js +45 -0
  107. package/dist/rules/helper/EffectHelper.d.ts +16 -0
  108. package/dist/rules/helper/EffectHelper.js +133 -0
  109. package/dist/rules/helper/EffectRuleIds.d.ts +3 -0
  110. package/dist/rules/helper/EffectRuleIds.js +29 -0
  111. package/dist/rules/helper/EndGameHelper.d.ts +13 -0
  112. package/dist/rules/helper/EndGameHelper.js +70 -0
  113. package/dist/rules/helper/InfluenceHelper.d.ts +13 -0
  114. package/dist/rules/helper/InfluenceHelper.js +47 -0
  115. package/dist/rules/helper/MobilizeHelper.d.ts +10 -0
  116. package/dist/rules/helper/MobilizeHelper.js +56 -0
  117. package/dist/rules/helper/PlanetHelper.d.ts +19 -0
  118. package/dist/rules/helper/PlanetHelper.js +104 -0
  119. package/dist/rules/helper/PlayerHelper.d.ts +12 -0
  120. package/dist/rules/helper/PlayerHelper.js +61 -0
  121. package/dist/rules/helper/TechnologyHelper.d.ts +4 -0
  122. package/dist/rules/helper/TechnologyHelper.js +96 -0
  123. package/dist/rules/helper/ZenithiumHelper.d.ts +10 -0
  124. package/dist/rules/helper/ZenithiumHelper.js +59 -0
  125. package/package.json +33 -0
@@ -0,0 +1,197 @@
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 __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __read = (this && this.__read) || function (o, n) {
29
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
30
+ if (!m) return o;
31
+ var i = m.call(o), r, ar = [], e;
32
+ try {
33
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
34
+ }
35
+ catch (error) { e = { error: error }; }
36
+ finally {
37
+ try {
38
+ if (r && !r.done && (m = i["return"])) m.call(i);
39
+ }
40
+ finally { if (e) throw e.error; }
41
+ }
42
+ return ar;
43
+ };
44
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
46
+ if (ar || !(i in from)) {
47
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
48
+ ar[i] = from[i];
49
+ }
50
+ }
51
+ return to.concat(ar || Array.prototype.slice.call(from));
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.ConditionalRule = void 0;
55
+ var rules_api_1 = require("@gamepark/rules-api");
56
+ var Effect_1 = require("../../material/effect/Effect");
57
+ var EffectType_1 = require("../../material/effect/EffectType");
58
+ var CustomMoveType_1 = require("../CustomMoveType");
59
+ var EffectHelper_1 = require("../helper/EffectHelper");
60
+ var Memory_1 = require("../Memory");
61
+ var index_1 = require("./index");
62
+ var ConditionalRule = (function (_super) {
63
+ __extends(ConditionalRule, _super);
64
+ function ConditionalRule() {
65
+ return _super !== null && _super.apply(this, arguments) || this;
66
+ }
67
+ ConditionalRule.prototype.onRuleStart = function () {
68
+ var condition = this.effect.condition;
69
+ var moves = _super.prototype.onRuleStart.call(this);
70
+ if (moves.length > 0)
71
+ return moves;
72
+ if (this.isDoCondition(condition) && this.effect.mandatory) {
73
+ moves.push.apply(moves, __spreadArray([], __read((0, EffectHelper_1.getEffectRule)(this.game, condition.effect).getAutomaticEffectMoves()), false));
74
+ return moves;
75
+ }
76
+ if (this.isLeaderCondition(condition) || this.isHaveCreditCondition(condition)) {
77
+ this.removeCondition();
78
+ return this.afterEffectPlayed();
79
+ }
80
+ return [];
81
+ };
82
+ ConditionalRule.prototype.getPlayerMoves = function () {
83
+ var condition = this.effect.condition;
84
+ if (this.isDoCondition(condition)) {
85
+ if (!this.isAutomaticEffect) {
86
+ var moves = [];
87
+ if (!this.effect.mandatory && !this.remind(Memory_1.Memory.CantPass))
88
+ moves.push(this.customMove(CustomMoveType_1.CustomMoveType.Pass));
89
+ moves.push.apply(moves, __spreadArray([], __read((0, EffectHelper_1.getEffectRule)(this.game, condition.effect).getPlayerMoves()), false));
90
+ return moves;
91
+ }
92
+ return [this.customMove(CustomMoveType_1.CustomMoveType.Pass), this.customMove(CustomMoveType_1.CustomMoveType.DoCondition)];
93
+ }
94
+ return [];
95
+ };
96
+ ConditionalRule.prototype.onCustomMove = function (move) {
97
+ if ((0, rules_api_1.isCustomMoveType)(CustomMoveType_1.CustomMoveType.Pass)(move)) {
98
+ this.removeFirstEffect();
99
+ return this.afterEffectPlayed();
100
+ }
101
+ if ((0, rules_api_1.isCustomMoveType)(CustomMoveType_1.CustomMoveType.DoCondition)(move)) {
102
+ var condition_1 = this.effect.condition;
103
+ if (!this.isDoCondition(condition_1))
104
+ return [];
105
+ var conditionEffect = (0, EffectHelper_1.getEffectRule)(this.game, condition_1.effect);
106
+ var extraData = conditionEffect.getExtraDataFromMove(move);
107
+ this.addEffectAndRemoveCondition(extraData);
108
+ return this.afterEffectPlayed();
109
+ }
110
+ this.onEffectPlayed(move);
111
+ var condition = this.effect.condition;
112
+ if (this.isDoCondition(condition)) {
113
+ var moves = (0, EffectHelper_1.getEffectRule)(this.game, condition.effect).onCustomMove(move);
114
+ moves.push.apply(moves, __spreadArray([], __read(this.afterEffectPlayed()), false));
115
+ return moves;
116
+ }
117
+ return [];
118
+ };
119
+ ConditionalRule.prototype.afterItemMove = function (move) {
120
+ var done = this.onEffectPlayed(move);
121
+ if (done) {
122
+ return this.afterEffectPlayed();
123
+ }
124
+ return [];
125
+ };
126
+ ConditionalRule.prototype.onEffectPlayed = function (move) {
127
+ var condition = this.effect.condition;
128
+ if (this.isDoCondition(condition)) {
129
+ if (this.isAutomaticEffect)
130
+ return;
131
+ var conditionEffect = (0, EffectHelper_1.getEffectRule)(this.game, condition.effect);
132
+ var done = conditionEffect.decrement(move);
133
+ if (done) {
134
+ var extraData = conditionEffect.getExtraDataFromMove(move);
135
+ this.removeCondition(extraData);
136
+ }
137
+ else {
138
+ this.memorize(Memory_1.Memory.CantPass, true);
139
+ }
140
+ return done;
141
+ }
142
+ return true;
143
+ };
144
+ Object.defineProperty(ConditionalRule.prototype, "isAutomaticEffect", {
145
+ get: function () {
146
+ var condition = this.effect.condition;
147
+ if (!this.isDoCondition(condition))
148
+ return false;
149
+ return condition.effect.type === EffectType_1.EffectType.GiveCredit || condition.effect.type === EffectType_1.EffectType.GiveZenithium;
150
+ },
151
+ enumerable: false,
152
+ configurable: true
153
+ });
154
+ ConditionalRule.prototype.isDoCondition = function (condition) {
155
+ return condition.type === Effect_1.ConditionType.DoEffect;
156
+ };
157
+ ConditionalRule.prototype.isLeaderCondition = function (condition) {
158
+ return condition.type === Effect_1.ConditionType.Leader;
159
+ };
160
+ ConditionalRule.prototype.isHaveCreditCondition = function (condition) {
161
+ return condition.type === Effect_1.ConditionType.HaveCredits;
162
+ };
163
+ ConditionalRule.prototype.isPossible = function () {
164
+ var condition = this.effect.condition;
165
+ if (this.isDoCondition(condition)) {
166
+ var conditionEffect = (0, EffectHelper_1.getEffectRule)(this.game, condition.effect);
167
+ return conditionEffect.isPossible() && (0, EffectHelper_1.getEffectRule)(this.game, this.effect.effect).isPossible();
168
+ }
169
+ if (this.isLeaderCondition(condition)) {
170
+ return this.playerHelper.isLeader;
171
+ }
172
+ if (this.isHaveCreditCondition(condition)) {
173
+ return this.playerHelper.credits >= condition.min;
174
+ }
175
+ return false;
176
+ };
177
+ ConditionalRule.prototype.addEffectAndRemoveCondition = function (extraData) {
178
+ var _this = this;
179
+ this.memorize(Memory_1.Memory.Effects, function (effects) {
180
+ var firstEffect = effects[0];
181
+ var condition = firstEffect.condition, effect = firstEffect.effect;
182
+ if (extraData) {
183
+ (0, EffectHelper_1.getEffectRule)(_this.game, effect).setExtraData(extraData);
184
+ }
185
+ return __spreadArray([
186
+ __assign(__assign({}, condition.effect), { effectSource: firstEffect.effectSource }),
187
+ __assign(__assign({}, effect), { effectSource: firstEffect.effectSource })
188
+ ], __read(effects.slice(1)), false);
189
+ });
190
+ };
191
+ ConditionalRule.prototype.onRuleEnd = function () {
192
+ this.forget(Memory_1.Memory.CantPass);
193
+ return [];
194
+ };
195
+ return ConditionalRule;
196
+ }(index_1.EffectRule));
197
+ exports.ConditionalRule = ConditionalRule;
@@ -0,0 +1,11 @@
1
+ import { CustomMove, ItemMove, MaterialMove } from '@gamepark/rules-api';
2
+ import { DevelopTechnologyEffect } from '../../material/effect/Effect';
3
+ import { EffectRule } from './index';
4
+ export declare class DevelopTechnologyRule extends EffectRule<DevelopTechnologyEffect> {
5
+ getPlayerMoves(): (CustomMove | import("@gamepark/rules-api").MoveItem<number, number, number>)[];
6
+ afterItemMove(move: ItemMove): MaterialMove[];
7
+ onCustomMove(move: CustomMove): MaterialMove[];
8
+ get technologies(): import("@gamepark/rules-api").Material<number, number, number>;
9
+ isPossible(): boolean;
10
+ get technologyTokens(): import("@gamepark/rules-api").Material<number, number, number>;
11
+ }
@@ -0,0 +1,133 @@
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 __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __read = (this && this.__read) || function (o, n) {
29
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
30
+ if (!m) return o;
31
+ var i = m.call(o), r, ar = [], e;
32
+ try {
33
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
34
+ }
35
+ catch (error) { e = { error: error }; }
36
+ finally {
37
+ try {
38
+ if (r && !r.done && (m = i["return"])) m.call(i);
39
+ }
40
+ finally { if (e) throw e.error; }
41
+ }
42
+ return ar;
43
+ };
44
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
46
+ if (ar || !(i in from)) {
47
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
48
+ ar[i] = from[i];
49
+ }
50
+ }
51
+ return to.concat(ar || Array.prototype.slice.call(from));
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.DevelopTechnologyRule = 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 CustomMoveType_1 = require("../CustomMoveType");
59
+ var TechnologyHelper_1 = require("../helper/TechnologyHelper");
60
+ var index_1 = require("./index");
61
+ var DevelopTechnologyRule = (function (_super) {
62
+ __extends(DevelopTechnologyRule, _super);
63
+ function DevelopTechnologyRule() {
64
+ return _super !== null && _super.apply(this, arguments) || this;
65
+ }
66
+ DevelopTechnologyRule.prototype.getPlayerMoves = function () {
67
+ return __spreadArray(__spreadArray([], __read(this.technologies.moveItems(function (item) { return (__assign(__assign({}, item.location), { x: item.location.x + 1 })); })), false), [
68
+ this.customMove(CustomMoveType_1.CustomMoveType.Pass)
69
+ ], false);
70
+ };
71
+ DevelopTechnologyRule.prototype.afterItemMove = function (move) {
72
+ var _a;
73
+ if (!(0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.TechMarker)(move))
74
+ return [];
75
+ var moves = [];
76
+ if (!this.effect.free) {
77
+ var cost = move.location.x - ((_a = this.effect.discount) !== null && _a !== void 0 ? _a : 0);
78
+ if (cost) {
79
+ moves.push(this.playerHelper.zenithiumMaterial.deleteItem(cost));
80
+ }
81
+ }
82
+ moves.push.apply(moves, __spreadArray([], __read(new TechnologyHelper_1.TechnologyHelper(this.game).applyTechnology(move)), false));
83
+ this.removeFirstEffect();
84
+ moves.push.apply(moves, __spreadArray([], __read(this.afterEffectPlayed()), false));
85
+ return moves;
86
+ };
87
+ DevelopTechnologyRule.prototype.onCustomMove = function (move) {
88
+ if (!(0, rules_api_1.isCustomMoveType)(CustomMoveType_1.CustomMoveType.Pass)(move))
89
+ return [];
90
+ this.removeFirstEffect();
91
+ return this.afterEffectPlayed();
92
+ };
93
+ Object.defineProperty(DevelopTechnologyRule.prototype, "technologies", {
94
+ get: function () {
95
+ var _this = this;
96
+ var zenithium = this.playerHelper.zenithium;
97
+ var techBoard = this.material(MaterialType_1.MaterialType.TechnologyBoard)
98
+ .locationId(function (id) { var _a; return id === ((_a = _this.effect.faction) !== null && _a !== void 0 ? _a : id); })
99
+ .getIndexes();
100
+ var tokens = this.technologyTokens.parent(function (p) { return techBoard.includes(p); });
101
+ if (!tokens.length)
102
+ return tokens;
103
+ if (this.effect.free && this.effect.lowest) {
104
+ var lowestX_1 = tokens.minBy(function (item) { return item.location.x; }).getItem().location.x;
105
+ return tokens.filter(function (item) { return item.location.x === lowestX_1; });
106
+ }
107
+ var discount = this.effect.discount;
108
+ if (discount !== undefined) {
109
+ return tokens.filter(function (item) {
110
+ return item.location.x + 1 - discount <= zenithium;
111
+ });
112
+ }
113
+ return tokens;
114
+ },
115
+ enumerable: false,
116
+ configurable: true
117
+ });
118
+ DevelopTechnologyRule.prototype.isPossible = function () {
119
+ return this.technologies.length > 0;
120
+ };
121
+ Object.defineProperty(DevelopTechnologyRule.prototype, "technologyTokens", {
122
+ get: function () {
123
+ return this.material(MaterialType_1.MaterialType.TechMarker)
124
+ .location(LocationType_1.LocationType.TechnologyBoardTokenSpace)
125
+ .player(this.playerHelper.team)
126
+ .location(function (l) { return l.x < 5; });
127
+ },
128
+ enumerable: false,
129
+ configurable: true
130
+ });
131
+ return DevelopTechnologyRule;
132
+ }(index_1.EffectRule));
133
+ exports.DevelopTechnologyRule = DevelopTechnologyRule;
@@ -0,0 +1,18 @@
1
+ import { ItemMove, MaterialMove } from '@gamepark/rules-api';
2
+ import { DiscardEffect } from '../../material/effect/Effect';
3
+ import { EffectRule } from './index';
4
+ export declare class DiscardRule extends EffectRule<DiscardEffect> {
5
+ onRuleStart(): MaterialMove[];
6
+ getPlayerMoves(): MaterialMove[];
7
+ getExtraDataFromMove(move: ItemMove): {
8
+ quantity: number;
9
+ influence: import("../../material/Influence").Influence;
10
+ } | {
11
+ quantity?: undefined;
12
+ influence?: undefined;
13
+ };
14
+ afterItemMove(move: ItemMove): MaterialMove[];
15
+ isPossible(): boolean;
16
+ get hand(): import("@gamepark/rules-api").Material<number, number, number>;
17
+ onRuleEnd(): never[];
18
+ }
@@ -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.DiscardRule = void 0;
44
+ var rules_api_1 = require("@gamepark/rules-api");
45
+ var Agents_1 = require("../../material/Agents");
46
+ var LocationType_1 = require("../../material/LocationType");
47
+ var MaterialType_1 = require("../../material/MaterialType");
48
+ var Memory_1 = require("../Memory");
49
+ var index_1 = require("./index");
50
+ var DiscardRule = (function (_super) {
51
+ __extends(DiscardRule, _super);
52
+ function DiscardRule() {
53
+ return _super !== null && _super.apply(this, arguments) || this;
54
+ }
55
+ DiscardRule.prototype.onRuleStart = function () {
56
+ var moves = _super.prototype.onRuleStart.call(this);
57
+ if (moves.length > 0)
58
+ return moves;
59
+ this.memorize(Memory_1.Memory.CurrentEffect, JSON.parse(JSON.stringify(this.effect)));
60
+ var effect = this.effect;
61
+ if (effect.full) {
62
+ moves.push(this.hand.moveItemsAtOnce({
63
+ type: LocationType_1.LocationType.AgentDiscard
64
+ }));
65
+ this.removeFirstEffect();
66
+ moves.push.apply(moves, __spreadArray([], __read(this.afterEffectPlayed()), false));
67
+ }
68
+ return moves;
69
+ };
70
+ DiscardRule.prototype.getPlayerMoves = function () {
71
+ var moves = [];
72
+ moves.push.apply(moves, __spreadArray([], __read(this.hand.moveItems({
73
+ type: LocationType_1.LocationType.AgentDiscard
74
+ })), false));
75
+ return moves;
76
+ };
77
+ DiscardRule.prototype.getExtraDataFromMove = function (move) {
78
+ if ((0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.AgentCard)(move) && move.location.type === LocationType_1.LocationType.AgentDiscard) {
79
+ var card = this.material(MaterialType_1.MaterialType.AgentCard).getItem(move.itemIndex);
80
+ var agent = Agents_1.Agents[card.id];
81
+ return { quantity: agent.cost, influence: agent.influence };
82
+ }
83
+ return {};
84
+ };
85
+ DiscardRule.prototype.afterItemMove = function (move) {
86
+ if (!(0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.AgentCard)(move) || move.location.type !== LocationType_1.LocationType.AgentDiscard)
87
+ return [];
88
+ this.removeFirstEffect();
89
+ return this.afterEffectPlayed();
90
+ };
91
+ DiscardRule.prototype.isPossible = function () {
92
+ return this.hand.length > 0;
93
+ };
94
+ Object.defineProperty(DiscardRule.prototype, "hand", {
95
+ get: function () {
96
+ return this.material(MaterialType_1.MaterialType.AgentCard).location(LocationType_1.LocationType.PlayerHand).player(this.player);
97
+ },
98
+ enumerable: false,
99
+ configurable: true
100
+ });
101
+ DiscardRule.prototype.onRuleEnd = function () {
102
+ this.forget(Memory_1.Memory.CurrentEffect);
103
+ return [];
104
+ };
105
+ return DiscardRule;
106
+ }(index_1.EffectRule));
107
+ exports.DiscardRule = DiscardRule;
@@ -0,0 +1,27 @@
1
+ import { CustomMove, ItemMove, MaterialGame, MaterialMove, PlayerTurnRule } from '@gamepark/rules-api';
2
+ import { RuleMove } from '@gamepark/rules-api/dist/material/moves';
3
+ import { RuleStep } from '@gamepark/rules-api/dist/material/rules/RuleStep';
4
+ import { PlayMoveContext } from '@gamepark/rules-api/dist/Rules';
5
+ import { Effect, ExpandedEffect } from '../../material/effect/Effect';
6
+ import { TeamColor } from '../../TeamColor';
7
+ import { PlayerHelper } from '../helper/PlayerHelper';
8
+ import { RuleId } from '../RuleId';
9
+ export declare abstract class EffectRule<E extends Effect = Effect> extends PlayerTurnRule {
10
+ effect: ExpandedEffect<E>;
11
+ constructor(game: MaterialGame, effect?: E);
12
+ onRuleStart(_move?: RuleMove, _previousRule?: RuleStep, _context?: PlayMoveContext): MaterialMove[];
13
+ getAutomaticEffectMoves(): MaterialMove[];
14
+ isPossible(): boolean;
15
+ get creditMoney(): import("@gamepark/rules-api").MaterialMoney<number, number, number, import("../../material/Credit").Credit>;
16
+ setExtraData(_extraData: Record<string, unknown>): void;
17
+ decrement(_move: ItemMove | CustomMove): boolean;
18
+ getExtraDataFromMove(_move: ItemMove | CustomMove): Record<string, unknown>;
19
+ get effects(): ExpandedEffect[];
20
+ get firstEffect(): ExpandedEffect | undefined;
21
+ get playerHelper(): PlayerHelper;
22
+ removeFirstEffect(): void;
23
+ applyFirstEffect(): import("@gamepark/rules-api").StartRule<RuleId>[];
24
+ afterEffectPlayed(): MaterialMove[];
25
+ get opponentTeam(): TeamColor;
26
+ removeCondition(extraData?: Record<string, unknown>): void;
27
+ }
@@ -0,0 +1,161 @@
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 __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __read = (this && this.__read) || function (o, n) {
29
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
30
+ if (!m) return o;
31
+ var i = m.call(o), r, ar = [], e;
32
+ try {
33
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
34
+ }
35
+ catch (error) { e = { error: error }; }
36
+ finally {
37
+ try {
38
+ if (r && !r.done && (m = i["return"])) m.call(i);
39
+ }
40
+ finally { if (e) throw e.error; }
41
+ }
42
+ return ar;
43
+ };
44
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
46
+ if (ar || !(i in from)) {
47
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
48
+ ar[i] = from[i];
49
+ }
50
+ }
51
+ return to.concat(ar || Array.prototype.slice.call(from));
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.EffectRule = void 0;
55
+ var rules_api_1 = require("@gamepark/rules-api");
56
+ var Credit_1 = require("../../material/Credit");
57
+ var MaterialType_1 = require("../../material/MaterialType");
58
+ var TeamColor_1 = require("../../TeamColor");
59
+ var EffectHelper_1 = require("../helper/EffectHelper");
60
+ var EffectRuleIds_1 = require("../helper/EffectRuleIds");
61
+ var PlayerHelper_1 = require("../helper/PlayerHelper");
62
+ var Memory_1 = require("../Memory");
63
+ var RuleId_1 = require("../RuleId");
64
+ var EffectRule = (function (_super) {
65
+ __extends(EffectRule, _super);
66
+ function EffectRule(game, effect) {
67
+ var _this = _super.call(this, game) || this;
68
+ _this.effect = (effect !== null && effect !== void 0 ? effect : _this.firstEffect);
69
+ return _this;
70
+ }
71
+ EffectRule.prototype.onRuleStart = function (_move, _previousRule, _context) {
72
+ if (!this.isPossible()) {
73
+ this.removeFirstEffect();
74
+ return this.afterEffectPlayed();
75
+ }
76
+ return [];
77
+ };
78
+ EffectRule.prototype.getAutomaticEffectMoves = function () {
79
+ return [];
80
+ };
81
+ EffectRule.prototype.isPossible = function () {
82
+ return true;
83
+ };
84
+ Object.defineProperty(EffectRule.prototype, "creditMoney", {
85
+ get: function () {
86
+ return this.material(MaterialType_1.MaterialType.CreditToken).money(Credit_1.credits);
87
+ },
88
+ enumerable: false,
89
+ configurable: true
90
+ });
91
+ EffectRule.prototype.setExtraData = function (_extraData) { };
92
+ EffectRule.prototype.decrement = function (_move) {
93
+ return true;
94
+ };
95
+ EffectRule.prototype.getExtraDataFromMove = function (_move) {
96
+ return {
97
+ quantity: 1
98
+ };
99
+ };
100
+ Object.defineProperty(EffectRule.prototype, "effects", {
101
+ get: function () {
102
+ return this.remind(Memory_1.Memory.Effects);
103
+ },
104
+ enumerable: false,
105
+ configurable: true
106
+ });
107
+ Object.defineProperty(EffectRule.prototype, "firstEffect", {
108
+ get: function () {
109
+ return this.effects[0];
110
+ },
111
+ enumerable: false,
112
+ configurable: true
113
+ });
114
+ Object.defineProperty(EffectRule.prototype, "playerHelper", {
115
+ get: function () {
116
+ return new PlayerHelper_1.PlayerHelper(this.game, this.player);
117
+ },
118
+ enumerable: false,
119
+ configurable: true
120
+ });
121
+ EffectRule.prototype.removeFirstEffect = function () {
122
+ this.memorize(Memory_1.Memory.Effects, function (effects) {
123
+ effects.shift();
124
+ return effects;
125
+ });
126
+ };
127
+ EffectRule.prototype.applyFirstEffect = function () {
128
+ var effect = this.firstEffect;
129
+ if (!effect) {
130
+ return [];
131
+ }
132
+ return [this.startRule(EffectRuleIds_1.EffectRuleIds[effect.type])];
133
+ };
134
+ EffectRule.prototype.afterEffectPlayed = function () {
135
+ var moves = this.applyFirstEffect();
136
+ if (!moves.some(function (move) { return (0, rules_api_1.isStartRule)(move) || (0, rules_api_1.isStartPlayerTurn)(move); }) && !this.effects.length) {
137
+ moves.push(this.startRule(RuleId_1.RuleId.Refill));
138
+ }
139
+ return moves;
140
+ };
141
+ Object.defineProperty(EffectRule.prototype, "opponentTeam", {
142
+ get: function () {
143
+ return this.playerHelper.team === TeamColor_1.TeamColor.White ? TeamColor_1.TeamColor.Black : TeamColor_1.TeamColor.White;
144
+ },
145
+ enumerable: false,
146
+ configurable: true
147
+ });
148
+ EffectRule.prototype.removeCondition = function (extraData) {
149
+ var _this = this;
150
+ this.memorize(Memory_1.Memory.Effects, function (effects) {
151
+ var firstEffect = effects[0];
152
+ var effect = firstEffect.effect;
153
+ if (extraData) {
154
+ (0, EffectHelper_1.getEffectRule)(_this.game, effect).setExtraData(extraData);
155
+ }
156
+ return __spreadArray([__assign(__assign({}, effect), { effectSource: firstEffect.effectSource })], __read(effects.slice(1)), false);
157
+ });
158
+ };
159
+ return EffectRule;
160
+ }(rules_api_1.PlayerTurnRule));
161
+ exports.EffectRule = EffectRule;
@@ -0,0 +1,22 @@
1
+ import { ItemMove, MaterialMove } from '@gamepark/rules-api';
2
+ import { ExileEffect } from '../../material/effect/Effect';
3
+ import { EffectRule } from './index';
4
+ export declare class ExileRule extends EffectRule<ExileEffect> {
5
+ isPossible(): boolean;
6
+ getPlayerMoves(): MaterialMove[];
7
+ decrement(move: ItemMove): boolean;
8
+ afterItemMove(move: ItemMove): MaterialMove[];
9
+ getExtraDataFromMove(move: ItemMove): {
10
+ quantity: number;
11
+ influence: import("../../material/Influence").Influence;
12
+ } | {
13
+ quantity: number;
14
+ influence?: undefined;
15
+ } | {
16
+ quantity?: undefined;
17
+ influence?: undefined;
18
+ };
19
+ exileOneCard(): import("@gamepark/rules-api").MoveItem<number, number, number>[];
20
+ exileMultipleCards(): MaterialMove[];
21
+ get cards(): import("@gamepark/rules-api").Material<number, number, number>;
22
+ }