@gamepark/zenith 0.0.1 → 0.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.
Files changed (63) hide show
  1. package/dist/PlayerId.js +1 -2
  2. package/dist/TeamColor.js +7 -13
  3. package/dist/ZenithOptions.js +1 -4
  4. package/dist/ZenithRules.js +71 -122
  5. package/dist/ZenithSetup.js +123 -266
  6. package/dist/index.js +3 -9
  7. package/dist/material/Agent.js +4 -7
  8. package/dist/material/Agents.js +920 -923
  9. package/dist/material/Bonus.js +5 -8
  10. package/dist/material/Bonuses.js +29 -33
  11. package/dist/material/Credit.js +4 -7
  12. package/dist/material/Faction.js +4 -7
  13. package/dist/material/Influence.js +4 -7
  14. package/dist/material/LocationType.js +2 -5
  15. package/dist/material/MaterialType.js +2 -5
  16. package/dist/material/effect/Effect.js +5 -10
  17. package/dist/material/effect/EffectType.js +2 -5
  18. package/dist/rules/CustomMoveType.js +2 -5
  19. package/dist/rules/DiscardActionRule.js +26 -75
  20. package/dist/rules/Memory.js +2 -5
  21. package/dist/rules/MulliganRule.js +47 -126
  22. package/dist/rules/PlayCardRule.js +68 -134
  23. package/dist/rules/RefillRule.js +83 -190
  24. package/dist/rules/RuleId.js +2 -5
  25. package/dist/rules/discard-action/DiplomacyActions.js +15 -20
  26. package/dist/rules/discard-action/DiplomacyBoardRule.js +27 -64
  27. package/dist/rules/discard-action/TechnologyActions.js +44 -48
  28. package/dist/rules/discard-action/TechnologyBoardRule.js +34 -102
  29. package/dist/rules/effect/ChoiceRule.js +21 -81
  30. package/dist/rules/effect/ConditionalRule.js +77 -141
  31. package/dist/rules/effect/DevelopTechnologyRule.js +53 -119
  32. package/dist/rules/effect/DiscardRule.js +37 -90
  33. package/dist/rules/effect/EffectRule.js +60 -138
  34. package/dist/rules/effect/ExileRule.js +62 -147
  35. package/dist/rules/effect/GiveCreditRule.js +24 -73
  36. package/dist/rules/effect/GiveInfluenceRule.js +38 -101
  37. package/dist/rules/effect/GiveLeaderBadgeRule.js +18 -46
  38. package/dist/rules/effect/GiveZenithiumRule.js +25 -79
  39. package/dist/rules/effect/MobilizeRule.js +38 -93
  40. package/dist/rules/effect/ResetInfluenceRule.js +21 -58
  41. package/dist/rules/effect/SpendCreditRule.js +29 -102
  42. package/dist/rules/effect/SpendZenithiumRule.js +32 -109
  43. package/dist/rules/effect/StealCreditRule.js +15 -64
  44. package/dist/rules/effect/TakeBonusRule.js +30 -91
  45. package/dist/rules/effect/TakeLeaderBadgeRule.js +31 -88
  46. package/dist/rules/effect/TakeTechnologyBonusTokenRule.js +45 -112
  47. package/dist/rules/effect/TransferRule.js +47 -81
  48. package/dist/rules/effect/WinCreditRule.js +60 -130
  49. package/dist/rules/effect/WinInfluenceRule.js +128 -248
  50. package/dist/rules/effect/WinZenithiumRule.js +24 -80
  51. package/dist/rules/effect/index.js +19 -35
  52. package/dist/rules/helper/BonusHelper.js +32 -64
  53. package/dist/rules/helper/CreditHelper.js +19 -44
  54. package/dist/rules/helper/EffectHelper.js +81 -123
  55. package/dist/rules/helper/EffectRuleIds.js +25 -29
  56. package/dist/rules/helper/EndGameHelper.js +24 -57
  57. package/dist/rules/helper/InfluenceHelper.js +18 -44
  58. package/dist/rules/helper/MobilizeHelper.js +27 -53
  59. package/dist/rules/helper/PlanetHelper.js +45 -78
  60. package/dist/rules/helper/PlayerHelper.js +24 -60
  61. package/dist/rules/helper/TechnologyHelper.js +31 -87
  62. package/dist/rules/helper/ZenithiumHelper.js +25 -48
  63. package/package.json +4 -3
@@ -1,76 +1,18 @@
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);
1
+ import { isCustomMoveType } from '@gamepark/rules-api';
2
+ import { ConditionType } from '../../material/effect/Effect';
3
+ import { EffectType } from '../../material/effect/EffectType';
4
+ import { CustomMoveType } from '../CustomMoveType';
5
+ import { getEffectRule } from '../helper/EffectHelper';
6
+ import { Memory } from '../Memory';
7
+ import { EffectRule } from './index';
8
+ export class ConditionalRule extends EffectRule {
9
+ onRuleStart() {
10
+ const condition = this.effect.condition;
11
+ const moves = super.onRuleStart();
70
12
  if (moves.length > 0)
71
13
  return moves;
72
14
  if (this.isDoCondition(condition) && this.effect.mandatory) {
73
- moves.push.apply(moves, __spreadArray([], __read((0, EffectHelper_1.getEffectRule)(this.game, condition.effect).getAutomaticEffectMoves()), false));
15
+ moves.push(...getEffectRule(this.game, condition.effect).getAutomaticEffectMoves());
74
16
  return moves;
75
17
  }
76
18
  if (this.isLeaderCondition(condition) || this.isHaveCreditCondition(condition)) {
@@ -78,93 +20,89 @@ var ConditionalRule = (function (_super) {
78
20
  return this.afterEffectPlayed();
79
21
  }
80
22
  return [];
81
- };
82
- ConditionalRule.prototype.getPlayerMoves = function () {
83
- var condition = this.effect.condition;
23
+ }
24
+ getPlayerMoves() {
25
+ const condition = this.effect.condition;
84
26
  if (this.isDoCondition(condition)) {
85
27
  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));
28
+ const moves = [];
29
+ if (!this.effect.mandatory && !this.remind(Memory.CantPass))
30
+ moves.push(this.customMove(CustomMoveType.Pass));
31
+ moves.push(...getEffectRule(this.game, condition.effect).getPlayerMoves());
90
32
  return moves;
91
33
  }
92
- return [this.customMove(CustomMoveType_1.CustomMoveType.Pass), this.customMove(CustomMoveType_1.CustomMoveType.DoCondition)];
34
+ return [this.customMove(CustomMoveType.Pass), this.customMove(CustomMoveType.DoCondition)];
93
35
  }
94
36
  return [];
95
- };
96
- ConditionalRule.prototype.onCustomMove = function (move) {
97
- if ((0, rules_api_1.isCustomMoveType)(CustomMoveType_1.CustomMoveType.Pass)(move)) {
37
+ }
38
+ onCustomMove(move) {
39
+ if (isCustomMoveType(CustomMoveType.Pass)(move)) {
98
40
  this.removeFirstEffect();
99
41
  return this.afterEffectPlayed();
100
42
  }
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))
43
+ if (isCustomMoveType(CustomMoveType.DoCondition)(move)) {
44
+ const condition = this.effect.condition;
45
+ if (!this.isDoCondition(condition))
104
46
  return [];
105
- var conditionEffect = (0, EffectHelper_1.getEffectRule)(this.game, condition_1.effect);
106
- var extraData = conditionEffect.getExtraDataFromMove(move);
47
+ const conditionEffect = getEffectRule(this.game, condition.effect);
48
+ const extraData = conditionEffect.getExtraDataFromMove(move);
107
49
  this.addEffectAndRemoveCondition(extraData);
108
50
  return this.afterEffectPlayed();
109
51
  }
110
52
  this.onEffectPlayed(move);
111
- var condition = this.effect.condition;
53
+ const condition = this.effect.condition;
112
54
  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));
55
+ const moves = getEffectRule(this.game, condition.effect).onCustomMove(move);
56
+ moves.push(...this.afterEffectPlayed());
115
57
  return moves;
116
58
  }
117
59
  return [];
118
- };
119
- ConditionalRule.prototype.afterItemMove = function (move) {
120
- var done = this.onEffectPlayed(move);
60
+ }
61
+ afterItemMove(move) {
62
+ const done = this.onEffectPlayed(move);
121
63
  if (done) {
122
64
  return this.afterEffectPlayed();
123
65
  }
124
66
  return [];
125
- };
126
- ConditionalRule.prototype.onEffectPlayed = function (move) {
127
- var condition = this.effect.condition;
67
+ }
68
+ onEffectPlayed(move) {
69
+ const condition = this.effect.condition;
128
70
  if (this.isDoCondition(condition)) {
129
71
  if (this.isAutomaticEffect)
130
72
  return;
131
- var conditionEffect = (0, EffectHelper_1.getEffectRule)(this.game, condition.effect);
132
- var done = conditionEffect.decrement(move);
73
+ const conditionEffect = getEffectRule(this.game, condition.effect);
74
+ const done = conditionEffect.decrement(move);
133
75
  if (done) {
134
- var extraData = conditionEffect.getExtraDataFromMove(move);
76
+ const extraData = conditionEffect.getExtraDataFromMove(move);
135
77
  this.removeCondition(extraData);
136
78
  }
137
79
  else {
138
- this.memorize(Memory_1.Memory.CantPass, true);
80
+ this.memorize(Memory.CantPass, true);
139
81
  }
140
82
  return done;
141
83
  }
142
84
  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;
85
+ }
86
+ get isAutomaticEffect() {
87
+ const condition = this.effect.condition;
88
+ if (!this.isDoCondition(condition))
89
+ return false;
90
+ return condition.effect.type === EffectType.GiveCredit || condition.effect.type === EffectType.GiveZenithium;
91
+ }
92
+ isDoCondition(condition) {
93
+ return condition.type === ConditionType.DoEffect;
94
+ }
95
+ isLeaderCondition(condition) {
96
+ return condition.type === ConditionType.Leader;
97
+ }
98
+ isHaveCreditCondition(condition) {
99
+ return condition.type === ConditionType.HaveCredits;
100
+ }
101
+ isPossible() {
102
+ const condition = this.effect.condition;
165
103
  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();
104
+ const conditionEffect = getEffectRule(this.game, condition.effect);
105
+ return conditionEffect.isPossible() && getEffectRule(this.game, this.effect.effect).isPossible();
168
106
  }
169
107
  if (this.isLeaderCondition(condition)) {
170
108
  return this.playerHelper.isLeader;
@@ -173,25 +111,23 @@ var ConditionalRule = (function (_super) {
173
111
  return this.playerHelper.credits >= condition.min;
174
112
  }
175
113
  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;
114
+ }
115
+ addEffectAndRemoveCondition(extraData) {
116
+ this.memorize(Memory.Effects, (effects) => {
117
+ const firstEffect = effects[0];
118
+ const { condition, effect } = firstEffect;
182
119
  if (extraData) {
183
- (0, EffectHelper_1.getEffectRule)(_this.game, effect).setExtraData(extraData);
120
+ getEffectRule(this.game, effect).setExtraData(extraData);
184
121
  }
185
- return __spreadArray([
186
- __assign(__assign({}, condition.effect), { effectSource: firstEffect.effectSource }),
187
- __assign(__assign({}, effect), { effectSource: firstEffect.effectSource })
188
- ], __read(effects.slice(1)), false);
122
+ return [
123
+ { ...condition.effect, effectSource: firstEffect.effectSource },
124
+ { ...effect, effectSource: firstEffect.effectSource },
125
+ ...effects.slice(1)
126
+ ];
189
127
  });
190
- };
191
- ConditionalRule.prototype.onRuleEnd = function () {
192
- this.forget(Memory_1.Memory.CantPass);
128
+ }
129
+ onRuleEnd() {
130
+ this.forget(Memory.CantPass);
193
131
  return [];
194
- };
195
- return ConditionalRule;
196
- }(index_1.EffectRule));
197
- exports.ConditionalRule = ConditionalRule;
132
+ }
133
+ }
@@ -1,133 +1,67 @@
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;
1
+ import { isCustomMoveType, isMoveItemType } from '@gamepark/rules-api';
2
+ import { LocationType } from '../../material/LocationType';
3
+ import { MaterialType } from '../../material/MaterialType';
4
+ import { CustomMoveType } from '../CustomMoveType';
5
+ import { TechnologyHelper } from '../helper/TechnologyHelper';
6
+ import { EffectRule } from './index';
7
+ export class DevelopTechnologyRule extends EffectRule {
8
+ getPlayerMoves() {
9
+ return [
10
+ ...this.technologies.moveItems((item) => ({
11
+ ...item.location,
12
+ x: item.location.x + 1
13
+ })),
14
+ this.customMove(CustomMoveType.Pass)
15
+ ];
65
16
  }
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))
17
+ afterItemMove(move) {
18
+ if (!isMoveItemType(MaterialType.TechMarker)(move))
74
19
  return [];
75
- var moves = [];
20
+ const moves = [];
76
21
  if (!this.effect.free) {
77
- var cost = move.location.x - ((_a = this.effect.discount) !== null && _a !== void 0 ? _a : 0);
22
+ const cost = move.location.x - (this.effect.discount ?? 0);
78
23
  if (cost) {
79
24
  moves.push(this.playerHelper.zenithiumMaterial.deleteItem(cost));
80
25
  }
81
26
  }
82
- moves.push.apply(moves, __spreadArray([], __read(new TechnologyHelper_1.TechnologyHelper(this.game).applyTechnology(move)), false));
27
+ moves.push(...new TechnologyHelper(this.game).applyTechnology(move));
83
28
  this.removeFirstEffect();
84
- moves.push.apply(moves, __spreadArray([], __read(this.afterEffectPlayed()), false));
29
+ moves.push(...this.afterEffectPlayed());
85
30
  return moves;
86
- };
87
- DevelopTechnologyRule.prototype.onCustomMove = function (move) {
88
- if (!(0, rules_api_1.isCustomMoveType)(CustomMoveType_1.CustomMoveType.Pass)(move))
31
+ }
32
+ onCustomMove(move) {
33
+ if (!isCustomMoveType(CustomMoveType.Pass)(move))
89
34
  return [];
90
35
  this.removeFirstEffect();
91
36
  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
- }
37
+ }
38
+ get technologies() {
39
+ const zenithium = this.playerHelper.zenithium;
40
+ const techBoard = this.material(MaterialType.TechnologyBoard)
41
+ .locationId((id) => id === (this.effect.faction ?? id))
42
+ .getIndexes();
43
+ const tokens = this.technologyTokens.parent((p) => techBoard.includes(p));
44
+ if (!tokens.length)
113
45
  return tokens;
114
- },
115
- enumerable: false,
116
- configurable: true
117
- });
118
- DevelopTechnologyRule.prototype.isPossible = function () {
46
+ if (this.effect.free && this.effect.lowest) {
47
+ const lowestX = tokens.minBy((item) => item.location.x).getItem().location.x;
48
+ return tokens.filter((item) => item.location.x === lowestX);
49
+ }
50
+ const discount = this.effect.discount;
51
+ if (discount !== undefined) {
52
+ return tokens.filter((item) => {
53
+ return item.location.x + 1 - discount <= zenithium;
54
+ });
55
+ }
56
+ return tokens;
57
+ }
58
+ isPossible() {
119
59
  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;
60
+ }
61
+ get technologyTokens() {
62
+ return this.material(MaterialType.TechMarker)
63
+ .location(LocationType.TechnologyBoardTokenSpace)
64
+ .player(this.playerHelper.team)
65
+ .location((l) => l.x < 5);
66
+ }
67
+ }
@@ -1,107 +1,54 @@
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);
1
+ import { isMoveItemType } from '@gamepark/rules-api';
2
+ import { Agents } from '../../material/Agents';
3
+ import { LocationType } from '../../material/LocationType';
4
+ import { MaterialType } from '../../material/MaterialType';
5
+ import { Memory } from '../Memory';
6
+ import { EffectRule } from './index';
7
+ export class DiscardRule extends EffectRule {
8
+ onRuleStart() {
9
+ const moves = super.onRuleStart();
57
10
  if (moves.length > 0)
58
11
  return moves;
59
- this.memorize(Memory_1.Memory.CurrentEffect, JSON.parse(JSON.stringify(this.effect)));
60
- var effect = this.effect;
12
+ this.memorize(Memory.CurrentEffect, JSON.parse(JSON.stringify(this.effect)));
13
+ const effect = this.effect;
61
14
  if (effect.full) {
62
15
  moves.push(this.hand.moveItemsAtOnce({
63
- type: LocationType_1.LocationType.AgentDiscard
16
+ type: LocationType.AgentDiscard
64
17
  }));
65
18
  this.removeFirstEffect();
66
- moves.push.apply(moves, __spreadArray([], __read(this.afterEffectPlayed()), false));
19
+ moves.push(...this.afterEffectPlayed());
67
20
  }
68
21
  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));
22
+ }
23
+ getPlayerMoves() {
24
+ const moves = [];
25
+ moves.push(...this.hand.moveItems({
26
+ type: LocationType.AgentDiscard
27
+ }));
75
28
  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];
29
+ }
30
+ getExtraDataFromMove(move) {
31
+ if (isMoveItemType(MaterialType.AgentCard)(move) && move.location.type === LocationType.AgentDiscard) {
32
+ const card = this.material(MaterialType.AgentCard).getItem(move.itemIndex);
33
+ const agent = Agents[card.id];
81
34
  return { quantity: agent.cost, influence: agent.influence };
82
35
  }
83
36
  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)
37
+ }
38
+ afterItemMove(move) {
39
+ if (!isMoveItemType(MaterialType.AgentCard)(move) || move.location.type !== LocationType.AgentDiscard)
87
40
  return [];
88
41
  this.removeFirstEffect();
89
42
  return this.afterEffectPlayed();
90
- };
91
- DiscardRule.prototype.isPossible = function () {
43
+ }
44
+ isPossible() {
92
45
  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);
46
+ }
47
+ get hand() {
48
+ return this.material(MaterialType.AgentCard).location(LocationType.PlayerHand).player(this.player);
49
+ }
50
+ onRuleEnd() {
51
+ this.forget(Memory.CurrentEffect);
103
52
  return [];
104
- };
105
- return DiscardRule;
106
- }(index_1.EffectRule));
107
- exports.DiscardRule = DiscardRule;
53
+ }
54
+ }