feat(characters): add temporary combat-stats stand-in for equipment
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { CharacterCombatStatsService } from './character-combat-stats.service';
|
||||
import { Character } from './entities/character.entity';
|
||||
|
||||
describe('CharacterCombatStatsService', () => {
|
||||
it('derives combat stats from the character, with a temporary fixed weapon/armor stand-in', () => {
|
||||
const service = new CharacterCombatStatsService();
|
||||
const character = { baseHp: 100, baseAttack: 6 } as Character;
|
||||
|
||||
expect(service.getStats(character)).toEqual({
|
||||
maxHp: 100,
|
||||
attack: 6,
|
||||
weaponDamage: 8,
|
||||
armor: 6,
|
||||
});
|
||||
});
|
||||
});
|
||||
28
apps/api/src/characters/character-combat-stats.service.ts
Normal file
28
apps/api/src/characters/character-combat-stats.service.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Character } from './entities/character.entity';
|
||||
|
||||
export interface CharacterCombatStats {
|
||||
maxHp: number;
|
||||
attack: number;
|
||||
weaponDamage: number;
|
||||
armor: number;
|
||||
}
|
||||
|
||||
// TEMPORARY (Slice 0.3): there is no equipment system yet. These constants
|
||||
// stand in for the starting weapon/armor until Slice 0.5 introduces real
|
||||
// equipment. Replacing them there must not change this method's signature
|
||||
// or the combat API it feeds (spec §10).
|
||||
const TEMPORARY_WEAPON_DAMAGE = 8;
|
||||
const TEMPORARY_ARMOR = 6;
|
||||
|
||||
@Injectable()
|
||||
export class CharacterCombatStatsService {
|
||||
getStats(character: Character): CharacterCombatStats {
|
||||
return {
|
||||
maxHp: character.baseHp,
|
||||
attack: character.baseAttack,
|
||||
weaponDamage: TEMPORARY_WEAPON_DAMAGE,
|
||||
armor: TEMPORARY_ARMOR,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user