feat: add hunt/monster domain entities and pure danger-rating helper
Adds Task 1 of Playable Slice 0.2: pure entity/enum/helper definitions for the Hunt/Encounter system (MonsterDefinition, LocationMonster, Hunt, HuntEncounter, EncounterType, HuntStatus, RandomSource, DangerRating). No DB migration, module wiring, or seed data yet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
31
apps/api/src/hunting/danger-rating.ts
Normal file
31
apps/api/src/hunting/danger-rating.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export enum DangerRating {
|
||||
WEAK = 'WEAK',
|
||||
MATCH = 'MATCH',
|
||||
STRONG = 'STRONG',
|
||||
VERY_DANGEROUS = 'VERY_DANGEROUS',
|
||||
DEADLY = 'DEADLY',
|
||||
}
|
||||
|
||||
export interface CombatantStats {
|
||||
attack: number;
|
||||
armor: number;
|
||||
hp: number;
|
||||
}
|
||||
|
||||
// power(entity) = attack*4 + armor*2 + floor(hp/5) — a deliberately small,
|
||||
// provisional server-side stand-in for a future CombatPower system (none
|
||||
// exists yet in this codebase). ratio = monsterPower / characterPower.
|
||||
export function calculateDangerRating(
|
||||
character: CombatantStats,
|
||||
monster: CombatantStats,
|
||||
): DangerRating {
|
||||
const power = (stats: CombatantStats) =>
|
||||
stats.attack * 4 + stats.armor * 2 + Math.floor(stats.hp / 5);
|
||||
const ratio = power(monster) / power(character);
|
||||
|
||||
if (ratio < 0.65) return DangerRating.WEAK;
|
||||
if (ratio < 1.0) return DangerRating.MATCH;
|
||||
if (ratio < 1.7) return DangerRating.STRONG;
|
||||
if (ratio < 2.3) return DangerRating.VERY_DANGEROUS;
|
||||
return DangerRating.DEADLY;
|
||||
}
|
||||
Reference in New Issue
Block a user