feat(rewards): add CombatRewardService with idempotent victory rewards
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
29
apps/api/src/rewards/rewards.errors.ts
Normal file
29
apps/api/src/rewards/rewards.errors.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { HttpException, HttpStatus } from '@nestjs/common';
|
||||
|
||||
export type RewardErrorCode = 'COMBAT_NOT_WON' | 'REWARD_STATE_INVALID';
|
||||
|
||||
export class RewardDomainError extends HttpException {
|
||||
constructor(
|
||||
public readonly code: RewardErrorCode,
|
||||
status: HttpStatus,
|
||||
message: string,
|
||||
) {
|
||||
super({ statusCode: status, code, message }, status);
|
||||
}
|
||||
}
|
||||
|
||||
export function combatNotWon(): RewardDomainError {
|
||||
return new RewardDomainError(
|
||||
'COMBAT_NOT_WON',
|
||||
HttpStatus.CONFLICT,
|
||||
'Only a won combat can grant victory rewards.',
|
||||
);
|
||||
}
|
||||
|
||||
export function rewardStateInvalid(): RewardDomainError {
|
||||
return new RewardDomainError(
|
||||
'REWARD_STATE_INVALID',
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
'The reward references unavailable data.',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user