feat: unify phase one creation flow
This commit is contained in:
@@ -467,6 +467,24 @@ function clampProgress(value: number) {
|
||||
return Math.max(0, Math.min(100, Math.round(value)));
|
||||
}
|
||||
|
||||
export function resolveMiniGameDraftGenerationStartedAtMs(
|
||||
startedAt: string | number | null | undefined,
|
||||
fallbackMs = Date.now(),
|
||||
) {
|
||||
if (typeof startedAt === 'number' && Number.isFinite(startedAt)) {
|
||||
return startedAt;
|
||||
}
|
||||
|
||||
if (typeof startedAt === 'string') {
|
||||
const parsed = Date.parse(startedAt);
|
||||
if (Number.isFinite(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
|
||||
return fallbackMs;
|
||||
}
|
||||
|
||||
function getStepDefinitions(kind: MiniGameDraftGenerationKind) {
|
||||
if (kind === 'puzzle') {
|
||||
return buildPuzzleSteps(createMiniGameDraftGenerationState('puzzle'));
|
||||
@@ -542,6 +560,7 @@ function buildMiniGameProgressSteps(
|
||||
|
||||
export function createMiniGameDraftGenerationState(
|
||||
kind: MiniGameDraftGenerationKind,
|
||||
startedAtMs = Date.now(),
|
||||
): MiniGameDraftGenerationState {
|
||||
return {
|
||||
kind,
|
||||
@@ -559,7 +578,7 @@ export function createMiniGameDraftGenerationState(
|
||||
: kind === 'wooden-fish'
|
||||
? 'wooden-fish-draft'
|
||||
: 'compile',
|
||||
startedAtMs: Date.now(),
|
||||
startedAtMs,
|
||||
completedAssetCount: 0,
|
||||
totalAssetCount: 0,
|
||||
error: null,
|
||||
|
||||
Reference in New Issue
Block a user