forked from phenom/healer-man
Update Healer Man server
This commit is contained in:
1 parent
97ee0c13f9
commit
f864b5aea7
20 files changed
+468
-211
No files matched your search
@@ -3,6 +3,7 @@ import { contentCategoryById, type ContentCategoryId } from "../app/contentCateg
|
||||
import { compareDungeonReleaseOrder, dungeonReleaseStage, type DungeonReleaseStage } from "./dungeonReleaseStage";
|
||||
import {
|
||||
BITE_SIZED_STOCKADES_DUNGEON_ID,
|
||||
isRandomizedBiteSizedDungeonId,
|
||||
RANDOMIZED_BITE_SIZED_STOCKADES_DUNGEON_ID,
|
||||
} from "./dungeonContentSource";
|
||||
|
||||
@@ -66,10 +67,32 @@ export function dungeonById(id: string): DungeonCatalogEntry | null {
|
||||
|
||||
export function dungeonsByCategory(category: DungeonCategoryId): readonly DungeonCatalogEntry[] {
|
||||
return DUNGEON_CATALOG.filter((dungeon) => (
|
||||
dungeon.category === category && dungeon.id !== RANDOMIZED_BITE_SIZED_STOCKADES_DUNGEON_ID
|
||||
dungeon.category === category && !isRandomizedBiteSizedDungeonId(dungeon.id)
|
||||
));
|
||||
}
|
||||
|
||||
/** The separately launched randomized mode, including every eligible location added later. */
|
||||
export function randomizedBiteSizedDungeons(): readonly DungeonCatalogEntry[] {
|
||||
return DUNGEON_CATALOG.filter((dungeon) => (
|
||||
dungeon.category === "bite-sized" && isRandomizedBiteSizedDungeonId(dungeon.id)
|
||||
));
|
||||
}
|
||||
|
||||
function randomAvailableDungeon(
|
||||
dungeons: readonly DungeonCatalogEntry[],
|
||||
currentDungeonId: string | undefined,
|
||||
random: () => number,
|
||||
eligible: (dungeon: DungeonCatalogEntry) => boolean,
|
||||
): DungeonCatalogEntry | null {
|
||||
const available = dungeons.filter((dungeon) => dungeon.available && eligible(dungeon));
|
||||
const candidates = available.length > 1
|
||||
? available.filter((dungeon) => dungeon.id !== currentDungeonId)
|
||||
: available;
|
||||
if (candidates.length === 0) return null;
|
||||
const roll = Math.max(0, Math.min(0.9999999999999999, random()));
|
||||
return candidates[Math.floor(roll * candidates.length)] ?? candidates[0];
|
||||
}
|
||||
|
||||
/** Selects from enterable category content and avoids an immediate repeat when alternatives exist. */
|
||||
export function randomDungeonByCategory(
|
||||
category: DungeonCategoryId,
|
||||
@@ -77,11 +100,14 @@ export function randomDungeonByCategory(
|
||||
random: () => number = Math.random,
|
||||
eligible: (dungeon: DungeonCatalogEntry) => boolean = () => true,
|
||||
): DungeonCatalogEntry | null {
|
||||
const available = dungeonsByCategory(category).filter((dungeon) => dungeon.available && eligible(dungeon));
|
||||
const candidates = available.length > 1
|
||||
? available.filter((dungeon) => dungeon.id !== currentDungeonId)
|
||||
: available;
|
||||
if (candidates.length === 0) return null;
|
||||
const roll = Math.max(0, Math.min(0.9999999999999999, random()));
|
||||
return candidates[Math.floor(roll * candidates.length)] ?? candidates[0];
|
||||
return randomAvailableDungeon(dungeonsByCategory(category), currentDungeonId, random, eligible);
|
||||
}
|
||||
|
||||
/** Selects the next location without crossing from randomized mode into authored Bite-Sized mode. */
|
||||
export function randomRandomizedBiteSizedDungeon(
|
||||
currentDungeonId?: string,
|
||||
random: () => number = Math.random,
|
||||
eligible: (dungeon: DungeonCatalogEntry) => boolean = () => true,
|
||||
): DungeonCatalogEntry | null {
|
||||
return randomAvailableDungeon(randomizedBiteSizedDungeons(), currentDungeonId, random, eligible);
|
||||
}
|
||||
Reference in new issue
Block a user