refactor(web): extract shared runtime monster-artwork lookup
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { HuntEncounter } from '../../../core/api/game-api.models';
|
||||
import { runtimeMonsterArtworkPath } from '../../../shared/monster-artwork';
|
||||
import { DangerBadgeComponent } from '../../../shared/danger-badge/danger-badge.component';
|
||||
|
||||
const runtimeArtworkPaths: Readonly<Record<string, string>> = {
|
||||
'/images/monsters/ash-rat.png': '/images/monsters/runtime/ash-rat-560.jpg',
|
||||
'/images/monsters/road-bandit.png': '/images/monsters/runtime/road-bandit-560.jpg',
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-encounter-card',
|
||||
imports: [DangerBadgeComponent],
|
||||
@@ -22,6 +18,6 @@ export class EncounterCardComponent {
|
||||
}
|
||||
|
||||
protected runtimeArtworkPath(artworkPath: string): string | undefined {
|
||||
return runtimeArtworkPaths[artworkPath];
|
||||
return runtimeMonsterArtworkPath(artworkPath);
|
||||
}
|
||||
}
|
||||
|
||||
13
apps/web/src/app/shared/monster-artwork.spec.ts
Normal file
13
apps/web/src/app/shared/monster-artwork.spec.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { runtimeMonsterArtworkPath } from './monster-artwork';
|
||||
|
||||
describe('runtimeMonsterArtworkPath', () => {
|
||||
it('returns the optimized JPEG derivative for a known monster artwork path', () => {
|
||||
expect(runtimeMonsterArtworkPath('/images/monsters/ash-rat.png')).toBe(
|
||||
'/images/monsters/runtime/ash-rat-560.jpg',
|
||||
);
|
||||
});
|
||||
|
||||
it('returns undefined for an artwork path with no runtime derivative', () => {
|
||||
expect(runtimeMonsterArtworkPath('/images/enemies/Dawnwolf.png')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
8
apps/web/src/app/shared/monster-artwork.ts
Normal file
8
apps/web/src/app/shared/monster-artwork.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
const RUNTIME_MONSTER_ARTWORK: Readonly<Record<string, string>> = {
|
||||
'/images/monsters/ash-rat.png': '/images/monsters/runtime/ash-rat-560.jpg',
|
||||
'/images/monsters/road-bandit.png': '/images/monsters/runtime/road-bandit-560.jpg',
|
||||
};
|
||||
|
||||
export function runtimeMonsterArtworkPath(artworkPath: string): string | undefined {
|
||||
return RUNTIME_MONSTER_ARTWORK[artworkPath];
|
||||
}
|
||||
Reference in New Issue
Block a user