Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:4000';
|
||||
|
||||
export const apiClient = axios.create({ baseURL: API_URL });
|
||||
|
||||
export function setAuthToken(token: string | null) {
|
||||
if (token) {
|
||||
apiClient.defaults.headers.common.Authorization = `Bearer ${token}`;
|
||||
localStorage.setItem('dnd_token', token);
|
||||
} else {
|
||||
delete apiClient.defaults.headers.common.Authorization;
|
||||
localStorage.removeItem('dnd_token');
|
||||
}
|
||||
}
|
||||
|
||||
export function getStoredToken(): string | null {
|
||||
return localStorage.getItem('dnd_token');
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { apiClient } from './client';
|
||||
import type {
|
||||
Campaign,
|
||||
CampaignMemberSummary,
|
||||
CharacterDetail,
|
||||
CharacterSummary,
|
||||
Encounter,
|
||||
EncounterParticipant,
|
||||
InventoryItem,
|
||||
Monster,
|
||||
Note,
|
||||
QuickStats,
|
||||
Spell,
|
||||
Weapon,
|
||||
} from './types';
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Campaigns
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export function useCampaigns() {
|
||||
return useQuery({
|
||||
queryKey: ['campaigns'],
|
||||
queryFn: async () => (await apiClient.get<{ campaigns: Campaign[] }>('/campaigns')).data.campaigns,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCampaign(campaignId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['campaign', campaignId],
|
||||
enabled: Boolean(campaignId),
|
||||
queryFn: async () =>
|
||||
(
|
||||
await apiClient.get<{ campaign: Campaign; members: CampaignMemberSummary[] }>(`/campaigns/${campaignId}`)
|
||||
).data,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateCampaign() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: {
|
||||
name: string;
|
||||
description?: string;
|
||||
startingGold?: number;
|
||||
startingItemCount?: number;
|
||||
startingSpellCount?: number;
|
||||
skipMotivationRoll?: boolean;
|
||||
}) => (await apiClient.post<{ campaign: Campaign }>('/campaigns', data)).data.campaign,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaigns'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateCampaign(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: Partial<Campaign>) =>
|
||||
(await apiClient.patch<{ campaign: Campaign }>(`/campaigns/${campaignId}`, data)).data.campaign,
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['campaign', campaignId] });
|
||||
qc.invalidateQueries({ queryKey: ['campaigns'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useJoinCampaign() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (inviteCode: string) =>
|
||||
(await apiClient.post<{ campaign: Campaign }>(`/campaigns/join/${inviteCode}`)).data.campaign,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaigns'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useRegenerateInvite(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async () =>
|
||||
(await apiClient.post<{ inviteCode: string }>(`/campaigns/${campaignId}/invite`, { regenerate: true })).data
|
||||
.inviteCode,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId] }),
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Characters
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export function useCampaignCharacters(campaignId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['campaign', campaignId, 'characters'],
|
||||
enabled: Boolean(campaignId),
|
||||
queryFn: async () =>
|
||||
(await apiClient.get<{ characters: CharacterSummary[] }>(`/campaigns/${campaignId}/characters`)).data
|
||||
.characters,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateCharacter(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: { name: string; userId?: string }) =>
|
||||
(await apiClient.post<{ character: CharacterSummary }>(`/campaigns/${campaignId}/characters`, data)).data
|
||||
.character,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'characters'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useCharacter(characterId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['character', characterId],
|
||||
enabled: Boolean(characterId),
|
||||
refetchInterval: false,
|
||||
queryFn: async () => (await apiClient.get<{ character: CharacterDetail }>(`/characters/${characterId}`)).data
|
||||
.character,
|
||||
});
|
||||
}
|
||||
|
||||
export function usePatchCharacter(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: Partial<CharacterDetail>) =>
|
||||
(await apiClient.patch<{ character: CharacterDetail }>(`/characters/${characterId}`, data)).data.character,
|
||||
onSuccess: (character) => {
|
||||
qc.setQueryData(['character', characterId], character);
|
||||
qc.invalidateQueries({ queryKey: ['campaign', character.campaignId, 'characters'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteCharacter(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (characterId: string) => apiClient.delete(`/characters/${characterId}`),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'characters'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useQuickStats(characterId: string | undefined, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: ['character', characterId, 'quick-stats'],
|
||||
enabled: Boolean(characterId) && enabled,
|
||||
queryFn: async () =>
|
||||
(await apiClient.get<{ quickStats: QuickStats }>(`/characters/${characterId}/quick-stats`)).data.quickStats,
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Character build flow
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
function invalidateCharacter(qc: ReturnType<typeof useQueryClient>, characterId: string) {
|
||||
qc.invalidateQueries({ queryKey: ['character', characterId] });
|
||||
}
|
||||
|
||||
export function useBuildRoll(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async () =>
|
||||
(await apiClient.post<{ buildStage: string; buildState: Record<string, unknown> }>(
|
||||
`/characters/${characterId}/build/roll`
|
||||
)).data,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useBuildChoose(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (body: Record<string, unknown>) =>
|
||||
(await apiClient.post<{ buildStage: string; buildState: Record<string, unknown> }>(
|
||||
`/characters/${characterId}/build/choose`,
|
||||
body
|
||||
)).data,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useBuildFinalize(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async () =>
|
||||
(await apiClient.post<{ character: CharacterDetail }>(`/characters/${characterId}/build/finalize`)).data
|
||||
.character,
|
||||
onSuccess: (character) => {
|
||||
qc.setQueryData(['character', characterId], character);
|
||||
qc.invalidateQueries({ queryKey: ['campaign', character.campaignId, 'characters'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Weapons / inventory / spells on a character
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export function useAssignWeapon(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: { weaponId: string; quantity?: number }) =>
|
||||
(await apiClient.post(`/characters/${characterId}/weapons`, data)).data,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePatchCharacterWeapon(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({ weaponId, ...data }: { weaponId: string; equipped?: boolean; quantity?: number }) =>
|
||||
(await apiClient.patch(`/characters/${characterId}/weapons/${weaponId}`, data)).data,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useAddInventoryItem(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: { name: string; description?: string; quantity?: number }) =>
|
||||
(await apiClient.post<{ item: InventoryItem }>(`/characters/${characterId}/inventory`, data)).data.item,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePatchInventoryItem(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({ itemId, ...data }: { itemId: string; quantity?: number; equipped?: boolean }) =>
|
||||
(await apiClient.patch(`/characters/${characterId}/inventory/${itemId}`, data)).data,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteInventoryItem(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (itemId: string) => apiClient.delete(`/characters/${characterId}/inventory/${itemId}`),
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useAssignSpell(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: { spellId: string; prepared?: boolean }) =>
|
||||
(await apiClient.post(`/characters/${characterId}/spells`, data)).data,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePatchCharacterSpell(characterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({ spellId, prepared }: { spellId: string; prepared: boolean }) =>
|
||||
(await apiClient.patch(`/characters/${characterId}/spells/${spellId}`, { prepared })).data,
|
||||
onSuccess: () => invalidateCharacter(qc, characterId),
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Campaign weapons / spells / monsters pools
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export function useCampaignWeapons(campaignId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['campaign', campaignId, 'weapons'],
|
||||
enabled: Boolean(campaignId),
|
||||
queryFn: async () => (await apiClient.get<{ weapons: Weapon[] }>(`/campaigns/${campaignId}/weapons`)).data.weapons,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateWeapon(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: Omit<Weapon, 'id' | 'campaignId'>) =>
|
||||
(await apiClient.post<{ weapon: Weapon }>(`/campaigns/${campaignId}/weapons`, data)).data.weapon,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'weapons'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useCampaignSpells(campaignId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['campaign', campaignId, 'spells'],
|
||||
enabled: Boolean(campaignId),
|
||||
queryFn: async () => (await apiClient.get<{ spells: Spell[] }>(`/campaigns/${campaignId}/spells`)).data.spells,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateSpell(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: Omit<Spell, 'id' | 'campaignId'>) =>
|
||||
(await apiClient.post<{ spell: Spell }>(`/campaigns/${campaignId}/spells`, data)).data.spell,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'spells'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useCampaignMonsters(campaignId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['campaign', campaignId, 'monsters'],
|
||||
enabled: Boolean(campaignId),
|
||||
queryFn: async () =>
|
||||
(await apiClient.get<{ monsters: Monster[] }>(`/campaigns/${campaignId}/monsters`)).data.monsters,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateMonster(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: Omit<Monster, 'id' | 'campaignId'>) =>
|
||||
(await apiClient.post<{ monster: Monster }>(`/campaigns/${campaignId}/monsters`, data)).data.monster,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'monsters'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteMonster(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (monsterId: string) => apiClient.delete(`/campaigns/${campaignId}/monsters/${monsterId}`),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'monsters'] }),
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Encounters
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export function useCampaignEncounters(campaignId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['campaign', campaignId, 'encounters'],
|
||||
enabled: Boolean(campaignId),
|
||||
queryFn: async () =>
|
||||
(await apiClient.get<{ encounters: Encounter[] }>(`/campaigns/${campaignId}/encounters`)).data.encounters,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateEncounter(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (name: string) =>
|
||||
(await apiClient.post<{ encounter: Encounter }>(`/campaigns/${campaignId}/encounters`, { name })).data
|
||||
.encounter,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'encounters'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useEncounter(encounterId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['encounter', encounterId],
|
||||
enabled: Boolean(encounterId),
|
||||
queryFn: async () => (await apiClient.get<{ encounter: Encounter }>(`/encounters/${encounterId}`)).data.encounter,
|
||||
});
|
||||
}
|
||||
|
||||
export function useAddParticipant(encounterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: { characterId?: string; monsterId?: string; displayName?: string; initiative?: number }) =>
|
||||
(await apiClient.post(`/encounters/${encounterId}/participants`, data)).data,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['encounter', encounterId] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePatchParticipant(encounterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({ participantId, ...data }: Partial<EncounterParticipant> & { participantId: string }) =>
|
||||
(await apiClient.patch(`/encounters/${encounterId}/participants/${participantId}`, data)).data,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['encounter', encounterId] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useRemoveParticipant(encounterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (participantId: string) =>
|
||||
apiClient.delete(`/encounters/${encounterId}/participants/${participantId}`),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['encounter', encounterId] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useAdvanceRound(encounterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async () => (await apiClient.post(`/encounters/${encounterId}/advance-round`)).data,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['encounter', encounterId] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePatchEncounter(encounterId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: { status?: EncounterStatusInput; name?: string }) =>
|
||||
(await apiClient.patch(`/encounters/${encounterId}`, data)).data,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['encounter', encounterId] }),
|
||||
});
|
||||
}
|
||||
type EncounterStatusInput = 'PLANNING' | 'ACTIVE' | 'COMPLETE';
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Notes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export function useCampaignNotes(campaignId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['campaign', campaignId, 'notes'],
|
||||
enabled: Boolean(campaignId),
|
||||
queryFn: async () => (await apiClient.get<{ notes: Note[] }>(`/campaigns/${campaignId}/notes`)).data.notes,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCharacterNotes(characterId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['character', characterId, 'notes'],
|
||||
enabled: Boolean(characterId),
|
||||
queryFn: async () => (await apiClient.get<{ notes: Note[] }>(`/characters/${characterId}/notes`)).data.notes,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateNote() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: { campaignId?: string; characterId?: string; body: string; visibility?: 'DM_ONLY' | 'SHARED' }) =>
|
||||
(await apiClient.post<{ note: Note }>('/notes', data)).data.note,
|
||||
onSuccess: (note) => {
|
||||
if (note.campaignId) qc.invalidateQueries({ queryKey: ['campaign', note.campaignId, 'notes'] });
|
||||
if (note.characterId) qc.invalidateQueries({ queryKey: ['character', note.characterId, 'notes'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
export type Ability = 'STR' | 'DEX' | 'CON' | 'INT' | 'WIS' | 'CHA';
|
||||
|
||||
export type Species =
|
||||
| 'HUMAN'
|
||||
| 'HALF_ELF'
|
||||
| 'ELF'
|
||||
| 'GNOME'
|
||||
| 'DWARF'
|
||||
| 'HALFLING'
|
||||
| 'DRAGONBORN'
|
||||
| 'TIEFLING'
|
||||
| 'HALF_ORC'
|
||||
| 'ORC';
|
||||
|
||||
export type CharacterClass =
|
||||
| 'FIGHTER'
|
||||
| 'BARBARIAN'
|
||||
| 'ROGUE'
|
||||
| 'RANGER'
|
||||
| 'WIZARD'
|
||||
| 'SORCERER'
|
||||
| 'CLERIC'
|
||||
| 'PALADIN'
|
||||
| 'BARD'
|
||||
| 'WARLOCK'
|
||||
| 'DRUID'
|
||||
| 'MONK';
|
||||
|
||||
export type BuildStage =
|
||||
| 'NOT_STARTED'
|
||||
| 'ROLLING_SPECIES'
|
||||
| 'ROLLING_CLASS'
|
||||
| 'ROLLING_MOTIVATION'
|
||||
| 'ASSIGNING_SCORES'
|
||||
| 'ASSIGNING_PROFICIENCIES'
|
||||
| 'CHOOSING_EQUIPMENT'
|
||||
| 'COMPLETE';
|
||||
|
||||
export interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export interface Campaign {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
inviteCode: string;
|
||||
startingGold: number;
|
||||
startingItemCount: number;
|
||||
startingSpellCount: number;
|
||||
skipMotivationRoll: boolean;
|
||||
ownerId: string;
|
||||
role: 'DM' | 'PLAYER';
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface CampaignMemberSummary {
|
||||
userId: string;
|
||||
displayName: string;
|
||||
role: 'DM' | 'PLAYER';
|
||||
}
|
||||
|
||||
export interface CharacterSummary {
|
||||
id: string;
|
||||
campaignId: string;
|
||||
userId: string | null;
|
||||
createdById: string;
|
||||
name: string;
|
||||
species: Species | null;
|
||||
characterClass: CharacterClass | null;
|
||||
level: number;
|
||||
xp: number;
|
||||
buildStage: BuildStage;
|
||||
currentHp: number;
|
||||
tempHp: number;
|
||||
maxHp: number | null;
|
||||
armorClass: number | null;
|
||||
}
|
||||
|
||||
export interface AbilityDetail {
|
||||
rolled: number;
|
||||
final: number;
|
||||
modifier: number;
|
||||
}
|
||||
|
||||
export interface CharacterSheet {
|
||||
abilities: Record<Ability, AbilityDetail>;
|
||||
proficiencyBonus: number;
|
||||
armorClass: number;
|
||||
initiative: number;
|
||||
speed: number;
|
||||
hp: { max: number };
|
||||
hitDice: { size: number; count: number };
|
||||
saves: Record<Ability, { proficient: boolean; bonus: number }>;
|
||||
skills: Record<string, { ability: Ability; proficient: boolean; expertise: boolean; bonus: number }>;
|
||||
passivePerception: number;
|
||||
spellcasting: { ability: Ability; saveDC: number; attackBonus: number } | null;
|
||||
}
|
||||
|
||||
export interface Weapon {
|
||||
id: string;
|
||||
campaignId: string;
|
||||
name: string;
|
||||
damageDice: string;
|
||||
damageType: string;
|
||||
attackAbility: 'STR' | 'DEX' | 'FINESSE';
|
||||
properties: string[];
|
||||
rangeNormal: number | null;
|
||||
rangeLong: number | null;
|
||||
}
|
||||
|
||||
export interface CharacterWeapon {
|
||||
id: string;
|
||||
characterId: string;
|
||||
weaponId: string;
|
||||
quantity: number;
|
||||
equipped: boolean;
|
||||
weapon: Weapon;
|
||||
}
|
||||
|
||||
export interface Spell {
|
||||
id: string;
|
||||
campaignId: string;
|
||||
name: string;
|
||||
level: number;
|
||||
school: string | null;
|
||||
castingTime: string | null;
|
||||
range: string | null;
|
||||
duration: string | null;
|
||||
description: string | null;
|
||||
}
|
||||
|
||||
export interface CharacterSpell {
|
||||
id: string;
|
||||
characterId: string;
|
||||
spellId: string;
|
||||
prepared: boolean;
|
||||
spell: Spell;
|
||||
}
|
||||
|
||||
export interface InventoryItem {
|
||||
id: string;
|
||||
characterId: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
quantity: number;
|
||||
equipped: boolean;
|
||||
}
|
||||
|
||||
export interface SkillProficiency {
|
||||
skill: string;
|
||||
proficient: boolean;
|
||||
expertise: boolean;
|
||||
}
|
||||
|
||||
export interface SaveProficiency {
|
||||
ability: Ability;
|
||||
proficient: boolean;
|
||||
}
|
||||
|
||||
export interface CharacterDetail {
|
||||
id: string;
|
||||
campaignId: string;
|
||||
userId: string | null;
|
||||
createdById: string;
|
||||
name: string;
|
||||
species: Species | null;
|
||||
characterClass: CharacterClass | null;
|
||||
level: number;
|
||||
xp: number;
|
||||
motivation: string | null;
|
||||
halfElfBonusAbility1: Ability | null;
|
||||
halfElfBonusAbility2: Ability | null;
|
||||
rolledScores: Record<Ability, number>;
|
||||
currentHp: number;
|
||||
tempHp: number;
|
||||
armorBonus: number;
|
||||
specialAbilities: string | null;
|
||||
gold: number;
|
||||
buildStage: BuildStage;
|
||||
buildState: Record<string, unknown> | null;
|
||||
skillProficiencies: SkillProficiency[];
|
||||
saveProficiencies: SaveProficiency[];
|
||||
inventoryItems: InventoryItem[];
|
||||
weapons: CharacterWeapon[];
|
||||
spells: CharacterSpell[];
|
||||
sheet: CharacterSheet | null;
|
||||
}
|
||||
|
||||
export interface Monster {
|
||||
id: string;
|
||||
campaignId: string;
|
||||
name: string;
|
||||
ac: number;
|
||||
maxHp: number;
|
||||
speed: number;
|
||||
strScore: number;
|
||||
dexScore: number;
|
||||
conScore: number;
|
||||
intScore: number;
|
||||
wisScore: number;
|
||||
chaScore: number;
|
||||
attackBonus: number;
|
||||
damageDice: string | null;
|
||||
challengeRating: string | null;
|
||||
specialTrait: string | null;
|
||||
notes: string | null;
|
||||
}
|
||||
|
||||
export type EncounterStatus = 'PLANNING' | 'ACTIVE' | 'COMPLETE';
|
||||
|
||||
export interface EncounterParticipant {
|
||||
id: string;
|
||||
encounterId: string;
|
||||
characterId: string | null;
|
||||
monsterId: string | null;
|
||||
displayName: string;
|
||||
initiative: number;
|
||||
currentHp: number;
|
||||
maxHp: number;
|
||||
conditions: string[];
|
||||
isMonster: boolean;
|
||||
character?: { id: string; name: string } | null;
|
||||
monster?: { id: string; name: string } | null;
|
||||
}
|
||||
|
||||
export interface Encounter {
|
||||
id: string;
|
||||
campaignId: string;
|
||||
name: string;
|
||||
status: EncounterStatus;
|
||||
currentRound: number;
|
||||
createdAt: string;
|
||||
participants?: EncounterParticipant[];
|
||||
}
|
||||
|
||||
export interface Note {
|
||||
id: string;
|
||||
campaignId: string | null;
|
||||
characterId: string | null;
|
||||
authorId: string;
|
||||
body: string;
|
||||
visibility: 'DM_ONLY' | 'SHARED';
|
||||
createdAt: string;
|
||||
author?: { displayName: string };
|
||||
}
|
||||
|
||||
export interface QuickStatsWeapon {
|
||||
characterWeaponId: string;
|
||||
weaponId: string;
|
||||
name: string;
|
||||
equipped: boolean;
|
||||
quantity: number;
|
||||
attackBonus: number;
|
||||
damageBonus: number;
|
||||
damageDice: string;
|
||||
damageType: string;
|
||||
}
|
||||
|
||||
export interface QuickStats {
|
||||
name: string;
|
||||
currentHp: number;
|
||||
maxHp: number;
|
||||
tempHp: number;
|
||||
armorClass: number;
|
||||
initiative: number;
|
||||
speed: number;
|
||||
proficiencyBonus: number;
|
||||
spellcasting: { ability: Ability; saveDC: number; attackBonus: number } | null;
|
||||
specialAbilities: string | null;
|
||||
weapons: QuickStatsWeapon[];
|
||||
}
|
||||
Reference in New Issue
Block a user