hrbattle 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,41 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __values = (this && this.__values) || function(o) {
13
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
14
+ if (m) return m.call(o);
15
+ if (o && typeof o.length === "number") return {
16
+ next: function () {
17
+ if (o && i >= o.length) o = void 0;
18
+ return { value: o && o[i++], done: !o };
19
+ }
20
+ };
21
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22
+ };
23
+ var __read = (this && this.__read) || function (o, n) {
24
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25
+ if (!m) return o;
26
+ var i = m.call(o), r, ar = [], e;
27
+ try {
28
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29
+ }
30
+ catch (error) { e = { error: error }; }
31
+ finally {
32
+ try {
33
+ if (r && !r.done && (m = i["return"])) m.call(i);
34
+ }
35
+ finally { if (e) throw e.error; }
36
+ }
37
+ return ar;
38
+ };
1
39
  import { BattleEventBus } from "./eventBus.js";
2
40
  import { EffectSystem } from "./effectSystem.js";
3
41
  import { BattleLogger } from "./logger.js";
@@ -5,103 +43,116 @@ import { SeedRng } from "./random.js";
5
43
  import { repression } from "./formula.js";
6
44
  import { ConfigSkillEngine, ScriptSkillEngine, SkillExecutor } from "./skillEngine.js";
7
45
  import { TurnBarSystem } from "./turnbar.js";
8
- export class BattleCore {
9
- initUnits;
10
- config;
11
- units;
12
- rng;
13
- eventBus = new BattleEventBus();
14
- turnBar = new TurnBarSystem();
15
- logger = new BattleLogger();
16
- effectSystem = new EffectSystem(this.eventBus);
17
- configSkillEngine = new ConfigSkillEngine();
18
- scriptSkillEngine = new ScriptSkillEngine();
19
- skillExecutor = new SkillExecutor(this.configSkillEngine, this.scriptSkillEngine);
20
- skillSlots = new Map();
21
- chasePredicates = [];
22
- chaseSkillResolvers = [];
23
- pendingImbalanceClear = new Set();
24
- pendingReactiveCounters = [];
25
- scriptPassivesInitialized = false;
26
- activeSkillContext = null;
27
- turn = 0;
28
- actionCount = 0;
29
- constructor(initUnits, config) {
46
+ var BattleCore = /** @class */ (function () {
47
+ function BattleCore(initUnits, config) {
48
+ var e_1, _a;
49
+ var _this = this;
30
50
  this.initUnits = initUnits;
31
51
  this.config = config;
52
+ this.eventBus = new BattleEventBus();
53
+ this.turnBar = new TurnBarSystem();
54
+ this.logger = new BattleLogger();
55
+ this.effectSystem = new EffectSystem(this.eventBus);
56
+ this.configSkillEngine = new ConfigSkillEngine();
57
+ this.scriptSkillEngine = new ScriptSkillEngine();
58
+ this.skillExecutor = new SkillExecutor(this.configSkillEngine, this.scriptSkillEngine);
59
+ this.skillSlots = new Map();
60
+ this.chasePredicates = [];
61
+ this.chaseSkillResolvers = [];
62
+ this.pendingImbalanceClear = new Set();
63
+ this.pendingReactiveCounters = [];
64
+ this.scriptPassivesInitialized = false;
65
+ this.activeSkillContext = null;
66
+ this.turn = 0;
67
+ this.actionCount = 0;
32
68
  this.rng = new SeedRng(config.seed);
33
- this.units = initUnits.map((u) => ({
69
+ this.units = initUnits.map(function (u) { return ({
34
70
  id: u.id,
35
71
  name: u.name,
36
72
  teamId: u.teamId,
37
73
  position: u.position,
38
74
  element: u.element,
39
- stats: { ...u.stats },
75
+ stats: __assign({}, u.stats),
40
76
  runtime: {
41
77
  Hp: u.stats.Mhp,
42
78
  AP: 0,
43
79
  Energy: 0,
44
- EnergyMax: this.maxUltimateCost(u.skills),
80
+ EnergyMax: _this.maxUltimateCost(u.skills),
45
81
  Shield: 0,
46
82
  Imbalance: 0,
47
83
  alive: true,
48
84
  stunned: false
49
85
  },
50
- skills: u.skills.map((s) => ({
86
+ skills: u.skills.map(function (s) { return ({
51
87
  id: s.id,
52
88
  type: s.type,
53
89
  cooldown: s.cooldown,
54
90
  energyCost: s.energyCost,
55
91
  energyGain: s.energyGain
56
- }))
57
- }));
58
- for (const unit of this.units) {
59
- this.skillSlots.set(unit.id, initUnits
60
- .find((u) => u.id === unit.id)
61
- .skills.map((d) => ({
92
+ }); })
93
+ }); });
94
+ var _loop_1 = function (unit) {
95
+ this_1.skillSlots.set(unit.id, initUnits
96
+ .find(function (u) { return u.id === unit.id; })
97
+ .skills.map(function (d) { return ({
62
98
  definition: d,
63
99
  cooldownRemain: 0
64
- })));
100
+ }); }));
101
+ };
102
+ var this_1 = this;
103
+ try {
104
+ for (var _b = __values(this.units), _c = _b.next(); !_c.done; _c = _b.next()) {
105
+ var unit = _c.value;
106
+ _loop_1(unit);
107
+ }
108
+ }
109
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
110
+ finally {
111
+ try {
112
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
113
+ }
114
+ finally { if (e_1) throw e_1.error; }
65
115
  }
66
116
  this.registerConfiguredChaseRules();
67
117
  this.registerReactiveCounterRules();
68
118
  }
69
- getEventBus() {
119
+ BattleCore.prototype.getEventBus = function () {
70
120
  return this.eventBus;
71
- }
72
- getLogger() {
121
+ };
122
+ BattleCore.prototype.getLogger = function () {
73
123
  return this.logger;
74
- }
75
- getEffectSystem() {
124
+ };
125
+ BattleCore.prototype.getEffectSystem = function () {
76
126
  return this.effectSystem;
77
- }
78
- getConfigSkillEngine() {
127
+ };
128
+ BattleCore.prototype.getConfigSkillEngine = function () {
79
129
  return this.configSkillEngine;
80
- }
81
- getScriptSkillEngine() {
130
+ };
131
+ BattleCore.prototype.getScriptSkillEngine = function () {
82
132
  return this.scriptSkillEngine;
83
- }
84
- getUnitById(unitId) {
85
- return this.units.find((u) => u.id === unitId);
86
- }
87
- addBuffToUnit(sourceId, targetId, buffId) {
133
+ };
134
+ BattleCore.prototype.getUnitById = function (unitId) {
135
+ return this.units.find(function (u) { return u.id === unitId; });
136
+ };
137
+ BattleCore.prototype.addBuffToUnit = function (sourceId, targetId, buffId) {
88
138
  this.applyBuff(sourceId, targetId, buffId);
89
- }
139
+ };
90
140
  /** 动态召唤一个新单位加入战斗 */
91
- spawnUnit(initUnit) {
141
+ BattleCore.prototype.spawnUnit = function (initUnit) {
142
+ var e_2, _a;
92
143
  // 检查同队存活单位数量,最多4个
93
- const teamAlive = this.units.filter((u) => u.teamId === initUnit.teamId && u.runtime.alive);
144
+ var teamAlive = this.units.filter(function (u) { return u.teamId === initUnit.teamId && u.runtime.alive; });
94
145
  if (teamAlive.length >= 4) {
95
146
  return null;
96
147
  }
97
- const position = (teamAlive.length + 1);
98
- const unit = {
148
+ var position = (teamAlive.length + 1);
149
+ var unit = {
99
150
  id: initUnit.id,
100
151
  name: initUnit.name,
101
152
  teamId: initUnit.teamId,
102
- position,
153
+ position: position,
103
154
  element: initUnit.element,
104
- stats: { ...initUnit.stats },
155
+ stats: __assign({}, initUnit.stats),
105
156
  runtime: {
106
157
  Hp: initUnit.stats.Mhp,
107
158
  AP: 0,
@@ -112,42 +163,63 @@ export class BattleCore {
112
163
  alive: true,
113
164
  stunned: false
114
165
  },
115
- skills: initUnit.skills.map((s) => ({
166
+ skills: initUnit.skills.map(function (s) { return ({
116
167
  id: s.id,
117
168
  type: s.type,
118
169
  cooldown: s.cooldown,
119
170
  energyCost: s.energyCost,
120
171
  energyGain: s.energyGain
121
- }))
172
+ }); })
122
173
  };
123
174
  this.units.push(unit);
124
- this.skillSlots.set(unit.id, initUnit.skills.map((d) => ({
175
+ this.skillSlots.set(unit.id, initUnit.skills.map(function (d) { return ({
125
176
  definition: d,
126
177
  cooldownRemain: 0
127
- })));
178
+ }); }));
128
179
  // 初始化被动技能
129
- const passiveSlots = this.getSlots(unit.id).filter((slot) => slot.definition.type === "passive" && slot.definition.mode === "script" && slot.definition.activateOnBattleStart);
130
- for (const passiveSlot of passiveSlots) {
131
- this.executeSkill(unit, passiveSlot.definition, "assist");
180
+ var passiveSlots = this.getSlots(unit.id).filter(function (slot) { return slot.definition.type === "passive" && slot.definition.mode === "script" && slot.definition.activateOnBattleStart; });
181
+ try {
182
+ for (var passiveSlots_1 = __values(passiveSlots), passiveSlots_1_1 = passiveSlots_1.next(); !passiveSlots_1_1.done; passiveSlots_1_1 = passiveSlots_1.next()) {
183
+ var passiveSlot = passiveSlots_1_1.value;
184
+ this.executeSkill(unit, passiveSlot.definition, "assist");
185
+ }
186
+ }
187
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
188
+ finally {
189
+ try {
190
+ if (passiveSlots_1_1 && !passiveSlots_1_1.done && (_a = passiveSlots_1.return)) _a.call(passiveSlots_1);
191
+ }
192
+ finally { if (e_2) throw e_2.error; }
132
193
  }
133
194
  this.rearrangePositions();
134
195
  return unit;
135
- }
196
+ };
136
197
  /** 延长目标单位所有主动技能的冷却回合数 */
137
- extendCooldown(unitId, delta) {
138
- const slots = this.skillSlots.get(unitId);
198
+ BattleCore.prototype.extendCooldown = function (unitId, delta) {
199
+ var e_3, _a;
200
+ var slots = this.skillSlots.get(unitId);
139
201
  if (!slots) {
140
202
  return;
141
203
  }
142
- for (const slot of slots) {
143
- if (slot.definition.type === "basic" || slot.definition.type === "core" || slot.definition.type === "ultimate") {
144
- slot.cooldownRemain = Math.max(0, slot.cooldownRemain + delta);
204
+ try {
205
+ for (var slots_1 = __values(slots), slots_1_1 = slots_1.next(); !slots_1_1.done; slots_1_1 = slots_1.next()) {
206
+ var slot = slots_1_1.value;
207
+ if (slot.definition.type === "basic" || slot.definition.type === "core" || slot.definition.type === "ultimate") {
208
+ slot.cooldownRemain = Math.max(0, slot.cooldownRemain + delta);
209
+ }
145
210
  }
146
211
  }
147
- }
212
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
213
+ finally {
214
+ try {
215
+ if (slots_1_1 && !slots_1_1.done && (_a = slots_1.return)) _a.call(slots_1);
216
+ }
217
+ finally { if (e_3) throw e_3.error; }
218
+ }
219
+ };
148
220
  /** 击杀指定单位 */
149
- killUnit(unitId) {
150
- const unit = this.getUnitById(unitId);
221
+ BattleCore.prototype.killUnit = function (unitId) {
222
+ var unit = this.getUnitById(unitId);
151
223
  if (!unit || !unit.runtime.alive) {
152
224
  return;
153
225
  }
@@ -155,84 +227,93 @@ export class BattleCore {
155
227
  unit.runtime.alive = false;
156
228
  this.eventBus.emit({ name: "OnDeath", payload: { targetId: unit.id, sourceId: unit.id } });
157
229
  this.rearrangePositions();
158
- }
159
- grantActionProgress(unitId, ratio) {
160
- const unit = this.getUnitById(unitId);
230
+ };
231
+ BattleCore.prototype.grantActionProgress = function (unitId, ratio) {
232
+ var unit = this.getUnitById(unitId);
161
233
  if (!unit || !unit.runtime.alive) {
162
234
  return;
163
235
  }
164
236
  this.turnBar.grantActionProgress(unit, ratio);
165
- }
166
- registerSkillScript(scriptId, script) {
237
+ };
238
+ BattleCore.prototype.registerSkillScript = function (scriptId, script) {
167
239
  this.scriptSkillEngine.registerScript(scriptId, script);
168
- }
169
- registerChase(predicate, resolver) {
240
+ };
241
+ BattleCore.prototype.registerChase = function (predicate, resolver) {
170
242
  this.chasePredicates.push(predicate);
171
243
  this.chaseSkillResolvers.push(resolver);
172
- }
173
- registerReactiveCounterRules() {
174
- this.eventBus.on("OnAfterDamage", ({ sourceId, targetId, value }) => {
175
- if (value <= 0 || sourceId === targetId || this.activeSkillContext?.trigger === "counter") {
244
+ };
245
+ BattleCore.prototype.registerReactiveCounterRules = function () {
246
+ var _this = this;
247
+ this.eventBus.on("OnAfterDamage", function (_a) {
248
+ var _b, _c, _d, _e, _f;
249
+ var sourceId = _a.sourceId, targetId = _a.targetId, value = _a.value;
250
+ if (value <= 0 || sourceId === targetId || ((_b = _this.activeSkillContext) === null || _b === void 0 ? void 0 : _b.trigger) === "counter") {
176
251
  return;
177
252
  }
178
- const source = this.units.find((u) => u.id === sourceId);
179
- const target = this.units.find((u) => u.id === targetId);
253
+ var source = _this.units.find(function (u) { return u.id === sourceId; });
254
+ var target = _this.units.find(function (u) { return u.id === targetId; });
180
255
  if (!source || !target || !source.runtime.alive || !target.runtime.alive) {
181
256
  return;
182
257
  }
183
- const reactiveCounterBuff = this.effectSystem
258
+ var reactiveCounterBuff = _this.effectSystem
184
259
  .getBuffs(target.id)
185
- .filter((buff) => buff.stacks > 0 && buff.config.reactiveCounter)
186
- .sort((a, b) => (b.config.reactiveCounterPriority ?? 0) - (a.config.reactiveCounterPriority ?? 0))[0];
260
+ .filter(function (buff) { return buff.stacks > 0 && buff.config.reactiveCounter; })
261
+ .sort(function (a, b) { var _a, _b; return ((_a = b.config.reactiveCounterPriority) !== null && _a !== void 0 ? _a : 0) - ((_b = a.config.reactiveCounterPriority) !== null && _b !== void 0 ? _b : 0); })[0];
187
262
  if (!reactiveCounterBuff) {
188
263
  return;
189
264
  }
190
- const basic = this.getSlots(target.id).find((slot) => slot.definition.type === "basic")?.definition;
265
+ var basic = (_c = _this.getSlots(target.id).find(function (slot) { return slot.definition.type === "basic"; })) === null || _c === void 0 ? void 0 : _c.definition;
191
266
  if (!basic) {
192
267
  return;
193
268
  }
194
- this.consumeBuffStack(target, reactiveCounterBuff.id);
195
- this.pendingReactiveCounters.push({
196
- sourceId,
197
- targetId,
198
- turn: this.turn,
199
- sourceSkillId: this.activeSkillContext?.skillId ?? basic.id,
200
- sourceTriggeredBy: this.activeSkillContext?.trigger
269
+ _this.consumeBuffStack(target, reactiveCounterBuff.id);
270
+ _this.pendingReactiveCounters.push({
271
+ sourceId: sourceId,
272
+ targetId: targetId,
273
+ turn: _this.turn,
274
+ sourceSkillId: (_e = (_d = _this.activeSkillContext) === null || _d === void 0 ? void 0 : _d.skillId) !== null && _e !== void 0 ? _e : basic.id,
275
+ sourceTriggeredBy: (_f = _this.activeSkillContext) === null || _f === void 0 ? void 0 : _f.trigger
201
276
  });
202
277
  }, 0);
203
- }
204
- processPendingReactiveCounters() {
205
- while (this.pendingReactiveCounters.length > 0) {
206
- const pending = this.pendingReactiveCounters.shift();
207
- const source = this.units.find((u) => u.id === pending.sourceId);
208
- const target = this.units.find((u) => u.id === pending.targetId);
278
+ };
279
+ BattleCore.prototype.processPendingReactiveCounters = function () {
280
+ var _this = this;
281
+ var _a;
282
+ var _loop_2 = function () {
283
+ var pending = this_2.pendingReactiveCounters.shift();
284
+ var source = this_2.units.find(function (u) { return u.id === pending.sourceId; });
285
+ var target = this_2.units.find(function (u) { return u.id === pending.targetId; });
209
286
  if (!source || !target || !source.runtime.alive || !target.runtime.alive) {
210
- continue;
287
+ return "continue";
211
288
  }
212
- const basic = this.getSlots(target.id).find((slot) => slot.definition.type === "basic")?.definition;
289
+ var basic = (_a = this_2.getSlots(target.id).find(function (slot) { return slot.definition.type === "basic"; })) === null || _a === void 0 ? void 0 : _a.definition;
213
290
  if (!basic) {
214
- continue;
291
+ return "continue";
215
292
  }
216
- const counterCtx = {
293
+ var counterCtx = {
217
294
  turn: pending.turn,
218
295
  sourceActorId: source.id,
219
296
  sourceSkillId: pending.sourceSkillId || basic.id,
220
297
  sourceTargets: [target.id],
221
298
  sourceTriggeredBy: pending.sourceTriggeredBy
222
299
  };
223
- const counterResult = this.executeSkill(target, basic, "counter", counterCtx, [source]);
224
- this.logger.logAction({
300
+ var counterResult = this_2.executeSkill(target, basic, "counter", counterCtx, [source]);
301
+ this_2.logger.logAction({
225
302
  turn: pending.turn,
226
303
  actorId: target.id,
227
304
  skillId: basic.id,
228
305
  triggeredBy: "counter",
229
306
  result: counterResult
230
307
  });
231
- this.logger.logSnapshot(pending.turn, "afterSkill", this.units, (unit) => this.effectSystem.getEffectiveStats(unit), (unit) => this.snapshotBuffs(unit), (unit) => this.computeImbalanceMax(unit));
308
+ this_2.logger.logSnapshot(pending.turn, "afterSkill", this_2.units, function (unit) { return _this.effectSystem.getEffectiveStats(unit); }, function (unit) { return _this.snapshotBuffs(unit); }, function (unit) { return _this.computeImbalanceMax(unit); });
309
+ };
310
+ var this_2 = this;
311
+ while (this.pendingReactiveCounters.length > 0) {
312
+ _loop_2();
232
313
  }
233
- }
234
- consumeBuffStack(owner, buffId) {
235
- const buff = this.effectSystem.getBuffs(owner.id).find((item) => item.id === buffId);
314
+ };
315
+ BattleCore.prototype.consumeBuffStack = function (owner, buffId) {
316
+ var buff = this.effectSystem.getBuffs(owner.id).find(function (item) { return item.id === buffId; });
236
317
  if (!buff) {
237
318
  return;
238
319
  }
@@ -241,20 +322,24 @@ export class BattleCore {
241
322
  return;
242
323
  }
243
324
  buff.stacks -= 1;
244
- }
245
- registerConfiguredChaseRules() {
246
- for (const unit of this.units) {
247
- const slots = this.getSlots(unit.id);
248
- for (const slot of slots) {
249
- const rule = slot.definition.chaseRule;
325
+ };
326
+ BattleCore.prototype.registerConfiguredChaseRules = function () {
327
+ var e_4, _a;
328
+ var _this = this;
329
+ var _loop_3 = function (unit) {
330
+ var e_5, _d;
331
+ var slots = this_3.getSlots(unit.id);
332
+ var _loop_4 = function (slot) {
333
+ var rule = slot.definition.chaseRule;
250
334
  if (!rule || rule.enabled === false) {
251
- continue;
335
+ return "continue";
252
336
  }
253
- this.registerChase((ctx, actor) => {
337
+ this_3.registerChase(function (ctx, actor) {
338
+ var _a, _b, _c, _d, _e, _f;
254
339
  if (actor.id !== unit.id || !actor.runtime.alive) {
255
340
  return false;
256
341
  }
257
- if (!(rule.allowSelfTrigger ?? false) && ctx.sourceActorId === actor.id) {
342
+ if (!((_a = rule.allowSelfTrigger) !== null && _a !== void 0 ? _a : false) && ctx.sourceActorId === actor.id) {
258
343
  return false;
259
344
  }
260
345
  if (rule.triggerSourceSkillIds && rule.triggerSourceSkillIds.length > 0 && !rule.triggerSourceSkillIds.includes(ctx.sourceSkillId)) {
@@ -265,36 +350,65 @@ export class BattleCore {
265
350
  return false;
266
351
  }
267
352
  }
268
- if (rule.requireSourceTargets ?? true) {
269
- if ((ctx.sourceTargets?.length ?? 0) === 0) {
353
+ if ((_b = rule.requireSourceTargets) !== null && _b !== void 0 ? _b : true) {
354
+ if (((_d = (_c = ctx.sourceTargets) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) === 0) {
270
355
  return false;
271
356
  }
272
357
  }
273
- if (rule.sameTeamOnly ?? true) {
274
- const sourceActor = this.units.find((u) => u.id === ctx.sourceActorId);
358
+ if ((_e = rule.sameTeamOnly) !== null && _e !== void 0 ? _e : true) {
359
+ var sourceActor = _this.units.find(function (u) { return u.id === ctx.sourceActorId; });
275
360
  if (!sourceActor || sourceActor.teamId !== actor.teamId) {
276
361
  return false;
277
362
  }
278
363
  }
279
- const chance = Math.min(10000, Math.max(0, Math.floor(rule.chance ?? 10000)));
280
- return Math.floor(this.rng.next() * 10000) < chance;
281
- }, (actor) => {
282
- const useSkillId = rule.useSkillId ?? slot.definition.id;
283
- return this.getSlots(actor.id).find((s) => s.definition.id === useSkillId)?.definition;
364
+ var chance = Math.min(10000, Math.max(0, Math.floor((_f = rule.chance) !== null && _f !== void 0 ? _f : 10000)));
365
+ return Math.floor(_this.rng.next() * 10000) < chance;
366
+ }, function (actor) {
367
+ var _a, _b;
368
+ var useSkillId = (_a = rule.useSkillId) !== null && _a !== void 0 ? _a : slot.definition.id;
369
+ return (_b = _this.getSlots(actor.id).find(function (s) { return s.definition.id === useSkillId; })) === null || _b === void 0 ? void 0 : _b.definition;
284
370
  });
371
+ };
372
+ try {
373
+ for (var slots_2 = (e_5 = void 0, __values(slots)), slots_2_1 = slots_2.next(); !slots_2_1.done; slots_2_1 = slots_2.next()) {
374
+ var slot = slots_2_1.value;
375
+ _loop_4(slot);
376
+ }
377
+ }
378
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
379
+ finally {
380
+ try {
381
+ if (slots_2_1 && !slots_2_1.done && (_d = slots_2.return)) _d.call(slots_2);
382
+ }
383
+ finally { if (e_5) throw e_5.error; }
384
+ }
385
+ };
386
+ var this_3 = this;
387
+ try {
388
+ for (var _b = __values(this.units), _c = _b.next(); !_c.done; _c = _b.next()) {
389
+ var unit = _c.value;
390
+ _loop_3(unit);
285
391
  }
286
392
  }
287
- }
288
- run() {
393
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
394
+ finally {
395
+ try {
396
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
397
+ }
398
+ finally { if (e_4) throw e_4.error; }
399
+ }
400
+ };
401
+ BattleCore.prototype.run = function () {
402
+ var _this = this;
289
403
  this.initializeScriptPassives();
290
404
  while (!this.winner() && this.actionCount < this.config.maxTurns) {
291
- const actor = this.turnBar.fillUntilAction(this.units);
405
+ var actor = this.turnBar.fillUntilAction(this.units);
292
406
  if (!actor) {
293
407
  break;
294
408
  }
295
409
  this.turn += 1;
296
410
  this.actionCount += 1;
297
- this.logger.logSnapshot(this.turn, "beforeAction", this.units, (unit) => this.effectSystem.getEffectiveStats(unit), (unit) => this.snapshotBuffs(unit), (unit) => this.computeImbalanceMax(unit));
411
+ this.logger.logSnapshot(this.turn, "beforeAction", this.units, function (unit) { return _this.effectSystem.getEffectiveStats(unit); }, function (unit) { return _this.snapshotBuffs(unit); }, function (unit) { return _this.computeImbalanceMax(unit); });
298
412
  this.eventBus.emit({ name: "OnTurnStart", payload: { actorId: actor.id, turn: this.turn } });
299
413
  this.applyTurnStart(actor);
300
414
  this.processPendingReactiveCounters();
@@ -305,70 +419,109 @@ export class BattleCore {
305
419
  this.applyTurnEnd(actor);
306
420
  this.decrementAllCooldowns(actor.id);
307
421
  this.turnBar.consumeAction(actor);
308
- this.logger.logSnapshot(this.turn, "turnEnd", this.units, (unit) => this.effectSystem.getEffectiveStats(unit), (unit) => this.snapshotBuffs(unit), (unit) => this.computeImbalanceMax(unit));
422
+ this.logger.logSnapshot(this.turn, "turnEnd", this.units, function (unit) { return _this.effectSystem.getEffectiveStats(unit); }, function (unit) { return _this.snapshotBuffs(unit); }, function (unit) { return _this.computeImbalanceMax(unit); });
309
423
  }
310
424
  return {
311
425
  winner: this.resolveWinnerByRule(),
312
426
  totalTurns: this.actionCount,
313
427
  logs: this.logger
314
428
  };
315
- }
316
- initializeScriptPassives() {
429
+ };
430
+ BattleCore.prototype.initializeScriptPassives = function () {
431
+ var e_6, _a, e_7, _b;
317
432
  if (this.scriptPassivesInitialized) {
318
433
  return;
319
434
  }
320
435
  this.scriptPassivesInitialized = true;
321
- for (const unit of this.units) {
322
- const passiveSlots = this.getSlots(unit.id).filter((slot) => slot.definition.type === "passive" && slot.definition.mode === "script" && slot.definition.activateOnBattleStart);
323
- for (const passiveSlot of passiveSlots) {
324
- this.executeSkill(unit, passiveSlot.definition, "assist");
436
+ try {
437
+ for (var _c = __values(this.units), _d = _c.next(); !_d.done; _d = _c.next()) {
438
+ var unit = _d.value;
439
+ var passiveSlots = this.getSlots(unit.id).filter(function (slot) { return slot.definition.type === "passive" && slot.definition.mode === "script" && slot.definition.activateOnBattleStart; });
440
+ try {
441
+ for (var passiveSlots_2 = (e_7 = void 0, __values(passiveSlots)), passiveSlots_2_1 = passiveSlots_2.next(); !passiveSlots_2_1.done; passiveSlots_2_1 = passiveSlots_2.next()) {
442
+ var passiveSlot = passiveSlots_2_1.value;
443
+ this.executeSkill(unit, passiveSlot.definition, "assist");
444
+ }
445
+ }
446
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
447
+ finally {
448
+ try {
449
+ if (passiveSlots_2_1 && !passiveSlots_2_1.done && (_b = passiveSlots_2.return)) _b.call(passiveSlots_2);
450
+ }
451
+ finally { if (e_7) throw e_7.error; }
452
+ }
325
453
  }
326
454
  }
327
- }
328
- performAction(actor) {
329
- const slots = this.getSlots(actor.id);
330
- const skillOrder = ["ultimate", "core", "basic"];
331
- const chaseUsed = new Set();
332
- for (const type of skillOrder) {
455
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
456
+ finally {
457
+ try {
458
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
459
+ }
460
+ finally { if (e_6) throw e_6.error; }
461
+ }
462
+ };
463
+ BattleCore.prototype.performAction = function (actor) {
464
+ var e_8, _a;
465
+ var _this = this;
466
+ var slots = this.getSlots(actor.id);
467
+ var skillOrder = ["ultimate", "core", "basic"];
468
+ var chaseUsed = new Set();
469
+ var _loop_5 = function (type) {
333
470
  if (!actor.runtime.alive) {
334
- break;
471
+ return "break";
335
472
  }
336
- const slot = slots.find((s) => s.definition.type === type);
473
+ var slot = slots.find(function (s) { return s.definition.type === type; });
337
474
  if (!slot) {
338
- continue;
475
+ return "continue";
339
476
  }
340
- const canCast = this.canCast(actor, slot);
477
+ var canCast = this_4.canCast(actor, slot);
341
478
  if (!canCast) {
342
- continue;
479
+ return "continue";
343
480
  }
344
481
  slot.cooldownRemain = slot.definition.cooldown;
345
482
  if (slot.definition.type === "ultimate") {
346
483
  actor.runtime.Energy = Math.max(0, actor.runtime.Energy - slot.definition.energyCost);
347
484
  }
348
- const result = this.executeSkill(actor, slot.definition, "normal");
349
- this.logger.logAction({
350
- turn: this.turn,
485
+ var result = this_4.executeSkill(actor, slot.definition, "normal");
486
+ this_4.logger.logAction({
487
+ turn: this_4.turn,
351
488
  actorId: actor.id,
352
489
  skillId: slot.definition.id,
353
490
  triggeredBy: "normal",
354
- result
491
+ result: result
355
492
  });
356
493
  if (slot.definition.type !== "ultimate") {
357
- this.gainEnergy(actor, slot.definition.energyGain);
494
+ this_4.gainEnergy(actor, slot.definition.energyGain);
358
495
  }
359
- this.logger.logSnapshot(this.turn, "afterSkill", this.units, (unit) => this.effectSystem.getEffectiveStats(unit), (unit) => this.snapshotBuffs(unit), (unit) => this.computeImbalanceMax(unit));
360
- this.processPendingReactiveCounters();
361
- this.rearrangePositions();
496
+ this_4.logger.logSnapshot(this_4.turn, "afterSkill", this_4.units, function (unit) { return _this.effectSystem.getEffectiveStats(unit); }, function (unit) { return _this.snapshotBuffs(unit); }, function (unit) { return _this.computeImbalanceMax(unit); });
497
+ this_4.processPendingReactiveCounters();
498
+ this_4.rearrangePositions();
362
499
  if (!actor.runtime.alive) {
363
- break;
500
+ return "break";
364
501
  }
365
- this.tryChaseAndAssist(actor, result, chaseUsed);
366
- if (this.winner()) {
367
- break;
502
+ this_4.tryChaseAndAssist(actor, result, chaseUsed);
503
+ if (this_4.winner()) {
504
+ return "break";
505
+ }
506
+ };
507
+ var this_4 = this;
508
+ try {
509
+ for (var skillOrder_1 = __values(skillOrder), skillOrder_1_1 = skillOrder_1.next(); !skillOrder_1_1.done; skillOrder_1_1 = skillOrder_1.next()) {
510
+ var type = skillOrder_1_1.value;
511
+ var state_1 = _loop_5(type);
512
+ if (state_1 === "break")
513
+ break;
368
514
  }
369
515
  }
370
- }
371
- canCast(actor, slot) {
516
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
517
+ finally {
518
+ try {
519
+ if (skillOrder_1_1 && !skillOrder_1_1.done && (_a = skillOrder_1.return)) _a.call(skillOrder_1);
520
+ }
521
+ finally { if (e_8) throw e_8.error; }
522
+ }
523
+ };
524
+ BattleCore.prototype.canCast = function (actor, slot) {
372
525
  if (!actor.runtime.alive || actor.runtime.stunned) {
373
526
  return false;
374
527
  }
@@ -379,186 +532,212 @@ export class BattleCore {
379
532
  return actor.runtime.Energy >= slot.definition.energyCost;
380
533
  }
381
534
  return true;
382
- }
383
- executeSkill(actor, skill, trigger, triggerCtx, selectedTargetsOverride) {
384
- this.eventBus.emit({ name: "OnBeforeCast", payload: { actorId: actor.id, skillId: skill.id, trigger } });
385
- const previousSkillContext = this.activeSkillContext;
386
- this.activeSkillContext = { actorId: actor.id, skillId: skill.id, trigger };
387
- const result = (() => {
535
+ };
536
+ BattleCore.prototype.executeSkill = function (actor, skill, trigger, triggerCtx, selectedTargetsOverride) {
537
+ var _this = this;
538
+ this.eventBus.emit({ name: "OnBeforeCast", payload: { actorId: actor.id, skillId: skill.id, trigger: trigger } });
539
+ var previousSkillContext = this.activeSkillContext;
540
+ this.activeSkillContext = { actorId: actor.id, skillId: skill.id, trigger: trigger };
541
+ var result = (function () {
388
542
  try {
389
- return this.skillExecutor.execute(skill, actor, {
390
- rng: this.rng,
391
- getUnits: () => this.units,
392
- applyDamage: (sourceId, targetId, value, staggerElement) => this.applyDamage(sourceId, targetId, value, staggerElement),
393
- applyHeal: (targetId, value) => this.applyHeal(targetId, value),
394
- applyShield: (targetId, value) => this.applyShield(targetId, value),
395
- applyBuff: (sourceId, targetId, buffId) => this.applyBuff(sourceId, targetId, buffId),
396
- getEffectiveStats: (unit) => this.effectSystem.getEffectiveStats(unit),
397
- createScriptApi: (skillElement) => ({
398
- damage: (sourceId, targetId, value) => {
399
- const r = this.applyDamage(sourceId, targetId, value, skillElement);
543
+ return _this.skillExecutor.execute(skill, actor, {
544
+ rng: _this.rng,
545
+ getUnits: function () { return _this.units; },
546
+ applyDamage: function (sourceId, targetId, value, staggerElement) { return _this.applyDamage(sourceId, targetId, value, staggerElement); },
547
+ applyHeal: function (targetId, value) { return _this.applyHeal(targetId, value); },
548
+ applyShield: function (targetId, value) { return _this.applyShield(targetId, value); },
549
+ applyBuff: function (sourceId, targetId, buffId) { return _this.applyBuff(sourceId, targetId, buffId); },
550
+ getEffectiveStats: function (unit) { return _this.effectSystem.getEffectiveStats(unit); },
551
+ createScriptApi: function (skillElement) { return ({
552
+ damage: function (sourceId, targetId, value) {
553
+ var r = _this.applyDamage(sourceId, targetId, value, skillElement);
400
554
  return { damage: r.damage, imbalanceDelta: r.imbalanceDelta, triggeredImbalanceBreak: r.triggeredImbalanceBreak };
401
555
  },
402
- heal: (targetId, value) => this.applyHeal(targetId, value),
403
- shield: (targetId, value) => this.applyShield(targetId, value),
404
- adjustImbalance: (targetId, delta) => {
405
- const sourceActorId = this.activeSkillContext?.actorId ?? actor.id;
406
- const sourceSkillId = this.activeSkillContext?.skillId ?? skill.id;
407
- return this.applyImbalanceDelta(sourceActorId, sourceSkillId, targetId, delta, "skill_effect");
556
+ heal: function (targetId, value) { return _this.applyHeal(targetId, value); },
557
+ shield: function (targetId, value) { return _this.applyShield(targetId, value); },
558
+ adjustImbalance: function (targetId, delta) {
559
+ var _a, _b, _c, _d;
560
+ var sourceActorId = (_b = (_a = _this.activeSkillContext) === null || _a === void 0 ? void 0 : _a.actorId) !== null && _b !== void 0 ? _b : actor.id;
561
+ var sourceSkillId = (_d = (_c = _this.activeSkillContext) === null || _c === void 0 ? void 0 : _c.skillId) !== null && _d !== void 0 ? _d : skill.id;
562
+ return _this.applyImbalanceDelta(sourceActorId, sourceSkillId, targetId, delta, "skill_effect");
408
563
  },
409
- addBuff: (sourceId, targetId, buffId) => this.applyBuff(sourceId, targetId, buffId),
410
- removeBuff: (targetId, buffId) => {
411
- const target = this.getUnitById(targetId);
564
+ addBuff: function (sourceId, targetId, buffId) { return _this.applyBuff(sourceId, targetId, buffId); },
565
+ removeBuff: function (targetId, buffId) {
566
+ var target = _this.getUnitById(targetId);
412
567
  if (target) {
413
- this.effectSystem.removeBuff(target, buffId);
568
+ _this.effectSystem.removeBuff(target, buffId);
414
569
  }
415
570
  },
416
- grantExtraTurn: (unitId) => this.turnBar.grantExtraTurn(unitId),
417
- adjustActionProgress: (unitId, ratio) => this.grantActionProgress(unitId, ratio),
418
- gainEnergy: (unitId, value) => this.gainEnergyToUnit(unitId, value),
419
- getUnit: (unitId) => this.units.find((u) => u.id === unitId),
420
- getAliveUnits: () => this.units.filter((u) => u.runtime.alive),
421
- hasBuff: (unitId, buffId) => this.effectSystem.hasBuff(unitId, buffId),
422
- getBuffs: (unitId) => this.effectSystem.getBuffs(unitId),
423
- randomInt: (maxExclusive) => (maxExclusive <= 0 ? 0 : this.rng.nextInt(maxExclusive)),
424
- pushPosition: (unitId, delta) => {
425
- const unit = this.getUnitById(unitId);
571
+ grantExtraTurn: function (unitId) { return _this.turnBar.grantExtraTurn(unitId); },
572
+ adjustActionProgress: function (unitId, ratio) { return _this.grantActionProgress(unitId, ratio); },
573
+ gainEnergy: function (unitId, value) { return _this.gainEnergyToUnit(unitId, value); },
574
+ getUnit: function (unitId) { return _this.units.find(function (u) { return u.id === unitId; }); },
575
+ getAliveUnits: function () { return _this.units.filter(function (u) { return u.runtime.alive; }); },
576
+ hasBuff: function (unitId, buffId) { return _this.effectSystem.hasBuff(unitId, buffId); },
577
+ getBuffs: function (unitId) { return _this.effectSystem.getBuffs(unitId); },
578
+ randomInt: function (maxExclusive) { return (maxExclusive <= 0 ? 0 : _this.rng.nextInt(maxExclusive)); },
579
+ pushPosition: function (unitId, delta) {
580
+ var unit = _this.getUnitById(unitId);
426
581
  if (unit) {
427
582
  unit.position = Math.max(1, Math.min(4, unit.position + delta));
428
583
  }
429
584
  },
430
- preventDeath: (unitId) => {
431
- const unit = this.getUnitById(unitId);
585
+ preventDeath: function (unitId) {
586
+ var unit = _this.getUnitById(unitId);
432
587
  if (unit && unit.runtime.Hp <= 0) {
433
588
  unit.runtime.Hp = 1;
434
589
  unit.runtime.alive = true;
435
590
  }
436
591
  },
437
- isUnitTurn: (unitId) => {
438
- return this.activeSkillContext?.actorId === unitId;
592
+ isUnitTurn: function (unitId) {
593
+ var _a;
594
+ return ((_a = _this.activeSkillContext) === null || _a === void 0 ? void 0 : _a.actorId) === unitId;
439
595
  },
440
- castSkill: (actorId, skillId, trigger, targetIds) => {
441
- const castActor = this.getUnitById(actorId);
596
+ castSkill: function (actorId, skillId, trigger, targetIds) {
597
+ var _a, _b, _c, _d, _e, _f;
598
+ var castActor = _this.getUnitById(actorId);
442
599
  if (!castActor || !castActor.runtime.alive) {
443
600
  return null;
444
601
  }
445
- const castSkill = this.getSlots(actorId).find((slot) => slot.definition.id === skillId)?.definition;
602
+ var castSkill = (_a = _this.getSlots(actorId).find(function (slot) { return slot.definition.id === skillId; })) === null || _a === void 0 ? void 0 : _a.definition;
446
603
  if (!castSkill) {
447
604
  return null;
448
605
  }
449
- const selectedTargets = (targetIds ?? [])
450
- .map((id) => this.getUnitById(id))
451
- .filter((u) => Boolean(u && u.runtime.alive));
452
- const triggerCtx = {
453
- turn: this.turn,
454
- sourceActorId: this.activeSkillContext?.actorId ?? actorId,
455
- sourceSkillId: this.activeSkillContext?.skillId ?? skillId,
456
- sourceTargets: selectedTargets.map((u) => u.id),
457
- sourceTriggeredBy: this.activeSkillContext?.trigger
606
+ var selectedTargets = (targetIds !== null && targetIds !== void 0 ? targetIds : [])
607
+ .map(function (id) { return _this.getUnitById(id); })
608
+ .filter(function (u) { return Boolean(u && u.runtime.alive); });
609
+ var triggerCtx = {
610
+ turn: _this.turn,
611
+ sourceActorId: (_c = (_b = _this.activeSkillContext) === null || _b === void 0 ? void 0 : _b.actorId) !== null && _c !== void 0 ? _c : actorId,
612
+ sourceSkillId: (_e = (_d = _this.activeSkillContext) === null || _d === void 0 ? void 0 : _d.skillId) !== null && _e !== void 0 ? _e : skillId,
613
+ sourceTargets: selectedTargets.map(function (u) { return u.id; }),
614
+ sourceTriggeredBy: (_f = _this.activeSkillContext) === null || _f === void 0 ? void 0 : _f.trigger
458
615
  };
459
- const castResult = this.executeSkill(castActor, castSkill, trigger, triggerCtx, selectedTargets.length > 0 ? selectedTargets : undefined);
460
- this.logger.logAction({
461
- turn: this.turn,
462
- actorId,
463
- skillId,
616
+ var castResult = _this.executeSkill(castActor, castSkill, trigger, triggerCtx, selectedTargets.length > 0 ? selectedTargets : undefined);
617
+ _this.logger.logAction({
618
+ turn: _this.turn,
619
+ actorId: actorId,
620
+ skillId: skillId,
464
621
  triggeredBy: trigger,
465
622
  result: castResult
466
623
  });
467
- this.logger.logSnapshot(this.turn, "afterSkill", this.units, (u) => this.effectSystem.getEffectiveStats(u), (u) => this.snapshotBuffs(u), (u) => this.computeImbalanceMax(u));
468
- this.processPendingReactiveCounters();
624
+ _this.logger.logSnapshot(_this.turn, "afterSkill", _this.units, function (u) { return _this.effectSystem.getEffectiveStats(u); }, function (u) { return _this.snapshotBuffs(u); }, function (u) { return _this.computeImbalanceMax(u); });
625
+ _this.processPendingReactiveCounters();
469
626
  return castResult;
470
627
  },
471
- onAnyEvent: (listenerUnitId, eventName, handler) => {
472
- this.eventBus.on(eventName, handler);
628
+ onAnyEvent: function (listenerUnitId, eventName, handler) {
629
+ _this.eventBus.on(eventName, handler);
473
630
  },
474
- spawnUnit: (initUnit) => this.spawnUnit(initUnit),
475
- extendCooldown: (unitId, delta) => this.extendCooldown(unitId, delta),
476
- killUnit: (unitId) => this.killUnit(unitId)
477
- })
631
+ spawnUnit: function (initUnit) { return _this.spawnUnit(initUnit); },
632
+ extendCooldown: function (unitId, delta) { return _this.extendCooldown(unitId, delta); },
633
+ killUnit: function (unitId) { return _this.killUnit(unitId); }
634
+ }); }
478
635
  }, trigger, triggerCtx, selectedTargetsOverride);
479
636
  }
480
637
  finally {
481
- this.activeSkillContext = previousSkillContext;
638
+ _this.activeSkillContext = previousSkillContext;
482
639
  }
483
640
  })();
484
- this.eventBus.emit({ name: "OnAfterCast", payload: { actorId: actor.id, skillId: skill.id, trigger, result } });
641
+ this.eventBus.emit({ name: "OnAfterCast", payload: { actorId: actor.id, skillId: skill.id, trigger: trigger, result: result } });
485
642
  return result;
486
- }
487
- tryChaseAndAssist(actor, result, chaseUsed) {
488
- const triggerCtx = {
643
+ };
644
+ BattleCore.prototype.tryChaseAndAssist = function (actor, result, chaseUsed) {
645
+ var e_9, _a, e_10, _b;
646
+ var _this = this;
647
+ var _c;
648
+ var triggerCtx = {
489
649
  turn: this.turn,
490
650
  sourceActorId: actor.id,
491
651
  sourceSkillId: result.skillId,
492
652
  sourceTargets: result.targets,
493
653
  sourceTriggeredBy: result.triggeredBy
494
654
  };
495
- for (const unit of this.units.filter((u) => u.runtime.alive && !chaseUsed.has(u.id))) {
496
- for (let i = 0; i < this.chasePredicates.length; i++) {
497
- if (!this.chasePredicates[i](triggerCtx, unit)) {
498
- continue;
499
- }
500
- const skill = this.chaseSkillResolvers[i](unit);
501
- if (!skill) {
502
- continue;
655
+ try {
656
+ for (var _d = __values(this.units.filter(function (u) { return u.runtime.alive && !chaseUsed.has(u.id); })), _e = _d.next(); !_e.done; _e = _d.next()) {
657
+ var unit = _e.value;
658
+ for (var i = 0; i < this.chasePredicates.length; i++) {
659
+ if (!this.chasePredicates[i](triggerCtx, unit)) {
660
+ continue;
661
+ }
662
+ var skill = this.chaseSkillResolvers[i](unit);
663
+ if (!skill) {
664
+ continue;
665
+ }
666
+ var chaseResult = this.executeSkill(unit, skill, "chase", triggerCtx);
667
+ this.logger.logAction({
668
+ turn: this.turn,
669
+ actorId: unit.id,
670
+ skillId: skill.id,
671
+ triggeredBy: "chase",
672
+ result: chaseResult
673
+ });
674
+ this.logger.logSnapshot(this.turn, "afterSkill", this.units, function (u) { return _this.effectSystem.getEffectiveStats(u); }, function (u) { return _this.snapshotBuffs(u); }, function (u) { return _this.computeImbalanceMax(u); });
675
+ this.processPendingReactiveCounters();
676
+ chaseUsed.add(unit.id);
503
677
  }
504
- const chaseResult = this.executeSkill(unit, skill, "chase", triggerCtx);
505
- this.logger.logAction({
506
- turn: this.turn,
507
- actorId: unit.id,
508
- skillId: skill.id,
509
- triggeredBy: "chase",
510
- result: chaseResult
511
- });
512
- this.logger.logSnapshot(this.turn, "afterSkill", this.units, (u) => this.effectSystem.getEffectiveStats(u), (u) => this.snapshotBuffs(u), (u) => this.computeImbalanceMax(u));
513
- this.processPendingReactiveCounters();
514
- chaseUsed.add(unit.id);
515
678
  }
516
679
  }
680
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
681
+ finally {
682
+ try {
683
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
684
+ }
685
+ finally { if (e_9) throw e_9.error; }
686
+ }
517
687
  if (result.targets.length === 0) {
518
688
  return;
519
689
  }
520
- const firstTarget = this.units.find((u) => u.id === result.targets[0] && u.runtime.alive);
690
+ var firstTarget = this.units.find(function (u) { return u.id === result.targets[0] && u.runtime.alive; });
521
691
  if (!firstTarget) {
522
692
  return;
523
693
  }
524
- const allies = this.units.filter((u) => u.teamId === actor.teamId && u.id !== actor.id && u.runtime.alive);
525
- for (const ally of allies) {
526
- const chance = Math.min(10000, Math.max(0, Math.floor(ally.stats.pAR)));
527
- if (Math.floor(this.rng.next() * 10000) >= chance) {
528
- continue;
694
+ var allies = this.units.filter(function (u) { return u.teamId === actor.teamId && u.id !== actor.id && u.runtime.alive; });
695
+ try {
696
+ for (var allies_1 = __values(allies), allies_1_1 = allies_1.next(); !allies_1_1.done; allies_1_1 = allies_1.next()) {
697
+ var ally = allies_1_1.value;
698
+ var chance = Math.min(10000, Math.max(0, Math.floor(ally.stats.pAR)));
699
+ if (Math.floor(this.rng.next() * 10000) >= chance) {
700
+ continue;
701
+ }
702
+ var basic = (_c = this.getSlots(ally.id).find(function (s) { return s.definition.type === "basic"; })) === null || _c === void 0 ? void 0 : _c.definition;
703
+ if (!basic) {
704
+ continue;
705
+ }
706
+ var assistRes = this.executeSkill(ally, basic, "assist", __assign(__assign({}, triggerCtx), { sourceTargets: [firstTarget.id] }));
707
+ this.logger.logAction({
708
+ turn: this.turn,
709
+ actorId: ally.id,
710
+ skillId: basic.id,
711
+ triggeredBy: "assist",
712
+ result: assistRes
713
+ });
714
+ this.logger.logSnapshot(this.turn, "afterSkill", this.units, function (u) { return _this.effectSystem.getEffectiveStats(u); }, function (u) { return _this.snapshotBuffs(u); }, function (u) { return _this.computeImbalanceMax(u); });
715
+ this.processPendingReactiveCounters();
529
716
  }
530
- const basic = this.getSlots(ally.id).find((s) => s.definition.type === "basic")?.definition;
531
- if (!basic) {
532
- continue;
717
+ }
718
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
719
+ finally {
720
+ try {
721
+ if (allies_1_1 && !allies_1_1.done && (_b = allies_1.return)) _b.call(allies_1);
533
722
  }
534
- const assistRes = this.executeSkill(ally, basic, "assist", {
535
- ...triggerCtx,
536
- sourceTargets: [firstTarget.id]
537
- });
538
- this.logger.logAction({
539
- turn: this.turn,
540
- actorId: ally.id,
541
- skillId: basic.id,
542
- triggeredBy: "assist",
543
- result: assistRes
544
- });
545
- this.logger.logSnapshot(this.turn, "afterSkill", this.units, (u) => this.effectSystem.getEffectiveStats(u), (u) => this.snapshotBuffs(u), (u) => this.computeImbalanceMax(u));
546
- this.processPendingReactiveCounters();
723
+ finally { if (e_10) throw e_10.error; }
547
724
  }
548
- }
549
- applyDamage(sourceId, targetId, value, staggerElement, skipShare = false) {
550
- const target = this.mustUnit(targetId);
551
- const source = this.mustUnit(sourceId);
552
- this.eventBus.emit({ name: "OnBeforeDamage", payload: { sourceId, targetId, value } });
553
- this.eventBus.emit({ name: "OnDamageDealt", payload: { sourceId, targetId, value } });
554
- let damage = Math.max(0, Math.floor(value));
725
+ };
726
+ BattleCore.prototype.applyDamage = function (sourceId, targetId, value, staggerElement, skipShare) {
727
+ var _a;
728
+ if (skipShare === void 0) { skipShare = false; }
729
+ var target = this.mustUnit(targetId);
730
+ var source = this.mustUnit(sourceId);
731
+ this.eventBus.emit({ name: "OnBeforeDamage", payload: { sourceId: sourceId, targetId: targetId, value: value } });
732
+ this.eventBus.emit({ name: "OnDamageDealt", payload: { sourceId: sourceId, targetId: targetId, value: value } });
733
+ var damage = Math.max(0, Math.floor(value));
555
734
  if (!skipShare && sourceId !== targetId) {
556
- const shareBuff = this.effectSystem.getBuffs(target.id).find((buff) => buff.stacks > 0 && (buff.config.damageShareToSourceRatio ?? 0) > 0);
557
- if (shareBuff && shareBuff.sourceId !== target.id) {
558
- const shareTo = this.units.find((unit) => unit.id === shareBuff.sourceId && unit.runtime.alive);
735
+ var shareBuff_1 = this.effectSystem.getBuffs(target.id).find(function (buff) { var _a; return buff.stacks > 0 && ((_a = buff.config.damageShareToSourceRatio) !== null && _a !== void 0 ? _a : 0) > 0; });
736
+ if (shareBuff_1 && shareBuff_1.sourceId !== target.id) {
737
+ var shareTo = this.units.find(function (unit) { return unit.id === shareBuff_1.sourceId && unit.runtime.alive; });
559
738
  if (shareTo) {
560
- const ratio = Math.max(0, Math.min(1, shareBuff.config.damageShareToSourceRatio ?? 0));
561
- const sharedDamage = Math.floor(damage * ratio);
739
+ var ratio = Math.max(0, Math.min(1, (_a = shareBuff_1.config.damageShareToSourceRatio) !== null && _a !== void 0 ? _a : 0));
740
+ var sharedDamage = Math.floor(damage * ratio);
562
741
  if (sharedDamage > 0) {
563
742
  this.applyDamage(sourceId, shareTo.id, sharedDamage, undefined, true);
564
743
  damage -= sharedDamage;
@@ -567,7 +746,7 @@ export class BattleCore {
567
746
  }
568
747
  }
569
748
  if (target.runtime.Shield > 0) {
570
- const absorbed = Math.min(target.runtime.Shield, damage);
749
+ var absorbed = Math.min(target.runtime.Shield, damage);
571
750
  target.runtime.Shield -= absorbed;
572
751
  damage -= absorbed;
573
752
  }
@@ -577,45 +756,45 @@ export class BattleCore {
577
756
  this.eventBus.emit({ name: "OnDeath", payload: { targetId: target.id, sourceId: source.id } });
578
757
  this.eventBus.emit({ name: "OnKill", payload: { killerId: source.id, targetId: target.id } });
579
758
  }
580
- this.eventBus.emit({ name: "OnAfterDamage", payload: { sourceId, targetId, value: damage } });
581
- let imbalanceDelta = 0;
582
- let triggeredImbalanceBreak = false;
759
+ this.eventBus.emit({ name: "OnAfterDamage", payload: { sourceId: sourceId, targetId: targetId, value: damage } });
760
+ var imbalanceDelta = 0;
761
+ var triggeredImbalanceBreak = false;
583
762
  if (staggerElement && sourceId !== targetId && target.runtime.alive) {
584
- const staggerResult = this.accumulateStagger(source, target, staggerElement);
763
+ var staggerResult = this.accumulateStagger(source, target, staggerElement);
585
764
  imbalanceDelta = staggerResult.applied;
586
765
  triggeredImbalanceBreak = staggerResult.broke;
587
766
  }
588
- return { damage, imbalanceDelta, triggeredImbalanceBreak };
589
- }
590
- applyHeal(targetId, value) {
591
- const target = this.mustUnit(targetId);
767
+ return { damage: damage, imbalanceDelta: imbalanceDelta, triggeredImbalanceBreak: triggeredImbalanceBreak };
768
+ };
769
+ BattleCore.prototype.applyHeal = function (targetId, value) {
770
+ var target = this.mustUnit(targetId);
592
771
  if (!target.runtime.alive) {
593
772
  return 0;
594
773
  }
595
- const heal = Math.max(0, Math.floor(value));
596
- const old = target.runtime.Hp;
774
+ var heal = Math.max(0, Math.floor(value));
775
+ var old = target.runtime.Hp;
597
776
  target.runtime.Hp = Math.min(target.stats.Mhp, target.runtime.Hp + heal);
598
777
  return target.runtime.Hp - old;
599
- }
600
- applyShield(targetId, value) {
601
- const target = this.mustUnit(targetId);
778
+ };
779
+ BattleCore.prototype.applyShield = function (targetId, value) {
780
+ var target = this.mustUnit(targetId);
602
781
  if (!target.runtime.alive) {
603
782
  return 0;
604
783
  }
605
- const shield = Math.max(0, Math.floor(value));
784
+ var shield = Math.max(0, Math.floor(value));
606
785
  target.runtime.Shield += shield;
607
786
  return shield;
608
- }
609
- applyImbalanceDelta(sourceActorId, sourceSkillId, targetId, delta, reason) {
610
- const target = this.mustUnit(targetId);
787
+ };
788
+ BattleCore.prototype.applyImbalanceDelta = function (sourceActorId, sourceSkillId, targetId, delta, reason) {
789
+ var target = this.mustUnit(targetId);
611
790
  if (!target.runtime.alive || delta === 0) {
612
791
  return 0;
613
792
  }
614
- const max = this.computeImbalanceMax(target);
615
- const from = target.runtime.Imbalance;
616
- const to = Math.max(0, Math.min(max, from + Math.floor(delta)));
793
+ var max = this.computeImbalanceMax(target);
794
+ var from = target.runtime.Imbalance;
795
+ var to = Math.max(0, Math.min(max, from + Math.floor(delta)));
617
796
  target.runtime.Imbalance = to;
618
- const applied = to - from;
797
+ var applied = to - from;
619
798
  if (applied !== 0) {
620
799
  this.logger.logImbalanceChange(target.id, applied, reason, sourceActorId, sourceSkillId);
621
800
  }
@@ -623,115 +802,175 @@ export class BattleCore {
623
802
  this.pendingImbalanceClear.delete(target.id);
624
803
  }
625
804
  return applied;
626
- }
627
- computeImbalanceMax(unit) {
628
- const effectiveStats = this.effectSystem.getEffectiveStats(unit);
805
+ };
806
+ BattleCore.prototype.computeImbalanceMax = function (unit) {
807
+ var effectiveStats = this.effectSystem.getEffectiveStats(unit);
629
808
  return Math.floor(Math.floor(unit.stats.Mhp * 6000 / 10000) * (10000 + effectiveStats.pITM) / 10000);
630
- }
631
- accumulateStagger(source, target, skillElement) {
809
+ };
810
+ BattleCore.prototype.accumulateStagger = function (source, target, skillElement) {
811
+ var _a, _b, _c;
632
812
  if (this.pendingImbalanceClear.has(target.id)) {
633
813
  return { applied: 0, broke: false };
634
814
  }
635
- const effectiveSource = this.effectSystem.getEffectiveStats(source);
636
- const baseStagger = effectiveSource.Att;
637
- let stagger = Math.floor(baseStagger * (10000 + effectiveSource.pIM) / 10000);
638
- const rep = repression(source.element, target.element);
815
+ var effectiveSource = this.effectSystem.getEffectiveStats(source);
816
+ var baseStagger = effectiveSource.Att;
817
+ var stagger = Math.floor(baseStagger * (10000 + effectiveSource.pIM) / 10000);
818
+ var rep = repression(source.element, target.element);
639
819
  if (rep === 1) {
640
820
  stagger = Math.floor(stagger * 13000 / 10000);
641
821
  }
642
822
  else if (rep === -1) {
643
823
  stagger = Math.floor(stagger * 7000 / 10000);
644
824
  }
645
- const takenRate = 10000 + this.effectSystem.getImbalanceTakenRate(target.id);
825
+ var takenRate = 10000 + this.effectSystem.getImbalanceTakenRate(target.id);
646
826
  stagger = Math.max(0, Math.floor(stagger * takenRate / 10000));
647
- const max = this.computeImbalanceMax(target);
648
- const from = target.runtime.Imbalance;
827
+ var max = this.computeImbalanceMax(target);
828
+ var from = target.runtime.Imbalance;
649
829
  target.runtime.Imbalance = Math.min(max, from + stagger);
650
- const applied = target.runtime.Imbalance - from;
830
+ var applied = target.runtime.Imbalance - from;
651
831
  if (applied !== 0) {
652
- this.logger.logImbalanceChange(target.id, applied, "skill_effect", this.activeSkillContext?.actorId ?? source.id, this.activeSkillContext?.skillId);
832
+ this.logger.logImbalanceChange(target.id, applied, "skill_effect", (_b = (_a = this.activeSkillContext) === null || _a === void 0 ? void 0 : _a.actorId) !== null && _b !== void 0 ? _b : source.id, (_c = this.activeSkillContext) === null || _c === void 0 ? void 0 : _c.skillId);
653
833
  }
654
- let broke = false;
834
+ var broke = false;
655
835
  if (target.runtime.Imbalance >= max) {
656
836
  broke = true;
657
837
  this.onImbalanceBreak(source, target, skillElement);
658
838
  }
659
- return { applied, broke };
660
- }
661
- onImbalanceBreak(source, target, element) {
662
- const max = this.computeImbalanceMax(target);
839
+ return { applied: applied, broke: broke };
840
+ };
841
+ BattleCore.prototype.onImbalanceBreak = function (source, target, element) {
842
+ var e_11, _a;
843
+ var max = this.computeImbalanceMax(target);
663
844
  target.runtime.Imbalance = max;
664
845
  this.pendingImbalanceClear.add(target.id);
665
- const breakBuffs = this.effectSystem
846
+ var breakBuffs = this.effectSystem
666
847
  .getBuffConfigs()
667
- .filter((buff) => buff.applyOnImbalanceBreak || buff.applyOnElementBreakElements?.includes(element));
668
- const appliedBuffIds = new Set();
669
- for (const breakBuff of breakBuffs) {
670
- if (appliedBuffIds.has(breakBuff.id)) {
671
- continue;
848
+ .filter(function (buff) { var _a; return buff.applyOnImbalanceBreak || ((_a = buff.applyOnElementBreakElements) === null || _a === void 0 ? void 0 : _a.includes(element)); });
849
+ var appliedBuffIds = new Set();
850
+ try {
851
+ for (var breakBuffs_1 = __values(breakBuffs), breakBuffs_1_1 = breakBuffs_1.next(); !breakBuffs_1_1.done; breakBuffs_1_1 = breakBuffs_1.next()) {
852
+ var breakBuff = breakBuffs_1_1.value;
853
+ if (appliedBuffIds.has(breakBuff.id)) {
854
+ continue;
855
+ }
856
+ appliedBuffIds.add(breakBuff.id);
857
+ this.applyBuff(source.id, target.id, breakBuff.id);
672
858
  }
673
- appliedBuffIds.add(breakBuff.id);
674
- this.applyBuff(source.id, target.id, breakBuff.id);
675
859
  }
676
- this.eventBus.emit({ name: "OnImbalanceBreak", payload: { sourceId: source.id, targetId: target.id, element } });
860
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
861
+ finally {
862
+ try {
863
+ if (breakBuffs_1_1 && !breakBuffs_1_1.done && (_a = breakBuffs_1.return)) _a.call(breakBuffs_1);
864
+ }
865
+ finally { if (e_11) throw e_11.error; }
866
+ }
867
+ this.eventBus.emit({ name: "OnImbalanceBreak", payload: { sourceId: source.id, targetId: target.id, element: element } });
677
868
  this.logger.logImbalanceBreak(target.id, source.id, element);
678
- }
679
- applyBuff(sourceId, targetId, buffId) {
680
- const target = this.mustUnit(targetId);
869
+ };
870
+ BattleCore.prototype.applyBuff = function (sourceId, targetId, buffId) {
871
+ var target = this.mustUnit(targetId);
681
872
  this.effectSystem.addBuff(target, sourceId, buffId);
682
- }
683
- applyTurnStart(actor) {
873
+ };
874
+ BattleCore.prototype.applyTurnStart = function (actor) {
875
+ var e_12, _a;
684
876
  if (this.pendingImbalanceClear.has(actor.id)) {
685
- const from = actor.runtime.Imbalance;
877
+ var from = actor.runtime.Imbalance;
686
878
  actor.runtime.Imbalance = 0;
687
879
  this.pendingImbalanceClear.delete(actor.id);
688
880
  this.logger.logImbalanceChange(actor.id, -from, "turn_start_clear", actor.id);
689
881
  }
690
- const dotEvents = this.effectSystem.onTurnStart(actor, this.units);
691
- for (const dot of dotEvents) {
692
- this.applyDamage(actor.id, dot.targetId, dot.value);
693
- // 记录DOT伤害到logger,用于飘字展示
694
- this.logger.logDotDamage(dot.targetId, dot.value, dot.buffId, dot.element);
882
+ var dotEvents = this.effectSystem.onTurnStart(actor, this.units);
883
+ try {
884
+ for (var dotEvents_1 = __values(dotEvents), dotEvents_1_1 = dotEvents_1.next(); !dotEvents_1_1.done; dotEvents_1_1 = dotEvents_1.next()) {
885
+ var dot = dotEvents_1_1.value;
886
+ this.applyDamage(actor.id, dot.targetId, dot.value);
887
+ // 记录DOT伤害到logger,用于飘字展示
888
+ this.logger.logDotDamage(dot.targetId, dot.value, dot.buffId, dot.element);
889
+ }
890
+ }
891
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
892
+ finally {
893
+ try {
894
+ if (dotEvents_1_1 && !dotEvents_1_1.done && (_a = dotEvents_1.return)) _a.call(dotEvents_1);
895
+ }
896
+ finally { if (e_12) throw e_12.error; }
695
897
  }
696
898
  this.rearrangePositions();
697
- }
698
- applyTurnEnd(actor) {
899
+ };
900
+ BattleCore.prototype.applyTurnEnd = function (actor) {
699
901
  this.effectSystem.onTurnEnd(actor, this.units);
700
902
  this.rearrangePositions();
701
- }
702
- gainEnergy(actor, value) {
903
+ };
904
+ BattleCore.prototype.gainEnergy = function (actor, value) {
703
905
  this.gainEnergyToUnit(actor.id, value);
704
- }
705
- gainEnergyToUnit(unitId, value) {
706
- const actor = this.mustUnit(unitId);
707
- const ratio = 10000 + actor.stats.pER;
708
- const gain = Math.floor((Math.max(0, value) * ratio) / 10000);
906
+ };
907
+ BattleCore.prototype.gainEnergyToUnit = function (unitId, value) {
908
+ var actor = this.mustUnit(unitId);
909
+ var ratio = 10000 + actor.stats.pER;
910
+ var gain = Math.floor((Math.max(0, value) * ratio) / 10000);
709
911
  actor.runtime.Energy = Math.min(actor.runtime.EnergyMax, actor.runtime.Energy + gain);
710
- }
711
- decrementAllCooldowns(actorId) {
712
- for (const [id, slots] of this.skillSlots.entries()) {
713
- if (id !== actorId) {
714
- continue;
912
+ };
913
+ BattleCore.prototype.decrementAllCooldowns = function (actorId) {
914
+ var e_13, _a, e_14, _b;
915
+ try {
916
+ for (var _c = __values(this.skillSlots.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
917
+ var _e = __read(_d.value, 2), id = _e[0], slots = _e[1];
918
+ if (id !== actorId) {
919
+ continue;
920
+ }
921
+ try {
922
+ for (var slots_3 = (e_14 = void 0, __values(slots)), slots_3_1 = slots_3.next(); !slots_3_1.done; slots_3_1 = slots_3.next()) {
923
+ var slot = slots_3_1.value;
924
+ slot.cooldownRemain = Math.max(0, slot.cooldownRemain - 1);
925
+ }
926
+ }
927
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
928
+ finally {
929
+ try {
930
+ if (slots_3_1 && !slots_3_1.done && (_b = slots_3.return)) _b.call(slots_3);
931
+ }
932
+ finally { if (e_14) throw e_14.error; }
933
+ }
715
934
  }
716
- for (const slot of slots) {
717
- slot.cooldownRemain = Math.max(0, slot.cooldownRemain - 1);
935
+ }
936
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
937
+ finally {
938
+ try {
939
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
718
940
  }
941
+ finally { if (e_13) throw e_13.error; }
719
942
  }
720
- }
721
- getSlots(unitId) {
722
- return this.skillSlots.get(unitId) ?? [];
723
- }
724
- rearrangePositions() {
725
- for (const teamId of [1, 2]) {
726
- const alive = this.units.filter((u) => u.teamId === teamId && u.runtime.alive).sort((a, b) => a.position - b.position);
727
- alive.forEach((u, idx) => {
943
+ };
944
+ BattleCore.prototype.getSlots = function (unitId) {
945
+ var _a;
946
+ return (_a = this.skillSlots.get(unitId)) !== null && _a !== void 0 ? _a : [];
947
+ };
948
+ BattleCore.prototype.rearrangePositions = function () {
949
+ var e_15, _a;
950
+ var _loop_6 = function (teamId) {
951
+ var alive = this_5.units.filter(function (u) { return u.teamId === teamId && u.runtime.alive; }).sort(function (a, b) { return a.position - b.position; });
952
+ alive.forEach(function (u, idx) {
728
953
  u.position = (idx + 1);
729
954
  });
955
+ };
956
+ var this_5 = this;
957
+ try {
958
+ for (var _b = __values([1, 2]), _c = _b.next(); !_c.done; _c = _b.next()) {
959
+ var teamId = _c.value;
960
+ _loop_6(teamId);
961
+ }
730
962
  }
731
- }
732
- winner() {
733
- const t1Alive = this.units.some((u) => u.teamId === 1 && u.runtime.alive);
734
- const t2Alive = this.units.some((u) => u.teamId === 2 && u.runtime.alive);
963
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
964
+ finally {
965
+ try {
966
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
967
+ }
968
+ finally { if (e_15) throw e_15.error; }
969
+ }
970
+ };
971
+ BattleCore.prototype.winner = function () {
972
+ var t1Alive = this.units.some(function (u) { return u.teamId === 1 && u.runtime.alive; });
973
+ var t2Alive = this.units.some(function (u) { return u.teamId === 2 && u.runtime.alive; });
735
974
  if (!t1Alive && !t2Alive) {
736
975
  return 0;
737
976
  }
@@ -742,14 +981,14 @@ export class BattleCore {
742
981
  return 1;
743
982
  }
744
983
  return 0;
745
- }
746
- resolveWinnerByRule() {
747
- const w = this.winner();
984
+ };
985
+ BattleCore.prototype.resolveWinnerByRule = function () {
986
+ var w = this.winner();
748
987
  if (w) {
749
988
  return w;
750
989
  }
751
- const t1 = this.hpRatio(1);
752
- const t2 = this.hpRatio(2);
990
+ var t1 = this.hpRatio(1);
991
+ var t2 = this.hpRatio(2);
753
992
  if (t1 > t2) {
754
993
  return 1;
755
994
  }
@@ -757,35 +996,37 @@ export class BattleCore {
757
996
  return 2;
758
997
  }
759
998
  return 2;
760
- }
761
- hpRatio(teamId) {
762
- const team = this.units.filter((u) => u.teamId === teamId);
763
- const hp = team.reduce((sum, u) => sum + Math.max(0, u.runtime.Hp), 0);
764
- const mhp = team.reduce((sum, u) => sum + u.stats.Mhp, 0);
999
+ };
1000
+ BattleCore.prototype.hpRatio = function (teamId) {
1001
+ var team = this.units.filter(function (u) { return u.teamId === teamId; });
1002
+ var hp = team.reduce(function (sum, u) { return sum + Math.max(0, u.runtime.Hp); }, 0);
1003
+ var mhp = team.reduce(function (sum, u) { return sum + u.stats.Mhp; }, 0);
765
1004
  return mhp > 0 ? hp / mhp : 0;
766
- }
767
- mustUnit(id) {
768
- const unit = this.units.find((u) => u.id === id);
1005
+ };
1006
+ BattleCore.prototype.mustUnit = function (id) {
1007
+ var unit = this.units.find(function (u) { return u.id === id; });
769
1008
  if (!unit) {
770
- throw new Error(`unit-not-found:${id}`);
1009
+ throw new Error("unit-not-found:".concat(id));
771
1010
  }
772
1011
  return unit;
773
- }
774
- maxUltimateCost(skills) {
775
- const ult = skills.find((s) => s.type === "ultimate");
1012
+ };
1013
+ BattleCore.prototype.maxUltimateCost = function (skills) {
1014
+ var ult = skills.find(function (s) { return s.type === "ultimate"; });
776
1015
  return ult ? ult.energyCost : 100;
777
- }
778
- snapshotBuffs(unit) {
1016
+ };
1017
+ BattleCore.prototype.snapshotBuffs = function (unit) {
779
1018
  return this.effectSystem
780
1019
  .getBuffs(unit.id)
781
- .filter((b) => b.stacks > 0 && b.remainingRounds > 0)
782
- .sort((a, b) => a.id.localeCompare(b.id))
783
- .map((b) => ({
1020
+ .filter(function (b) { return b.stacks > 0 && b.remainingRounds > 0; })
1021
+ .sort(function (a, b) { return a.id.localeCompare(b.id); })
1022
+ .map(function (b) { return ({
784
1023
  id: b.id,
785
1024
  name: b.config.name,
786
1025
  stacks: b.stacks,
787
1026
  remainingRounds: b.remainingRounds,
788
1027
  sourceId: b.sourceId
789
- }));
790
- }
791
- }
1028
+ }); });
1029
+ };
1030
+ return BattleCore;
1031
+ }());
1032
+ export { BattleCore };