Adds startHunt's server-authoritative flow: complete due travel, verify the location allows hunting, weighted-random-roll exactly 3 encounters from the location's enabled monster pool inside a locked transaction that supersedes any prior active hunt, and compute a danger rating per encounter from the rolled monster's own stats. Mirrors TravelService's transaction/locking pattern and error conventions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
38 lines
927 B
TypeScript
38 lines
927 B
TypeScript
import { HttpException } from '@nestjs/common';
|
|
|
|
export class HuntingDomainError extends HttpException {
|
|
constructor(
|
|
public readonly code: string,
|
|
status: number,
|
|
message: string,
|
|
) {
|
|
super({ statusCode: status, code, message }, status);
|
|
}
|
|
}
|
|
|
|
export function huntingNotAvailable(): HuntingDomainError {
|
|
return new HuntingDomainError(
|
|
'HUNTING_NOT_AVAILABLE',
|
|
400,
|
|
'Hunting is not available at the current location.',
|
|
);
|
|
}
|
|
|
|
export function characterTravelling(): HuntingDomainError {
|
|
return new HuntingDomainError(
|
|
'CHARACTER_TRAVELLING',
|
|
409,
|
|
'The character cannot hunt while travelling.',
|
|
);
|
|
}
|
|
|
|
export function noHuntEncountersAvailable(): HuntingDomainError {
|
|
return new HuntingDomainError(
|
|
'NO_HUNT_ENCOUNTERS_AVAILABLE',
|
|
409,
|
|
'No encounters are currently available at this location.',
|
|
);
|
|
}
|
|
|
|
export { characterNotFound } from '../travel/travel.errors';
|