Skip to content

Commit

Permalink
fix(combat): fix npe for post-combat items
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Sep 26, 2023
1 parent a3f1735 commit bde561d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/app/pages/explore/explore.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<div class="formation-count">
{{
actionInfo.actionData.formation.monsters.length
}} monsters
}} monster(s)
</div>
</ion-col>
</ion-row>
Expand Down
9 changes: 6 additions & 3 deletions server/src/modules/fight/fight.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ICombatTargetParams,
IFightCharacter,
IFightTile,
IItem,
IMonster,
IMonsterFormation,
TrackedStat,
Expand Down Expand Up @@ -349,14 +350,16 @@ export class FightService {
.filter(Boolean),
);

let randomDrop;
let randomDrop: IItem | undefined;

if (
randomDropPossibility &&
random(0, 100) <= randomDropPossibility.chance
) {
randomDrop = this.contentService.getItem(randomDropPossibility.item);
addStatusMessage(fight, 'Fight', `You found "${randomDrop.name}"!`);
if (randomDrop) {
addStatusMessage(fight, 'Fight', `You found "${randomDrop.name}"!`);
}
}

if (isWin && fight.defenders.length > 0) {
Expand All @@ -368,7 +371,7 @@ export class FightService {
`Fight ${
fight.internalId
} rewarded ${xpDelta} XP and ${coinDelta} coins and ${
randomDrop?.item ?? 'no'
randomDrop?.name ?? 'no'
} item drop.`,
);

Expand Down

0 comments on commit bde561d

Please sign in to comment.