forked from phenom/healer-man
Release Healer Man 0.1.46
This commit is contained in:
1 parent
f82daf1c13
commit
9ff574ac0b
73 files changed
+33486
-174
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import { touchCharacter } from "./accountRepository";
|
||||
import { useShellStore } from "./shellStore";
|
||||
import { activateDungeonSession } from "../game/dungeonSession";
|
||||
import { dungeonRouteDefinition } from "../game/dungeonRoutes";
|
||||
import { useDungeonSimulationStore } from "../game/dungeonSimulationStore";
|
||||
import type { DungeonReplayV1, DungeonSimulationMode } from "../game/dungeonSimulationTypes";
|
||||
import { defaultPartyRoleForClass } from "../game/partyRoles";
|
||||
import { useGameStore } from "../game/store";
|
||||
|
||||
function gmCharacter() {
|
||||
const shell = useShellStore.getState();
|
||||
if (shell.session?.kind !== "account" || !shell.session.accessToken || !shell.session.roles?.includes("gm")) {
|
||||
shell.setNotice("Game Master access is required.");
|
||||
return null;
|
||||
}
|
||||
const character = shell.selectedCharacterId
|
||||
? touchCharacter(shell.session.ownerId, shell.selectedCharacterId)
|
||||
?? shell.characters.find((candidate) => candidate.id === shell.selectedCharacterId)
|
||||
: null;
|
||||
if (!character) shell.setNotice("Select a character before launching a simulation.");
|
||||
return character;
|
||||
}
|
||||
|
||||
export function enterDungeonSimulation(
|
||||
dungeonId: string,
|
||||
mode: DungeonSimulationMode,
|
||||
seed: string,
|
||||
): boolean {
|
||||
const character = gmCharacter();
|
||||
const route = dungeonRouteDefinition(dungeonId);
|
||||
if (!character || !route || !seed.trim()) return false;
|
||||
if (!activateDungeonSession(dungeonId, undefined, {
|
||||
gmTestMode: true,
|
||||
dungeonSimulation: true,
|
||||
})) {
|
||||
useShellStore.getState().setNotice("The dungeon package is unavailable on this client.");
|
||||
return false;
|
||||
}
|
||||
useDungeonSimulationStore.getState().startLive({ dungeonId, route, mode, seed: seed.trim() });
|
||||
useGameStore.getState().setCompanionOpen(false);
|
||||
useShellStore.setState({
|
||||
phase: "game",
|
||||
activeCharacter: character,
|
||||
activeDungeonId: dungeonId,
|
||||
activeDungeonRole: defaultPartyRoleForClass(character.classId),
|
||||
notice: "",
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
export function enterDungeonSimulationReplay(replay: DungeonReplayV1): boolean {
|
||||
const character = gmCharacter();
|
||||
if (!character || !dungeonRouteDefinition(replay.dungeonId, replay.routeId)) return false;
|
||||
if (!activateDungeonSession(replay.dungeonId, undefined, {
|
||||
gmTestMode: true,
|
||||
dungeonSimulation: true,
|
||||
})) {
|
||||
useShellStore.getState().setNotice("The replay dungeon package is unavailable on this client.");
|
||||
return false;
|
||||
}
|
||||
useDungeonSimulationStore.getState().startReplay(replay);
|
||||
useGameStore.getState().setCompanionOpen(false);
|
||||
useShellStore.setState({
|
||||
phase: "game",
|
||||
activeCharacter: character,
|
||||
activeDungeonId: replay.dungeonId,
|
||||
activeDungeonRole: defaultPartyRoleForClass(character.classId),
|
||||
notice: "",
|
||||
});
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user