V1.28.0: free roam, and completed encounters out of the way

- Free roam: a third kind of encounter. The DM ticks the nearby locations,
  the whole party is in it from the start, and each player sends their own
  character to a place
- A place shows who is found there and what is for sale; a character shops
  (a place's own shop, or an NPC's wares and exchange) only where they stand
- Locations can have a shop of their own; an NPC can be "found at" a location
- Completed encounters are hidden from the campaign's list until "Show
  completed" is ticked; moving an encounter works on the list as shown

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 09:30:16 +02:00
co-authored by Claude Opus 5.5
parent 9b3637576d
commit 555765916f
21 changed files with 823 additions and 69 deletions
+30 -2
View File
@@ -1,6 +1,7 @@
import { useMutation, useQuery, useQueryClient, type QueryClient } from '@tanstack/react-query';
import { apiClient } from './client';
import type {
Ability,
ActionPatch,
ActionSource,
BuildOptions,
@@ -646,6 +647,11 @@ export function usePatchPoolEntry(campaignId: string, pool: Pool) {
exchangeCash?: number | null;
effects?: GearEffect[];
effectNote?: string | null;
// A spell: how it lands in a battle. An NPC: where they are found.
attackRoll?: boolean;
saveAbility?: Ability | null;
halfOnSave?: boolean;
locationId?: string | null;
}) =>
(await apiClient.patch(`/campaigns/${campaignId}/${pool}/${id}`, data)).data,
onSuccess: () => {
@@ -840,7 +846,7 @@ export function useCreateEncounter(campaignId: string) {
const qc = useQueryClient();
return useMutation({
// Where it goes in the campaign's order: the top, the bottom (the default), or straight after another.
mutationFn: async (data: { name: string; mode?: EncounterMode; position?: 'TOP' | 'BOTTOM'; afterEncounterId?: string }) =>
mutationFn: async (data: { name: string; mode?: EncounterMode; position?: 'TOP' | 'BOTTOM'; afterEncounterId?: string; placeIds?: string[] }) =>
(await apiClient.post<{ encounter: Encounter }>(`/campaigns/${campaignId}/encounters`, data)).data.encounter,
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'encounters'] }),
});
@@ -986,6 +992,28 @@ export function useSetTargets(encounterId: string) {
});
}
// Free roam: the DM sets the places the party can go to in the scene.
export function useSetPlaces(encounterId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (locationIds: string[]) => (await apiClient.put(`/encounters/${encounterId}/places`, { locationIds })).data,
onSuccess: (data) => keepEncounter(qc, encounterId, data),
});
}
// Free roam: a character goes to one of the scene's places.
export function useVisitPlace(encounterId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (data: { characterId: string; locationId: string }) => (await apiClient.post(`/encounters/${encounterId}/visit`, data)).data,
onSuccess: (data, { characterId }) => {
keepEncounter(qc, encounterId, data);
qc.invalidateQueries({ queryKey: ['character', characterId] });
qc.invalidateQueries({ queryKey: ['campaign'] }); // the places a player knows, and where the party is
},
});
}
// Declares an attack or a spell: by whoever is on turn unless an actor is
// named, at the targets marked unless some are given.
export function useDeclareAction(encounterId: string) {
@@ -1121,7 +1149,7 @@ export function useCreateNpc(campaignId: string) {
// in progress, characters in the scene change money and buy
// --------------------------------------------------------------------------
export type NewWare = ({ npcId: string } | { encounterId: string }) &
export type NewWare = ({ npcId: string } | { encounterId: string } | { locationId: string }) &
({ weaponId: string } | { itemId: string }) & { price: number; currency: Currency; level?: number; stock: number | null };
// Wares reach the screen inside the NPC list and inside each encounter.