forked from phenom/healer-man
Release Healer Man 0.1.12
This commit is contained in:
1 parent
13970d03c8
commit
65e24f644e
201 files changed
+5061
-123
No files matched your search
@@ -5,34 +5,87 @@ import {
|
||||
isGameMasterSession,
|
||||
resolvedBossAdminCatalog,
|
||||
} from "../game/manastormAdminConfig";
|
||||
import {
|
||||
drawRandomGmReviewTarget,
|
||||
type GmReviewKind,
|
||||
type GmReviewTarget,
|
||||
} from "../game/gmContentReview";
|
||||
import { useManastormAdminStore } from "../game/manastormAdminStore";
|
||||
import { INSTALLED_MANASTORM_RUNTIME_CATALOG } from "../game/manastormInstalledCatalog";
|
||||
import { installedManastormStageBinding } from "../game/manastormInstalledStages";
|
||||
import { registerManastormStageBindingResolver } from "../game/manastormStagePopulation";
|
||||
import { activateManastormStage } from "../game/manastormStageLoader";
|
||||
import { activateManastormStage, releaseActiveManastormStage } from "../game/manastormStageLoader";
|
||||
import { manastormModeForCharacterLevel, setManastormCatalog } from "../game/manastorm";
|
||||
import { createEmptyManastormProgress, manastormModeProgress } from "../game/manastormProgress";
|
||||
import { manastormActiveSpellLoadoutModel } from "../game/manastormSpellLoadout";
|
||||
import { useManastormStore } from "../game/manastormStore";
|
||||
import { defaultPartyRoleForClass } from "../game/partyRoles";
|
||||
import { useGameStore } from "../game/store";
|
||||
import { activateDungeonSession } from "../game/dungeonSession";
|
||||
import type { CharacterProfile } from "./types";
|
||||
|
||||
export function enterGmManastormTest(bossKey: string): boolean {
|
||||
function activeGmCharacter(): CharacterProfile | null {
|
||||
const shell = useShellStore.getState();
|
||||
if (!isGameMasterSession(shell.session) || !shell.selectedCharacterId) {
|
||||
useShellStore.setState({ notice: "Game Master access is required." });
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
const activeCharacter = touchCharacter(shell.session!.ownerId, shell.selectedCharacterId)
|
||||
?? shell.characters.find((character) => character.id === shell.selectedCharacterId)
|
||||
?? null;
|
||||
if (!activeCharacter) {
|
||||
useShellStore.setState({ notice: "Select a character before testing a boss." });
|
||||
useShellStore.setState({ notice: "Select a character before testing content." });
|
||||
return null;
|
||||
}
|
||||
return activeCharacter;
|
||||
}
|
||||
|
||||
function enterGmDungeonTest(target: Extract<GmReviewTarget, { readonly kind: "dungeon" }>): boolean {
|
||||
const activeCharacter = activeGmCharacter();
|
||||
if (!activeCharacter) return false;
|
||||
useManastormStore.getState().resetRun();
|
||||
releaseActiveManastormStage();
|
||||
if (!activateDungeonSession(target.dungeonId, undefined, {
|
||||
gmTestMode: true,
|
||||
gmReviewTarget: target,
|
||||
})) {
|
||||
useShellStore.setState({ notice: "That dungeon did not pass its offline runtime gate." });
|
||||
return false;
|
||||
}
|
||||
useGameStore.getState().setCompanionOpen(false);
|
||||
useShellStore.setState({
|
||||
phase: "game",
|
||||
activeCharacter,
|
||||
activeDungeonId: target.dungeonId,
|
||||
activeDungeonRole: defaultPartyRoleForClass(activeCharacter.classId),
|
||||
notice: "GM dungeon review",
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
export function enterRandomGmReview(kind: GmReviewKind): boolean {
|
||||
const admin = useManastormAdminStore.getState();
|
||||
if (admin.dirty || admin.saving) {
|
||||
useShellStore.setState({ notice: "Save or discard GM changes before testing another target." });
|
||||
return false;
|
||||
}
|
||||
const previous = useGameStore.getState().activeGmReviewTarget;
|
||||
const target = drawRandomGmReviewTarget(kind, admin.config, previous);
|
||||
if (!target) {
|
||||
const label = kind === "dungeon" ? "dungeons" : kind === "boss" ? "bosses" : "Manastorm encounters";
|
||||
useShellStore.setState({ notice: `All runnable ${label} have been marked Ready.` });
|
||||
return false;
|
||||
}
|
||||
if (target.kind === "dungeon") return enterGmDungeonTest(target);
|
||||
return enterGmManastormTest(target.bossKey, target);
|
||||
}
|
||||
|
||||
export function enterGmManastormTest(bossKey: string, reviewTarget: GmReviewTarget | null = null): boolean {
|
||||
const activeCharacter = activeGmCharacter();
|
||||
if (!activeCharacter) return false;
|
||||
const adminConfig = useManastormAdminStore.getState().config;
|
||||
const entry = resolvedBossAdminCatalog(adminConfig).find((candidate) => candidate.key === bossKey);
|
||||
if (!entry || entry.status === "not-ready" || !entry.runnable || !entry.stage) {
|
||||
if (!entry || !entry.runnable || !entry.stage) {
|
||||
useShellStore.setState({ notice: entry?.validationIssues[0] ?? "That boss is not available for GM testing." });
|
||||
return false;
|
||||
}
|
||||
@@ -84,7 +137,7 @@ export function enterGmManastormTest(bossKey: string): boolean {
|
||||
useShellStore.setState({ notice: "The configured boss could not be prepared for testing." });
|
||||
return false;
|
||||
}
|
||||
if (!activateManastormStage(encounter, undefined, false, true).activated) {
|
||||
if (!activateManastormStage(encounter, undefined, false, true, reviewTarget).activated) {
|
||||
useManastormStore.getState().resetRun();
|
||||
useShellStore.setState({ notice: "The configured dungeon or stage package is not loadable." });
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user