Skip to content

Commit

Permalink
oopsy: add IsImmune to OopsyData (quisquous#5750)
Browse files Browse the repository at this point in the history
  • Loading branch information
g0shu authored Aug 5, 2023
1 parent 928d96a commit 85f3ef1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface OopsyData {
role: Role;
party: PartyTracker;
inCombat: boolean;
IsImmune: (x?: string) => boolean;
ShortName: (x?: string) => string;
IsPlayerId: (x?: string) => boolean;
DamageFromMatches: (matches: NetMatches['Ability']) => number;
Expand Down
7 changes: 7 additions & 0 deletions ui/oopsyraidsy/damage_tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ export class DamageTracker {
role: this.role,
party: this.playerStateTracker.partyTracker,
inCombat: this.inCombat,
IsImmune: (targetId?: string) => {
// 52 = hallowed, 199 = holmgang, 32A = living, 32B = walking, 72C = bolide
const invulnIds = ['52', '199', '32A', '32B', '72C'];
if (this.playerStateTracker.HasEffect(targetId, invulnIds))
return true;
return false;
},
ShortName: (name?: string) => ShortNamify(name, this.options.PlayerNicks),
IsPlayerId: IsPlayerId,
DamageFromMatches: (matches: NetMatches['Ability']) => UnscrambleDamage(matches?.damage),
Expand Down
15 changes: 15 additions & 0 deletions ui/oopsyraidsy/player_state_tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,21 @@ export class PlayerStateTracker {
delete this.trackedEffectMap[targetId]?.[effectId];
}

HasEffect(targetId: string | undefined, effectId: string | string[] | undefined): boolean {
if (targetId === undefined || effectId === undefined)
return false;
if (typeof effectId === 'string') {
if (this.trackedEffectMap[targetId]?.[effectId])
return true;
} else {
for (const effect of effectId) {
if (this.trackedEffectMap[targetId]?.[effect])
return true;
}
}
return false;
}

OnDeathReason(timestamp: number, reason: OopsyDeathReason): void {
const targetId = reason.id;
if (!targetId || !IsPlayerId(targetId))
Expand Down

0 comments on commit 85f3ef1

Please sign in to comment.