@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,161 +1,83 @@
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
- }
1
+ import { isStartPlayerTurn, isStartRule, PlayerTurnRule } from '@gamepark/rules-api';
2
+ import { credits } from '../../material/Credit';
3
+ import { MaterialType } from '../../material/MaterialType';
4
+ import { TeamColor } from '../../TeamColor';
5
+ import { getEffectRule } from '../helper/EffectHelper';
6
+ import { EffectRuleIds } from '../helper/EffectRuleIds';
7
+ import { PlayerHelper } from '../helper/PlayerHelper';
8
+ import { Memory } from '../Memory';
9
+ import { RuleId } from '../RuleId';
10
+ export class EffectRule extends PlayerTurnRule {
11
+ effect;
12
+ constructor(game, effect) {
13
+ super(game);
14
+ this.effect = (effect ?? this.firstEffect);
50
15
  }
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) {
16
+ onRuleStart(_move, _previousRule, _context) {
72
17
  if (!this.isPossible()) {
73
18
  this.removeFirstEffect();
74
19
  return this.afterEffectPlayed();
75
20
  }
76
21
  return [];
77
- };
78
- EffectRule.prototype.getAutomaticEffectMoves = function () {
22
+ }
23
+ getAutomaticEffectMoves() {
79
24
  return [];
80
- };
81
- EffectRule.prototype.isPossible = function () {
25
+ }
26
+ isPossible() {
82
27
  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) {
28
+ }
29
+ get creditMoney() {
30
+ return this.material(MaterialType.CreditToken).money(credits);
31
+ }
32
+ setExtraData(_extraData) { }
33
+ decrement(_move) {
93
34
  return true;
94
- };
95
- EffectRule.prototype.getExtraDataFromMove = function (_move) {
35
+ }
36
+ getExtraDataFromMove(_move) {
96
37
  return {
97
38
  quantity: 1
98
39
  };
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) {
40
+ }
41
+ get effects() {
42
+ return this.remind(Memory.Effects);
43
+ }
44
+ get firstEffect() {
45
+ return this.effects[0];
46
+ }
47
+ get playerHelper() {
48
+ return new PlayerHelper(this.game, this.player);
49
+ }
50
+ removeFirstEffect() {
51
+ this.memorize(Memory.Effects, (effects) => {
123
52
  effects.shift();
124
53
  return effects;
125
54
  });
126
- };
127
- EffectRule.prototype.applyFirstEffect = function () {
128
- var effect = this.firstEffect;
55
+ }
56
+ applyFirstEffect() {
57
+ const effect = this.firstEffect;
129
58
  if (!effect) {
130
59
  return [];
131
60
  }
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));
61
+ return [this.startRule(EffectRuleIds[effect.type])];
62
+ }
63
+ afterEffectPlayed() {
64
+ const moves = this.applyFirstEffect();
65
+ if (!moves.some((move) => isStartRule(move) || isStartPlayerTurn(move)) && !this.effects.length) {
66
+ moves.push(this.startRule(RuleId.Refill));
138
67
  }
139
68
  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;
69
+ }
70
+ get opponentTeam() {
71
+ return this.playerHelper.team === TeamColor.White ? TeamColor.Black : TeamColor.White;
72
+ }
73
+ removeCondition(extraData) {
74
+ this.memorize(Memory.Effects, (effects) => {
75
+ const firstEffect = effects[0];
76
+ const { effect } = firstEffect;
153
77
  if (extraData) {
154
- (0, EffectHelper_1.getEffectRule)(_this.game, effect).setExtraData(extraData);
78
+ getEffectRule(this.game, effect).setExtraData(extraData);
155
79
  }
156
- return __spreadArray([__assign(__assign({}, effect), { effectSource: firstEffect.effectSource })], __read(effects.slice(1)), false);
80
+ return [{ ...effect, effectSource: firstEffect.effectSource }, ...effects.slice(1)];
157
81
  });
158
- };
159
- return EffectRule;
160
- }(rules_api_1.PlayerTurnRule));
161
- exports.EffectRule = EffectRule;
82
+ }
83
+ }
@@ -1,93 +1,34 @@
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 __values = (this && this.__values) || function(o) {
18
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
19
- if (m) return m.call(o);
20
- if (o && typeof o.length === "number") return {
21
- next: function () {
22
- if (o && i >= o.length) o = void 0;
23
- return { value: o && o[i++], done: !o };
24
- }
25
- };
26
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
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.ExileRule = void 0;
55
- var rules_api_1 = require("@gamepark/rules-api");
56
- var Agents_1 = require("../../material/Agents");
57
- var EffectType_1 = require("../../material/effect/EffectType");
58
- var Influence_1 = require("../../material/Influence");
59
- var LocationType_1 = require("../../material/LocationType");
60
- var MaterialType_1 = require("../../material/MaterialType");
61
- var index_1 = require("./index");
62
- var ExileRule = (function (_super) {
63
- __extends(ExileRule, _super);
64
- function ExileRule() {
65
- return _super !== null && _super.apply(this, arguments) || this;
66
- }
67
- ExileRule.prototype.isPossible = function () {
68
- var _a, _b;
69
- if (((_a = this.firstEffect) === null || _a === void 0 ? void 0 : _a.type) === EffectType_1.EffectType.Conditional && !this.effect.quantities) {
70
- return this.getPlayerMoves().length >= ((_b = this.effect.quantity) !== null && _b !== void 0 ? _b : 1);
1
+ import { isMoveItemType, isMoveItemTypeAtOnce } from '@gamepark/rules-api';
2
+ import { Agents } from '../../material/Agents';
3
+ import { EffectType } from '../../material/effect/EffectType';
4
+ import { influences } from '../../material/Influence';
5
+ import { LocationType } from '../../material/LocationType';
6
+ import { MaterialType } from '../../material/MaterialType';
7
+ import { EffectRule } from './index';
8
+ export class ExileRule extends EffectRule {
9
+ isPossible() {
10
+ if (this.firstEffect?.type === EffectType.Conditional && !this.effect.quantities) {
11
+ return this.getPlayerMoves().length >= (this.effect.quantity ?? 1);
71
12
  }
72
13
  return this.getPlayerMoves().length > 0;
73
- };
74
- ExileRule.prototype.getPlayerMoves = function () {
14
+ }
15
+ getPlayerMoves() {
75
16
  if (this.effect.quantities) {
76
17
  return this.exileMultipleCards();
77
18
  }
78
19
  return this.exileOneCard();
79
- };
80
- ExileRule.prototype.decrement = function (move) {
81
- if ((0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.AgentCard)(move) && move.location.type === LocationType_1.LocationType.AgentDiscard) {
20
+ }
21
+ decrement(move) {
22
+ if (isMoveItemType(MaterialType.AgentCard)(move) && move.location.type === LocationType.AgentDiscard) {
82
23
  if (this.effect.quantity) {
83
24
  this.effect.quantity--;
84
25
  return this.effect.quantity === 0 || !this.isPossible();
85
26
  }
86
27
  }
87
28
  return true;
88
- };
89
- ExileRule.prototype.afterItemMove = function (move) {
90
- if ((0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.AgentCard)(move) && move.location.type === LocationType_1.LocationType.AgentDiscard) {
29
+ }
30
+ afterItemMove(move) {
31
+ if (isMoveItemType(MaterialType.AgentCard)(move) && move.location.type === LocationType.AgentDiscard) {
91
32
  if (this.effect.quantity) {
92
33
  this.effect.quantity--;
93
34
  }
@@ -97,86 +38,60 @@ var ExileRule = (function (_super) {
97
38
  }
98
39
  }
99
40
  return [];
100
- };
101
- ExileRule.prototype.getExtraDataFromMove = function (move) {
102
- if ((0, rules_api_1.isMoveItemType)(MaterialType_1.MaterialType.AgentCard)(move) && move.location.type === LocationType_1.LocationType.AgentDiscard) {
103
- var card = this.material(MaterialType_1.MaterialType.AgentCard).getItem(move.itemIndex);
104
- var agent = Agents_1.Agents[card.id];
41
+ }
42
+ getExtraDataFromMove(move) {
43
+ if (isMoveItemType(MaterialType.AgentCard)(move) && move.location.type === LocationType.AgentDiscard) {
44
+ const card = this.material(MaterialType.AgentCard).getItem(move.itemIndex);
45
+ const agent = Agents[card.id];
105
46
  return { quantity: agent.cost, influence: agent.influence };
106
47
  }
107
- if ((0, rules_api_1.isMoveItemTypeAtOnce)(MaterialType_1.MaterialType.AgentCard)(move) && move.location.type === LocationType_1.LocationType.AgentDiscard) {
48
+ if (isMoveItemTypeAtOnce(MaterialType.AgentCard)(move) && move.location.type === LocationType.AgentDiscard) {
108
49
  if (this.effect.quantities && this.effect.factors) {
109
- var index = this.effect.quantities.indexOf(move.indexes.length);
50
+ const index = this.effect.quantities.indexOf(move.indexes.length);
110
51
  return { quantity: this.effect.factors[index] };
111
52
  }
112
53
  }
113
54
  return {};
114
- };
115
- ExileRule.prototype.exileOneCard = function () {
116
- var e_1, _a;
117
- var allInfluences = Influence_1.influences;
118
- var allCards = this.cards;
119
- var indexes = [];
120
- try {
121
- for (var allInfluences_1 = __values(allInfluences), allInfluences_1_1 = allInfluences_1.next(); !allInfluences_1_1.done; allInfluences_1_1 = allInfluences_1.next()) {
122
- var influence = allInfluences_1_1.value;
123
- var influenceCards = allCards.locationId(influence);
124
- indexes.push.apply(indexes, __spreadArray([], __read(influenceCards.maxBy(function (item) { return item.location.x; }).getIndexes()), false));
125
- }
126
- }
127
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
128
- finally {
129
- try {
130
- if (allInfluences_1_1 && !allInfluences_1_1.done && (_a = allInfluences_1.return)) _a.call(allInfluences_1);
131
- }
132
- finally { if (e_1) throw e_1.error; }
55
+ }
56
+ exileOneCard() {
57
+ const allInfluences = influences;
58
+ const allCards = this.cards;
59
+ const indexes = [];
60
+ for (const influence of allInfluences) {
61
+ const influenceCards = allCards.locationId(influence);
62
+ indexes.push(...influenceCards.maxBy((item) => item.location.x).getIndexes());
133
63
  }
134
64
  return allCards.index(indexes).moveItems({
135
- type: LocationType_1.LocationType.AgentDiscard
65
+ type: LocationType.AgentDiscard
136
66
  });
137
- };
138
- ExileRule.prototype.exileMultipleCards = function () {
139
- var e_2, _a;
67
+ }
68
+ exileMultipleCards() {
140
69
  if (!this.effect.quantities)
141
70
  return [];
142
- var allCards = this.cards;
143
- var moves = [];
144
- try {
145
- for (var _b = __values(this.effect.quantities), _c = _b.next(); !_c.done; _c = _b.next()) {
146
- var quantity = _c.value;
147
- if (allCards.length < quantity)
148
- continue;
149
- moves.push(allCards.limit(quantity).moveItemsAtOnce({ type: LocationType_1.LocationType.AgentDiscard }));
150
- }
151
- }
152
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
153
- finally {
154
- try {
155
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
156
- }
157
- finally { if (e_2) throw e_2.error; }
71
+ const allCards = this.cards;
72
+ const moves = [];
73
+ for (const quantity of this.effect.quantities) {
74
+ if (allCards.length < quantity)
75
+ continue;
76
+ moves.push(allCards
77
+ .limit(quantity)
78
+ .sort((item) => item.location.x)
79
+ .moveItemsAtOnce({ type: LocationType.AgentDiscard }));
158
80
  }
159
81
  return moves;
160
- };
161
- Object.defineProperty(ExileRule.prototype, "cards", {
162
- get: function () {
163
- var _this = this;
164
- var team = this.effect.opponent ? this.opponentTeam : this.playerHelper.team;
165
- return this.material(MaterialType_1.MaterialType.AgentCard)
166
- .location(LocationType_1.LocationType.Influence)
167
- .filter(function (item) {
168
- if (_this.effect.except && _this.effect.except === item.location.id)
169
- return false;
170
- if (_this.effect.influence && _this.effect.influence !== item.location.id)
171
- return false;
172
- return true;
173
- })
174
- .player(team)
175
- .sort(function (item) { return -item.location.x; });
176
- },
177
- enumerable: false,
178
- configurable: true
179
- });
180
- return ExileRule;
181
- }(index_1.EffectRule));
182
- exports.ExileRule = ExileRule;
82
+ }
83
+ get cards() {
84
+ const team = this.effect.opponent ? this.opponentTeam : this.playerHelper.team;
85
+ return this.material(MaterialType.AgentCard)
86
+ .location(LocationType.Influence)
87
+ .filter((item) => {
88
+ if (this.effect.except && this.effect.except === item.location.id)
89
+ return false;
90
+ if (this.effect.influence && this.effect.influence !== item.location.id)
91
+ return false;
92
+ return true;
93
+ })
94
+ .player(team)
95
+ .sort((item) => -item.location.x);
96
+ }
97
+ }
@@ -1,79 +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
- 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.GiveCreditRule = void 0;
44
- var rules_api_1 = require("@gamepark/rules-api");
45
- var LocationType_1 = require("../../material/LocationType");
46
- var CustomMoveType_1 = require("../CustomMoveType");
47
- var Memory_1 = require("../Memory");
48
- var index_1 = require("./index");
49
- var GiveCreditRule = (function (_super) {
50
- __extends(GiveCreditRule, _super);
51
- function GiveCreditRule() {
52
- return _super !== null && _super.apply(this, arguments) || this;
53
- }
54
- GiveCreditRule.prototype.onRuleStart = function () {
55
- var moves = [];
56
- var money = this.creditMoney;
57
- this.memorize(Memory_1.Memory.CurrentEffect, JSON.parse(JSON.stringify(this.effect)));
58
- this.memorize(Memory_1.Memory.Credit, this.effect.quantity);
59
- moves.push.apply(moves, __spreadArray([], __read(money.moveMoney({ type: LocationType_1.LocationType.TeamCredit, player: this.playerHelper.team }, { type: LocationType_1.LocationType.TeamCredit, player: this.opponentTeam }, this.effect.quantity)), false));
1
+ import { isCustomMoveType } from '@gamepark/rules-api';
2
+ import { LocationType } from '../../material/LocationType';
3
+ import { CustomMoveType } from '../CustomMoveType';
4
+ import { Memory } from '../Memory';
5
+ import { EffectRule } from './index';
6
+ export class GiveCreditRule extends EffectRule {
7
+ onRuleStart() {
8
+ const moves = [];
9
+ const money = this.creditMoney;
10
+ this.memorize(Memory.CurrentEffect, JSON.parse(JSON.stringify(this.effect)));
11
+ this.memorize(Memory.Credit, this.effect.quantity);
12
+ moves.push(...money.moveMoney({ type: LocationType.TeamCredit, player: this.playerHelper.team }, { type: LocationType.TeamCredit, player: this.opponentTeam }, this.effect.quantity));
60
13
  this.removeFirstEffect();
61
- moves.push.apply(moves, __spreadArray([], __read(this.afterEffectPlayed()), false));
14
+ moves.push(...this.afterEffectPlayed());
62
15
  return moves;
63
- };
64
- GiveCreditRule.prototype.getExtraDataFromMove = function (move) {
65
- if (!(0, rules_api_1.isCustomMoveType)(CustomMoveType_1.CustomMoveType.DoCondition)(move))
16
+ }
17
+ getExtraDataFromMove(move) {
18
+ if (!isCustomMoveType(CustomMoveType.DoCondition)(move))
66
19
  return {};
67
20
  return { quantity: move.data };
68
- };
69
- GiveCreditRule.prototype.isPossible = function () {
21
+ }
22
+ isPossible() {
70
23
  return this.playerHelper.credits >= this.effect.quantity;
71
- };
72
- GiveCreditRule.prototype.onRuleEnd = function () {
73
- this.forget(Memory_1.Memory.CurrentEffect);
74
- this.forget(Memory_1.Memory.Credit);
24
+ }
25
+ onRuleEnd() {
26
+ this.forget(Memory.CurrentEffect);
27
+ this.forget(Memory.Credit);
75
28
  return [];
76
- };
77
- return GiveCreditRule;
78
- }(index_1.EffectRule));
79
- exports.GiveCreditRule = GiveCreditRule;
29
+ }
30
+ }