refactor: 收口公开详情封面解锁规则
This commit is contained in:
@@ -532,6 +532,7 @@ import {
|
||||
resolvePlatformPublicWorkActionMode,
|
||||
resolvePlatformPublicWorkDetailOpenDecision,
|
||||
resolvePlatformPublicWorkDetailOpenStrategy,
|
||||
resolveVisiblePuzzleDetailCoverCount,
|
||||
} from './platformPublicWorkDetailFlow';
|
||||
import {
|
||||
buildPuzzleResultProfileId,
|
||||
@@ -731,22 +732,6 @@ function isRecommendRuntimeReadyForEntry(
|
||||
return true;
|
||||
}
|
||||
|
||||
function resolveVisiblePuzzleDetailCoverCount(
|
||||
entry: PlatformPublicGalleryCard | null,
|
||||
run: PuzzleRunSnapshot | null,
|
||||
) {
|
||||
if (!entry || !isPuzzleGalleryEntry(entry)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (run?.entryProfileId !== entry.profileId) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 中文注释:封面首图永远公开,后续封面跟随当前玩家本次 run 的通关进度即时解锁。
|
||||
return Math.max(1, run.clearedLevelCount + 1);
|
||||
}
|
||||
|
||||
function mapBarkBattleWorkToPublishedConfig(
|
||||
work: BarkBattleWorkSummary,
|
||||
): BarkBattlePublishedConfig {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { expect, test } from 'vitest';
|
||||
import type { BarkBattleWorkSummary } from '../../../packages/shared/src/contracts/barkBattle';
|
||||
import type { BigFishWorkSummary } from '../../../packages/shared/src/contracts/bigFishWorkSummary';
|
||||
import type { JumpHopGalleryCardResponse } from '../../../packages/shared/src/contracts/jumpHop';
|
||||
import type { PuzzleRunSnapshot } from '../../../packages/shared/src/contracts/puzzleRuntimeSession';
|
||||
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
|
||||
import type { CustomWorldGalleryCard } from '../../../packages/shared/src/contracts/runtime';
|
||||
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
|
||||
@@ -33,6 +34,7 @@ import {
|
||||
resolvePlatformPublicWorkActionMode,
|
||||
resolvePlatformPublicWorkDetailOpenDecision,
|
||||
resolvePlatformPublicWorkDetailOpenStrategy,
|
||||
resolveVisiblePuzzleDetailCoverCount,
|
||||
} from './platformPublicWorkDetailFlow';
|
||||
|
||||
type TypedPlatformPublicGalleryCard = Extract<
|
||||
@@ -165,6 +167,24 @@ function buildPuzzleWork(
|
||||
};
|
||||
}
|
||||
|
||||
function buildPuzzleRun(
|
||||
overrides: Partial<PuzzleRunSnapshot> = {},
|
||||
): PuzzleRunSnapshot {
|
||||
return {
|
||||
runId: 'puzzle-run',
|
||||
entryProfileId: 'puzzle-profile',
|
||||
clearedLevelCount: 0,
|
||||
currentLevelIndex: 0,
|
||||
currentGridSize: 3,
|
||||
playedProfileIds: ['puzzle-profile'],
|
||||
previousLevelTags: [],
|
||||
currentLevel: null,
|
||||
recommendedNextProfileId: null,
|
||||
leaderboardEntries: [],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function buildBigFishWork(
|
||||
overrides: Partial<BigFishWorkSummary> = {},
|
||||
): BigFishWorkSummary {
|
||||
@@ -593,6 +613,35 @@ test('platform public work detail flow maps detail entries back to work summarie
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
test('platform public work detail flow resolves visible puzzle cover count', () => {
|
||||
const puzzleEntry = buildTypedEntry('puzzle', {
|
||||
profileId: 'puzzle-profile',
|
||||
});
|
||||
|
||||
expect(resolveVisiblePuzzleDetailCoverCount(null, null)).toBe(1);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(buildTypedEntry('big-fish'), null),
|
||||
).toBe(1);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(
|
||||
puzzleEntry,
|
||||
buildPuzzleRun({ entryProfileId: 'other-profile', clearedLevelCount: 9 }),
|
||||
),
|
||||
).toBe(1);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(
|
||||
puzzleEntry,
|
||||
buildPuzzleRun({ clearedLevelCount: 2 }),
|
||||
),
|
||||
).toBe(3);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(
|
||||
puzzleEntry,
|
||||
buildPuzzleRun({ clearedLevelCount: -1 }),
|
||||
),
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
test('platform public work detail flow resolves edit mode only for owned works', () => {
|
||||
const entry = buildTypedEntry('puzzle');
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
JumpHopGalleryCardResponse,
|
||||
JumpHopWorkProfileResponse,
|
||||
} from '../../../packages/shared/src/contracts/jumpHop';
|
||||
import type { PuzzleRunSnapshot } from '../../../packages/shared/src/contracts/puzzleRuntimeSession';
|
||||
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
|
||||
import type { CustomWorldGalleryCard } from '../../../packages/shared/src/contracts/runtime';
|
||||
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
|
||||
@@ -239,6 +240,22 @@ export function mapPublicWorkDetailToPuzzleWork(
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveVisiblePuzzleDetailCoverCount(
|
||||
entry: PlatformPublicGalleryCard | null,
|
||||
run: PuzzleRunSnapshot | null,
|
||||
) {
|
||||
if (!entry || !isPuzzleGalleryEntry(entry)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (run?.entryProfileId !== entry.profileId) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 中文注释:封面首图永远公开,后续封面跟随当前玩家本次 run 的通关进度即时解锁。
|
||||
return Math.max(1, run.clearedLevelCount + 1);
|
||||
}
|
||||
|
||||
export function mapPublicWorkDetailToBigFishWork(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
): BigFishWorkSummary | null {
|
||||
|
||||
Reference in New Issue
Block a user