animation

This commit is contained in:
Bastian Wagner
2026-08-19 23:24:36 +02:00
parent 76e8ef4320
commit fd9852bfbf
9 changed files with 220 additions and 92 deletions

View File

@@ -1,4 +1,4 @@
import { runtimeMonsterArtworkPath } from './monster-artwork';
import { monsterCutoutPath, monsterIconPath, runtimeMonsterArtworkPath } from './monster-artwork';
describe('runtimeMonsterArtworkPath', () => {
it('returns the optimized JPEG derivative for a known monster artwork path', () => {
@@ -11,3 +11,25 @@ describe('runtimeMonsterArtworkPath', () => {
expect(runtimeMonsterArtworkPath('/images/enemies/Dawnwolf.png')).toBeUndefined();
});
});
describe('monsterCutoutPath', () => {
it('returns the background-free cut-out for a known monster key', () => {
expect(monsterCutoutPath('ash-rat')).toBe('/images/combat/sprites/ash-rat-760.png');
expect(monsterCutoutPath('road-bandit')).toBe('/images/combat/sprites/road-bandit-620.png');
});
it('returns undefined for a monster without a cut-out', () => {
expect(monsterCutoutPath('dawnwolf')).toBeUndefined();
});
});
describe('monsterIconPath', () => {
it('returns the medallion icon for a known monster key', () => {
expect(monsterIconPath('ash-rat')).toBe('/images/combat/icons/ash-rat-128.png');
expect(monsterIconPath('road-bandit')).toBe('/images/combat/icons/road-bandit-128.png');
});
it('returns undefined for a monster without an icon', () => {
expect(monsterIconPath('dawnwolf')).toBeUndefined();
});
});

View File

@@ -7,12 +7,14 @@ export function runtimeMonsterArtworkPath(artworkPath: string): string | undefin
return RUNTIME_MONSTER_ARTWORK[artworkPath];
}
const COMBAT_MONSTER_SPRITE: Readonly<Record<string, string>> = {
// Background-free body art and medallion icons, shared by the combat stage
// and the hunt encounter cards.
const MONSTER_CUTOUT: Readonly<Record<string, string>> = {
'ash-rat': '/images/combat/sprites/ash-rat-760.png',
'road-bandit': '/images/combat/sprites/road-bandit-620.png',
};
const COMBAT_MONSTER_ICON: Readonly<Record<string, string>> = {
const MONSTER_ICON: Readonly<Record<string, string>> = {
'ash-rat': '/images/combat/icons/ash-rat-128.png',
'road-bandit': '/images/combat/icons/road-bandit-128.png',
};
@@ -26,14 +28,14 @@ const COMBAT_MONSTER_SCALE: Readonly<Record<string, number>> = {
const DEFAULT_MONSTER_SCALE = 0.6;
export function combatMonsterSpritePath(monsterKey: string): string | undefined {
return COMBAT_MONSTER_SPRITE[monsterKey];
export function monsterCutoutPath(monsterKey: string): string | undefined {
return MONSTER_CUTOUT[monsterKey];
}
export function combatMonsterSpriteScale(monsterKey: string): number {
return COMBAT_MONSTER_SCALE[monsterKey] ?? DEFAULT_MONSTER_SCALE;
}
export function combatMonsterIconPath(monsterKey: string): string | undefined {
return COMBAT_MONSTER_ICON[monsterKey];
export function monsterIconPath(monsterKey: string): string | undefined {
return MONSTER_ICON[monsterKey];
}