Initial commit
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
export const SPECIES_LABELS: Record<string, string> = {
|
||||
HUMAN: 'Human',
|
||||
HALF_ELF: 'Half-Elf',
|
||||
ELF: 'Elf',
|
||||
GNOME: 'Gnome',
|
||||
DWARF: 'Dwarf',
|
||||
HALFLING: 'Halfling',
|
||||
DRAGONBORN: 'Dragonborn',
|
||||
TIEFLING: 'Tiefling',
|
||||
HALF_ORC: 'Half-Orc',
|
||||
ORC: 'Orc',
|
||||
};
|
||||
|
||||
export const CLASS_LABELS: Record<string, string> = {
|
||||
FIGHTER: 'Fighter',
|
||||
BARBARIAN: 'Barbarian',
|
||||
ROGUE: 'Rogue',
|
||||
RANGER: 'Ranger',
|
||||
WIZARD: 'Wizard',
|
||||
SORCERER: 'Sorcerer',
|
||||
CLERIC: 'Cleric',
|
||||
PALADIN: 'Paladin',
|
||||
BARD: 'Bard',
|
||||
WARLOCK: 'Warlock',
|
||||
DRUID: 'Druid',
|
||||
MONK: 'Monk',
|
||||
};
|
||||
|
||||
export const SKILL_LABELS: Record<string, string> = {
|
||||
ACROBATICS: 'Acrobatics',
|
||||
ANIMAL_HANDLING: 'Animal Handling',
|
||||
ARCANA: 'Arcana',
|
||||
ATHLETICS: 'Athletics',
|
||||
DECEPTION: 'Deception',
|
||||
HISTORY: 'History',
|
||||
INSIGHT: 'Insight',
|
||||
INTIMIDATION: 'Intimidation',
|
||||
INVESTIGATION: 'Investigation',
|
||||
MEDICINE: 'Medicine',
|
||||
NATURE: 'Nature',
|
||||
PERCEPTION: 'Perception',
|
||||
PERFORMANCE: 'Performance',
|
||||
PERSUASION: 'Persuasion',
|
||||
RELIGION: 'Religion',
|
||||
SLEIGHT_OF_HAND: 'Sleight of Hand',
|
||||
STEALTH: 'Stealth',
|
||||
SURVIVAL: 'Survival',
|
||||
};
|
||||
|
||||
export const ABILITY_LABELS: Record<string, string> = {
|
||||
STR: 'Strength',
|
||||
DEX: 'Dexterity',
|
||||
CON: 'Constitution',
|
||||
INT: 'Intelligence',
|
||||
WIS: 'Wisdom',
|
||||
CHA: 'Charisma',
|
||||
};
|
||||
|
||||
export function fmtMod(mod: number): string {
|
||||
return mod >= 0 ? `+${mod}` : `${mod}`;
|
||||
}
|
||||
|
||||
export function extractErrorMessage(err: unknown): string {
|
||||
const anyErr = err as { response?: { data?: { error?: unknown } } };
|
||||
const apiError = anyErr?.response?.data?.error;
|
||||
if (typeof apiError === 'string') return apiError;
|
||||
if (apiError && typeof apiError === 'object') {
|
||||
const flat = apiError as { formErrors?: string[]; fieldErrors?: Record<string, string[]> };
|
||||
const messages = [
|
||||
...(flat.formErrors || []),
|
||||
...Object.values(flat.fieldErrors || {}).flat(),
|
||||
];
|
||||
if (messages.length) return messages.join(', ');
|
||||
return JSON.stringify(apiError);
|
||||
}
|
||||
if (err instanceof Error) return err.message;
|
||||
return 'Something went wrong.';
|
||||
}
|
||||
Reference in New Issue
Block a user