fixed # 新增药水机制

This commit is contained in:
2026-11-23 23:45:37 +08:00
parent f955716c97
commit 0eeba640ae
45 changed files with 1053 additions and 235 deletions
+4 -1
View File
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { createHash } from "node:crypto";
import { registerHooks } from "node:module";
import { join } from "node:path";
import { getSts2Atlas } from "./sts2-atlas.js";
import { relicCatalog } from "../relics/catalog.js";
import { relicDefinitions, getRelic, heldRelics, canAcquireRelic, grantRelic, relicRewardIds, relicRewardPools } from "../relics/definitions.js";
import { relicState, grantGold, newRelicCard, resolveRelicChoices, relicCardPool, addPermanentRelicCard } from "../relics/progression.js";
@@ -57,9 +59,10 @@ function fixture(run,{encounter={},onCounterChange}={}){
eq(relicCatalog.length,298,"complete catalog");eq(new Set(relicCatalog.map(r=>r.wikiId)).size,298);
eq(relicCatalog.map(r=>r.order),Array.from({length:298},(_,i)=>i+1));
const manifest=JSON.parse(await readFile(new URL("../assets/relics/manifest.json",import.meta.url),"utf8"));
const relicAtlas = getSts2Atlas("relic_atlas.sprites");
for(const asset of manifest.assets){
const bytes=await readFile(new URL(`../${asset.runtime}`,import.meta.url));
const source=await readFile(new URL(`../assets/sts2/Godot_Atlas_Sprites_v0.111.0/images/atlases/relic_atlas.sprites/${asset.source}`,import.meta.url));
const source=await readFile(join(relicAtlas, asset.source));
eq(createHash("sha256").update(bytes).digest("hex"),asset.sha256,asset.wikiId);
eq(bytes,source,`original image ${asset.wikiId}`);
eq([bytes.readUInt32BE(16),bytes.readUInt32BE(20)],[asset.width,asset.height]);
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 816 KiB

+2 -1
View File
@@ -4,8 +4,9 @@ const crypto = require('node:crypto');
const { pathToFileURL } = require('node:url');
(async () => {
const root = path.resolve(__dirname, '..');
const { getSts2Atlas } = await import('./sts2-atlas.js');
const source = getSts2Atlas('power_atlas.sprites');
const { statusIconNames } = await import(pathToFileURL(path.join(root, 'ui/hud/status-model.js')).href);
const source = path.join(root, 'assets/sts2/Godot_Atlas_Sprites_v0.111.0/images/atlases/power_atlas.sprites');
const output = path.join(root, 'assets/status');
fs.mkdirSync(output, {recursive:true});
const entries = [], missing = [];
+19 -1
View File
@@ -2,6 +2,7 @@
import argparse
import hashlib
import json
import os
import struct
from pathlib import Path
@@ -24,6 +25,23 @@ LIUBEI_RELICS = frozenset({
})
def get_relic_atlas():
tools_dir = ROOT / "tools"
config = tools_dir / ".sts2-source"
source = os.environ.get("MENGSAN_STS2_SOURCE", "").strip()
if not source and config.is_file():
source = config.read_text(encoding="utf-8-sig").strip()
atlas = (
tools_dir / (source or "../assets/sts2")
/ "Godot_Atlas_Sprites_v0.111.0" / "images" / "atlases" / "relic_atlas.sprites"
).resolve()
if not atlas.is_dir():
raise FileNotFoundError(
f"找不到 STS2 拆分图集:{atlas}。请检查 MENGSAN_STS2_SOURCE 或 tools/.sts2-source。"
)
return atlas
def main():
parser = argparse.ArgumentParser()
parser.add_argument("snapshot", type=Path)
@@ -32,7 +50,7 @@ def main():
rows = source["relics"]
if len(rows) != 298 or len({row["id"] for row in rows}) != 298:
raise ValueError("Expected reviewed 298 unique relics")
atlas = ROOT / "assets/sts2/Godot_Atlas_Sprites_v0.111.0/images/atlases/relic_atlas.sprites"
atlas = get_relic_atlas()
target = ROOT / "assets/relics"
target.mkdir(exist_ok=True)
entries, assets = [], []
+17
View File
@@ -0,0 +1,17 @@
import { existsSync, readFileSync, statSync } from "node:fs";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const toolsDir = fileURLToPath(new URL(".", import.meta.url));
export function getSts2Atlas(name) {
const config = join(toolsDir, ".sts2-source");
const source = process.env.MENGSAN_STS2_SOURCE?.trim()
|| (existsSync(config) ? readFileSync(config, "utf8").trim() : "")
|| "../assets/sts2";
const atlas = resolve(toolsDir, source, "Godot_Atlas_Sprites_v0.111.0", "images", "atlases", name);
if (!statSync(atlas, { throwIfNoEntry: false })?.isDirectory()) {
throw new Error("找不到 STS2 拆分图集:" + atlas + "。请检查 MENGSAN_STS2_SOURCE 或 tools/.sts2-source。");
}
return atlas;
}