feat(api): re-anchor HP regeneration before an equipment-driven max-HP change
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { CharacterStatsService } from '../characters/character-stats.service';
|
||||
import { CharacterVitalsService } from '../characters/character-vitals.service';
|
||||
import { Character } from '../characters/entities/character.entity';
|
||||
import { CombatStatus } from '../combat/combat-status.enum';
|
||||
import { Combat } from '../combat/entities/combat.entity';
|
||||
@@ -48,6 +49,7 @@ export class EquipmentService {
|
||||
constructor(
|
||||
private readonly dataSource: DataSource,
|
||||
private readonly characterStats: CharacterStatsService,
|
||||
private readonly characterVitals: CharacterVitalsService,
|
||||
) {}
|
||||
|
||||
async getEquipment(characterId: string): Promise<EquipmentResponseDto> {
|
||||
@@ -106,6 +108,10 @@ export class EquipmentService {
|
||||
throw itemLevelRequirementNotMet();
|
||||
}
|
||||
|
||||
const statsBeforeChange = await this.characterStats.calculate(character, manager);
|
||||
this.characterVitals.settle(character, statsBeforeChange.maxHp);
|
||||
await characters.save(character);
|
||||
|
||||
const existing = await equipmentRepo.findOne({
|
||||
where: { characterId, slot: definition.equipmentSlot },
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
|
||||
Reference in New Issue
Block a user