forked from phenom/healer-man
Update Healer Man server
This commit is contained in:
1 parent
3e30af4c98
commit
97ee0c13f9
25 files changed
+576
-179
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
contentPackHasUpdate,
|
||||
contentPackIsUsable,
|
||||
installContentForLogicalUrls,
|
||||
installContentPack,
|
||||
} from "../content/contentManager";
|
||||
import {
|
||||
RANDOMIZED_BITE_SIZED_STOCKADES_DUNGEON_ID,
|
||||
dungeonContentPackId,
|
||||
} from "../game/dungeonContentSource";
|
||||
import { randomizedBiteSizedDefinitionForSeed } from "../game/dungeonRegistry";
|
||||
|
||||
export function randomizedBiteSizedModelUrls(seed: string): readonly string[] {
|
||||
const definition = randomizedBiteSizedDefinitionForSeed(seed);
|
||||
return [...new Set(Object.values(definition.entities).flatMap((entity) => (
|
||||
entity.visual.model?.url ? [entity.visual.model.url] : []
|
||||
)))].sort();
|
||||
}
|
||||
|
||||
interface RandomizedContentDependencies {
|
||||
readonly development: boolean;
|
||||
readonly installPack: (packId: string) => Promise<void>;
|
||||
readonly installUrls: (urls: readonly string[]) => Promise<void>;
|
||||
readonly packIsUsable: (packId: string) => boolean;
|
||||
readonly packHasUpdate: (packId: string) => boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_DEPENDENCIES: RandomizedContentDependencies = {
|
||||
development: import.meta.env.DEV,
|
||||
installPack: installContentPack,
|
||||
installUrls: installContentForLogicalUrls,
|
||||
packIsUsable: contentPackIsUsable,
|
||||
packHasUpdate: contentPackHasUpdate,
|
||||
};
|
||||
|
||||
/** Downloads the rolled location and creature packs before the seeded run enters gameplay. */
|
||||
export async function ensureRandomizedBiteSizedRunContent(
|
||||
seed: string,
|
||||
dependencies: RandomizedContentDependencies = DEFAULT_DEPENDENCIES,
|
||||
): Promise<void> {
|
||||
if (dependencies.development) return;
|
||||
const basePackId = dungeonContentPackId(RANDOMIZED_BITE_SIZED_STOCKADES_DUNGEON_ID);
|
||||
if (!dependencies.packIsUsable(basePackId) || dependencies.packHasUpdate(basePackId)) {
|
||||
await dependencies.installPack(basePackId);
|
||||
}
|
||||
await dependencies.installUrls(randomizedBiteSizedModelUrls(seed));
|
||||
}
|
||||
Reference in new issue
Block a user