Skip to content

Commit

Permalink
feat(combat): add UI notificaiton if an enemy has no encounter data
Browse files Browse the repository at this point in the history
  • Loading branch information
justindujardin committed Oct 25, 2022
1 parent efc1ea7 commit b6b3617
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/app/routes/world/map/features/combat-feature.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { List } from 'immutable';
import { map, take } from 'rxjs/operators';
import { IEnemy } from '../../../../../app/models/base-entity';
import { AppState } from '../../../../app.model';
import { NotificationService } from '../../../../components/notification/notification.service';
import { Point } from '../../../../core';
import { CombatEncounterAction } from '../../../../models/combat/combat.actions';
import { CombatEncounter, IZoneMatch } from '../../../../models/combat/combat.model';
Expand Down Expand Up @@ -52,7 +53,7 @@ export class CombatFeatureComponent extends TiledFeatureComponent {
// @ts-ignore
@Input() feature: TiledMapFeatureData;

constructor(public store: Store<AppState>) {
constructor(public store: Store<AppState>, public notify: NotificationService) {
super();
}

Expand Down Expand Up @@ -88,6 +89,15 @@ export class CombatFeatureComponent extends TiledFeatureComponent {
const encounter: ITemplateFixedEncounter = getFixedEncounterById(
this.properties.id
);

if (!encounter) {
this.notify.show(
`There is no encounter named: ${this.properties.id}.`,
null,
0
);
return;
}
const toCombatant = (id: string): IEnemy => {
const itemTemplate: IEnemy = getEnemyById(id) as any;
return instantiateEntity<IEnemy>(itemTemplate, {
Expand Down

0 comments on commit b6b3617

Please sign in to comment.