|
1 | | -// Comments in English |
2 | 1 | export class ABFCombatResultData { |
3 | 2 | /** @param {Partial<ABFCombatResultData>} p */ |
4 | 3 | constructor(p = {}) { |
5 | | - this.difference = p.difference ?? 0; // Diferencia |
| 4 | + this.difference = p.difference ?? 0; // Diferencia |
6 | 5 | this.counterAttackValue = p.counterAttackValue ?? 0; // Valor de contraataque |
7 | 6 | this.hasCounterAttack = p.hasCounterAttack ?? false; // ¿Hay contraataque? |
8 | | - this.damageFinal = p.damageFinal ?? 0; // Daño final |
| 7 | + this.damageFinal = p.damageFinal ?? 0; // Daño final |
9 | 8 | this.lifePercentRemoved = p.lifePercentRemoved ?? 0; // % de vida quitada |
10 | | - this.isCritical = p.isCritical ?? false; // ¿Es crítico? |
| 9 | + this.isCritical = p.isCritical ?? false; // ¿Es crítico? |
11 | 10 | this.baseCriticalValue = p.baseCriticalValue ?? 0; // Valor base del crítico |
12 | | - this.attackBreak = p.attackBreak ?? 0; // Rotura del ataque |
| 11 | + this.attackBreak = p.attackBreak ?? 0; // Rotura del ataque |
13 | 12 | } |
14 | 13 |
|
15 | | - toJSON() { return { ...this }; } |
| 14 | + toJSON() { |
| 15 | + return { ...this }; |
| 16 | + } |
16 | 17 |
|
17 | 18 | static fromJSON(json) { |
18 | 19 | const obj = typeof json === 'string' ? JSON.parse(json) : json; |
19 | 20 | return new ABFCombatResultData(obj); |
20 | 21 | } |
21 | 22 |
|
22 | 23 | /** Fluent builder */ |
23 | | - static builder() { return new ABFCombatResultDataBuilder(); } |
| 24 | + static builder() { |
| 25 | + return new ABFCombatResultDataBuilder(); |
| 26 | + } |
24 | 27 | } |
25 | 28 |
|
26 | 29 | export class ABFCombatResultDataBuilder { |
27 | | - constructor() { this._p = {}; } |
| 30 | + constructor() { |
| 31 | + this._p = {}; |
| 32 | + } |
28 | 33 |
|
29 | | - difference(v) { this._p.difference = Number(v) || 0; return this; } |
30 | | - counterAttackValue(v) { this._p.counterAttackValue = Number(v) || 0; return this; } |
31 | | - hasCounterAttack(v) { this._p.hasCounterAttack = !!v; return this; } |
32 | | - damageFinal(v) { this._p.damageFinal = Number(v) || 0; return this; } |
33 | | - lifePercentRemoved(v) { this._p.lifePercentRemoved = Number(v) || 0; return this; } |
34 | | - isCritical(v) { this._p.isCritical = !!v; return this; } |
35 | | - baseCriticalValue(v) { this._p.baseCriticalValue = Number(v) || 0; return this; } |
36 | | - attackBreak(v) { this._p.attackBreak = Number(v) || 0; return this; } |
| 34 | + difference(v) { |
| 35 | + this._p.difference = Number(v) || 0; |
| 36 | + return this; |
| 37 | + } |
| 38 | + counterAttackValue(v) { |
| 39 | + this._p.counterAttackValue = Number(v) || 0; |
| 40 | + return this; |
| 41 | + } |
| 42 | + hasCounterAttack(v) { |
| 43 | + this._p.hasCounterAttack = !!v; |
| 44 | + return this; |
| 45 | + } |
| 46 | + damageFinal(v) { |
| 47 | + this._p.damageFinal = Number(v) || 0; |
| 48 | + return this; |
| 49 | + } |
| 50 | + lifePercentRemoved(v) { |
| 51 | + this._p.lifePercentRemoved = Number(v) || 0; |
| 52 | + return this; |
| 53 | + } |
| 54 | + isCritical(v) { |
| 55 | + this._p.isCritical = !!v; |
| 56 | + return this; |
| 57 | + } |
| 58 | + baseCriticalValue(v) { |
| 59 | + this._p.baseCriticalValue = Number(v) || 0; |
| 60 | + return this; |
| 61 | + } |
| 62 | + attackBreak(v) { |
| 63 | + this._p.attackBreak = Number(v) || 0; |
| 64 | + return this; |
| 65 | + } |
37 | 66 |
|
38 | | - build() { return new ABFCombatResultData(this._p); } |
| 67 | + build() { |
| 68 | + return new ABFCombatResultData(this._p); |
| 69 | + } |
39 | 70 | } |
0 commit comments