初始仓库迁移
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-04 23:57:06 +08:00
parent 80986b790d
commit c49c64896a
18446 changed files with 532435 additions and 2 deletions

View File

@@ -0,0 +1,80 @@
import { WorldTemplateType, WorldType } from '../types';
const CUSTOM_WORLD_NPC_IMAGE_POOL = [
'/character/Sword%20Princess/Original/Hero/idle/Idle01.png',
'/character/Archer%20Hero/Original/Hero/idle/idle01.png',
'/character/Girl%20Hero%201/Original/Hero/Idle/Idle01.png',
'/character/Punch%20Hero%203/Original/Hero/Idle/Idle01.png',
'/character/Fighter%204/original/Hero/idle/idle01.png',
] as const;
const SCENE_BACKGROUND_PACKS = [
{ packName: 'Pixel Battle Backgrounds - Pack 1', count: 121 },
{ packName: 'Pixel Battle Backgrounds - Pack 2', count: 119 },
{ packName: 'Pixel Battle Backgrounds - Pack 3', count: 170 },
] as const;
function hashText(value: string) {
let hash = 0;
for (let index = 0; index < value.length; index += 1) {
hash = (hash * 31 + value.charCodeAt(index)) >>> 0;
}
return hash >>> 0;
}
function buildSceneImagePath(packName: string, imageNumber: number) {
const filename = `${imageNumber.toString().padStart(3, '0')}.png`;
return `/scene_bg/Pixel Battle Backgrounds Mega Pack/${packName}/${filename}`;
}
export function getAllCustomWorldSceneImages() {
const refs: string[] = [];
for (const pack of SCENE_BACKGROUND_PACKS) {
for (let imageNumber = 1; imageNumber <= pack.count; imageNumber += 1) {
refs.push(buildSceneImagePath(pack.packName, imageNumber));
}
}
return refs;
}
function collectWorldSceneImagePool(worldType: WorldTemplateType) {
const refs: string[] = [];
let globalIndex = 0;
for (const pack of SCENE_BACKGROUND_PACKS) {
for (let imageNumber = 1; imageNumber <= pack.count; imageNumber += 1) {
const assignedWorld = globalIndex % 2 === 0 ? WorldType.WUXIA : WorldType.XIANXIA;
if (assignedWorld === worldType) {
refs.push(buildSceneImagePath(pack.packName, imageNumber));
}
globalIndex += 1;
}
}
return refs;
}
export function normalizeOptionalImageSrc(value: unknown) {
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
}
export function getDefaultCustomWorldNpcImage(seedKey: string, index: number) {
const offset = hashText(`${seedKey}:npc:${index}`) % CUSTOM_WORLD_NPC_IMAGE_POOL.length;
return CUSTOM_WORLD_NPC_IMAGE_POOL[offset];
}
export function getDefaultCustomWorldSceneImage(
seedKey: string,
index: number,
worldType: WorldTemplateType,
) {
const pool = collectWorldSceneImagePool(worldType);
if (pool.length === 0) {
return worldType === WorldType.WUXIA ? '/scene_bg/45_PixelSky.png' : '/scene_bg/47_PixelSky.png';
}
const offset = hashText(`${seedKey}:scene:${index}`) % pool.length;
return pool[offset];
}