Skip to content

Commit fac61d6

Browse files
committed
bugs to dev
1 parent c7309b4 commit fac61d6

22 files changed

Lines changed: 598 additions & 529 deletions

File tree

src/classes/components/combat/CombatController.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,18 +460,20 @@ class CombatController implements ICounterContainer, IStatContainer {
460460
value: number,
461461
ap: boolean = false,
462462
irreducible = false,
463-
reliable = 0
463+
reliable = 0,
464+
direct = false
464465
): { total: number; resist: string[]; condition: string[] } {
465-
return this.DamageController.CalculateDamage(type, value, ap, irreducible, reliable)
466+
return this.DamageController.CalculateDamage(type, value, ap, irreducible, reliable, direct)
466467
}
467468

468469
public TakeDamage(
469470
type: DamageType,
470471
value: number,
471472
ap: boolean = false,
472-
irreducible = false
473+
irreducible = false,
474+
direct = false
473475
): void {
474-
this.DamageController.TakeDamage(type, value, ap, irreducible)
476+
this.DamageController.TakeDamage(type, value, ap, irreducible, direct)
475477
}
476478

477479
public ApplyDamage(type: DamageType, value: number): void {

src/classes/components/combat/DamageController.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ class DamageController {
1313
return this._parent.ActiveActor.CombatController
1414
}
1515

16+
private resolveTarget(direct: boolean): CombatController {
17+
return direct ? this._parent : this._parent.ActiveActor.CombatController
18+
}
19+
1620
public CalculateArmorReduction(
1721
type: DamageType,
1822
value: number,
1923
ap: boolean,
20-
irreducible: boolean
24+
irreducible: boolean,
25+
direct = false
2126
): number {
2227
if (
2328
irreducible ||
@@ -27,15 +32,16 @@ class DamageController {
2732
type === DamageType.AppliedBurn
2833
)
2934
return 0
30-
return this._parent.ActiveActor.StatController.getCurrent(StatKey.ARMOR) || 0
35+
return this.resolveTarget(direct).StatController.getCurrent(StatKey.ARMOR) || 0
3136
}
3237

3338
public CalculateDamage(
3439
type: DamageType,
3540
value: number,
3641
ap: boolean = false,
3742
irreducible = false,
38-
reliable = 0
43+
reliable = 0,
44+
direct = false
3945
): { total: number; resist: string[]; condition: string[] } {
4046
const out = { total: value, resist: [] as string[], condition: [] as string[] }
4147

@@ -60,9 +66,14 @@ class DamageController {
6066

6167
if (irreducible) return out
6268

63-
out.total = Math.max(0, out.total - this.CalculateArmorReduction(type, value, ap, irreducible))
69+
out.total = Math.max(
70+
0,
71+
out.total - this.CalculateArmorReduction(type, value, ap, irreducible, direct)
72+
)
6473

65-
const resist = this._active.Resistances.find(r => r.type === type.toLowerCase())
74+
const resist = this.resolveTarget(direct).Resistances.find(
75+
r => r.type === type.toLowerCase()
76+
)
6677

6778
if (resist) {
6879
if (resist.condition === 'vulnerable') {
@@ -88,30 +99,33 @@ class DamageController {
8899
type: DamageType,
89100
value: number,
90101
ap: boolean = false,
91-
irreducible = false
102+
irreducible = false,
103+
direct = false
92104
): void {
93105
if (this._parent.SaveLock) return
94106

107+
const target = this.resolveTarget(direct)
108+
95109
if (
96110
type === DamageType.Heat.toLowerCase() &&
97-
!this._parent.ActiveActor.StatController.getMax(StatKey.STRESS)
111+
!target.StatController.getMax(StatKey.STRESS)
98112
) {
99113
type = DamageType.Energy
100114
}
101115

102-
const damage = this.CalculateDamage(type, value, ap, irreducible)
116+
const damage = this.CalculateDamage(type, value, ap, irreducible, 0, direct)
103117

104-
this.ApplyDamage(type, damage.total)
118+
this.ApplyDamage(type, damage.total, direct)
105119

106120
this._parent.CombatLog.TakeDamage(value, type)
107121
this._parent.CombatLog.ArmorReduced(
108-
this.CalculateArmorReduction(type, value, ap, irreducible)
122+
this.CalculateArmorReduction(type, value, ap, irreducible, direct)
109123
)
110124
if (this._parent.IsDestroyed) this._parent.CombatLog.LoseMech()
111125
}
112126

113-
public ApplyDamage(type: DamageType, value: number): void {
114-
const target = this._active
127+
public ApplyDamage(type: DamageType, value: number, direct = false): void {
128+
const target = this.resolveTarget(direct)
115129

116130
if (type.toLowerCase() === DamageType.Heat.toLowerCase()) {
117131
target.ApplyHeat(value)
@@ -139,9 +153,9 @@ class DamageController {
139153
}
140154
}
141155

142-
this._parent.ActiveActor.StatController.setCurrentStat(
156+
target.StatController.setCurrentStat(
143157
StatKey.HP,
144-
this._parent.ActiveActor.StatController.getCurrent(StatKey.HP) - value
158+
target.StatController.getCurrent(StatKey.HP) - value
145159
)
146160
this._parent.log(`Took ${value} ${type} damage`)
147161
this._parent.CombatLog.StatChange(-value, 'hp')

src/classes/components/combat/ICombatant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface ICombatant {
2424
SaveController: SaveController
2525
FeatureController: FeatureController
2626
CombatController: CombatController
27+
StatController: StatController
2728

2829
SetStats(): void
2930

@@ -40,7 +41,6 @@ interface ICombatant {
4041
ActiveLayerIndex?: number
4142
IsLinked?: boolean
4243
IsNameless?: boolean
43-
StatController?: StatController
4444
ActiveMech?: Mech
4545
Mechs?: Mech[]
4646
ActiveLayer?: EidolonLayer

src/classes/components/feature/bonus/Bonus.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Bonus {
3535
public readonly Condition: string | undefined
3636

3737
public constructor(data: IBonusData, source: string) {
38+
if (data.id === 'size') console.log(data)
3839
const entry = getBonusDictionary().find(x => x.id === data.id)
3940
this.ID = data.id || 'UNKNOWN_BONUS'
4041
this.Source = source
@@ -74,7 +75,7 @@ class Bonus {
7475
return str
7576
}
7677

77-
if (this.Overwrite) str = str.replace(/{INC_DEC}/g, 'Sets').replace('by', 'to')
78+
if (this.Overwrite) str = str.replace(/{BY_TO}/g, 'Sets').replace('by', 'to')
7879

7980
const repNum = Array.isArray(this.Value)
8081
? Number(this.Value[0])

src/classes/enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ enum DamageType {
154154
Burn = 'Burn',
155155
AppliedBurn = 'Applied Burn', // for dealing burn damage without incrementing burn stack
156156
Variable = 'Variable',
157+
AoE = 'AoE',
157158
}
158159

159160
enum MechType {

src/features/active_mode/runner/gm/EncounterPanels/PilotPanel.vue

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,15 @@ import PanelBase from './_PanelBase.vue';
137137
import PilotActionsPanel from './_components/PilotActionsPanel.vue';
138138
import PilotCombatLoadout from './_components/loadouts/PilotCombatLoadout.vue';
139139
import DeployButton from './_components/loadouts/_deployButton.vue';
140-
import { EncounterInstance } from '@/classes/encounter/EncounterInstance.js';
140+
import type { EncounterInstance } from '@/classes/encounter/EncounterInstance';
141141
142-
const props = defineProps({
143-
combatant: {
144-
type: Object,
145-
required: true,
146-
},
147-
encounterInstance: {
148-
type: EncounterInstance,
149-
required: true,
150-
},
151-
})
142+
const props = defineProps<{
143+
combatant: CombatantData
144+
encounterInstance: EncounterInstance
145+
}>()
152146
153147
provide(EncounterContextKey, {
154-
owner: computed(() => props.combatant as CombatantData),
148+
owner: computed(() => props.combatant),
155149
encounterInstance: computed(() => props.encounterInstance),
156150
})
157151

0 commit comments

Comments
 (0)