Files
ChronicleOfTheImmortalClan/src/renderer/game/engine/sim/worldsim-brief.ts
T

18 lines
859 B
TypeScript

import { World } from '../runtime/World'
import { WONDER_NAMES } from './worldsim-data'
export function worldSimBrief(w: World): { tideLabel: string; priceLabel: string; latest: string; wonderLabel?: string } | null {
const ws = w.state.worldSim
if (!ws) return null
const tide = ws.tide ?? 0.5
const tideLabel = tide > 0.9 ? '灵涨' : tide < 0.7 ? '灵衰' : '汐平'
const pool = ws.marketPool ?? {}
const ratio = (pool['lingcao'] ?? 600) / 600
const priceLabel = ratio > 1.15 ? '物腾' : ratio < 0.85 ? '物贱' : '平稳'
const latest = ws.newsFeed?.[ws.newsFeed.length - 1]?.text ?? ''
// 0.1.37 世界奇观标签
const wonder = (ws as { wonder?: { kind: string } }).wonder
const wonderLabel = wonder ? WONDER_NAMES[wonder.kind as keyof typeof WONDER_NAMES] : undefined
return { tideLabel, priceLabel, latest, wonderLabel }
}