v0.1.1: 养成闭环 + 管理自主 + 存档安全
- 指婚/续弦:成员详情可主动找人结亲(血亲自动排除、鳏寡可再醮) - 装备 UI:法宝从府库装备/替换,战力实时反馈 - 御敌点将:劫掠事件可自选迎战阵容(默认 Top4 可改) - 宗祠祭祖:每两年一次,灵石150 → 声望+6/全族修为小升 - 回档时间轴:每季快照列表,一键回卷(回卷前自动保当前档) - 战报匣子:史书页全文战报留存可翻阅 - 年度族簿纸笺:每年初弹收支/人丁/战力简报 - 媒人提示条 + 寻衅一年冷却 + 出生率与劫掠频率微调 - 单测 19→29(storage mock roundtrip/回档/指婚血亲/祭祖/寻衅/装备/账本)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { useState } from 'react'
|
||||
import { useGameStore } from '../store'
|
||||
import { applyEventChoice } from '../../game/engine/systems/events'
|
||||
import { eventCategoryName, EventDef } from '../../game/data/events'
|
||||
import { applyEventChoice, rankPower } from '../../game/engine/systems/events'
|
||||
import { eventCategoryName } from '../../game/data/events'
|
||||
import { describeRealm } from '../../game/data/realms'
|
||||
import { Character } from '../../game/types/domain'
|
||||
import { combatPowerOf } from '../../game/engine/systems/combat'
|
||||
|
||||
export function EventModal() {
|
||||
const pendingEventId = useGameStore((s) => s.pendingEventId)
|
||||
@@ -8,17 +12,44 @@ export function EventModal() {
|
||||
const world = useGameStore((s) => s.world)
|
||||
const bump = useGameStore((s) => s.bump)
|
||||
const setSpeed = useGameStore((s) => s.setSpeed)
|
||||
const [squadPicking, setSquadPicking] = useState(false)
|
||||
const [squadSel, setSquadSel] = useState<string[]>([])
|
||||
if (!pendingEventId || !pendingEventDef || !world) return null
|
||||
|
||||
const choose = (idx: number) => {
|
||||
applyEventChoice(world, pendingEventId, idx)
|
||||
const raidIdx = pendingEventDef.options.findIndex((o) => o.eff.raid)
|
||||
const squadPool: Character[] =
|
||||
raidIdx >= 0
|
||||
? world.aliveMembers()
|
||||
.filter((c) => world.ageOf(c) >= 16 && c.state !== 'expedition')
|
||||
.sort((a, b) => rankPower(world, b) - rankPower(world, a))
|
||||
: []
|
||||
|
||||
const closeModal = () => {
|
||||
useGameStore.setState({ pendingEventId: undefined, pendingEventDef: undefined })
|
||||
setSquadPicking(false)
|
||||
setSquadSel([])
|
||||
bump()
|
||||
// 重要事务后暂停推算,给玩家喘息
|
||||
}
|
||||
|
||||
const choose = (idx: number) => {
|
||||
const isRaid = raidIdx >= 0 && raidIdx === idx
|
||||
if (isRaid && !squadPicking) {
|
||||
setSquadPicking(true)
|
||||
setSquadSel(squadPool.slice(0, 4).map((c) => c.id))
|
||||
return
|
||||
}
|
||||
applyEventChoice(world, pendingEventId, idx, isRaid ? squadSel : undefined)
|
||||
closeModal()
|
||||
const sp = useGameStore.getState().speed
|
||||
if (sp > 1) setSpeed(1)
|
||||
}
|
||||
|
||||
const toggleSquad = (id: string) => {
|
||||
setSquadSel((old) =>
|
||||
old.includes(id) ? old.filter((x) => x !== id) : old.length >= 4 ? [...old.slice(1), id] : [...old, id]
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="modal-outer">
|
||||
<div className="modal">
|
||||
@@ -28,13 +59,36 @@ export function EventModal() {
|
||||
{pendingEventDef.once && ' · 仅此一次'}
|
||||
</div>
|
||||
<div className="modal-text">{pendingEventDef.text}</div>
|
||||
|
||||
{squadPicking && (
|
||||
<div className="modal-squad" style={{ marginBottom: 14 }}>
|
||||
<div className="dim" style={{ marginBottom: 6 }}>迎战点将(默认四人,可改动)</div>
|
||||
<div className="squad-picker">
|
||||
{squadPool.map((c) => (
|
||||
<div
|
||||
key={c.id}
|
||||
className={`squadian ${squadSel.includes(c.id) ? 'sel' : ''}`}
|
||||
onClick={() => toggleSquad(c.id)}
|
||||
>
|
||||
{c.name}·{describeRealm(c.realm)}·战力{Math.round(combatPowerOf(world, c))}
|
||||
</div>
|
||||
))}
|
||||
{squadPool.length === 0 && <span className="dim2">无可出战之人</span>}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="modal-opts">
|
||||
{pendingEventDef.options.map((o, i) => (
|
||||
<button key={i} className="opt-btn" onClick={() => choose(i)}>
|
||||
{o.label}
|
||||
{o.hint && <span className="hint">{o.hint}</span>}
|
||||
</button>
|
||||
))}
|
||||
{pendingEventDef.options.map((o, i) => {
|
||||
const isRaid = raidIdx === i
|
||||
return (
|
||||
<button key={i} className="opt-btn" onClick={() => choose(i)}>
|
||||
{isRaid && squadPicking ? '出战!(点将已毕)' : o.label}
|
||||
{isRaid && !squadPicking && <span className="hint">点将迎战 · 可自选阵容</span>}
|
||||
{!isRaid && o.hint && <span className="hint">{o.hint}</span>}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useGameStore } from '../store'
|
||||
import { Character } from '../../game/types/domain'
|
||||
import { Character, GameState } from '../../game/types/domain'
|
||||
import { describeRealm, nextRealm } from '../../game/data/realms'
|
||||
import { describeRoots, ROOT_GRADE_NAMES } from '../../game/data/elements'
|
||||
import { TRAITS } from '../../game/data/traits'
|
||||
@@ -8,6 +8,12 @@ import { ITEMS, ARTIFACT_POWER } from '../../game/data/items'
|
||||
import { combatPowerOf } from '../../game/engine/systems/combat'
|
||||
import { lifespanOf } from '../../game/engine/systems/lifecycle'
|
||||
|
||||
function equipableItems(member: Character, s: GameState): string[] {
|
||||
const inv = Object.keys(ARTIFACT_POWER).filter((ai) => (s.family.inventory[ai] ?? 0) > 0)
|
||||
if (member.equipment && !inv.includes(member.equipment)) inv.push(member.equipment)
|
||||
return inv
|
||||
}
|
||||
|
||||
export function MemberModal({ member }: { member: Character }) {
|
||||
const world = useGameStore((s) => s.world)
|
||||
const setSelected = useGameStore((s) => s.setSelected)
|
||||
@@ -153,6 +159,53 @@ export function MemberModal({ member }: { member: Character }) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{member.alive && (
|
||||
<div className="mm-sec">
|
||||
<div className="dim" style={{ marginBottom: 6 }}>法宝装备(府库所列)</div>
|
||||
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
|
||||
{equipableItems(member, s).length === 0 && <span className="dim2">府库暂无存货(可往坊市购得或于秘境寻获)</span>}
|
||||
{equipableItems(member, s).map((ai) => (
|
||||
<button
|
||||
key={ai}
|
||||
className="btn btn-sm"
|
||||
style={{
|
||||
borderColor: member.equipment === ai ? 'var(--vermilion)' : undefined,
|
||||
color: member.equipment === ai ? 'var(--vermilion-bright)' : undefined
|
||||
}}
|
||||
onClick={() => {
|
||||
w.equip(member.id, ai)
|
||||
bump()
|
||||
}}
|
||||
>
|
||||
<span className="s-icon" style={{ marginRight: 4 }}>{ITEMS[ai].icon}</span>
|
||||
{ITEMS[ai].name}(+{Math.round((ARTIFACT_POWER[ai] ?? 0) * 100)}%){member.equipment === ai ? ' · 已佩' : ''}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{member.alive && w.canMarry(member.id) && (
|
||||
<div className="mm-sec">
|
||||
<div className="dim" style={{ marginBottom: 6 }}>指婚(寻配族内共居者,远亲无碍)</div>
|
||||
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
|
||||
{w.marriageCandidatesOf(member.id).slice(0, 6).map((cand) => (
|
||||
<button
|
||||
key={cand.id}
|
||||
className="btn btn-sm"
|
||||
onClick={() => {
|
||||
w.marryTo(member.id, cand.id)
|
||||
bump()
|
||||
}}
|
||||
>
|
||||
{cand.name} · {describeRealm(cand.realm)} · {w.ageOf(cand)}岁
|
||||
</button>
|
||||
))}
|
||||
{w.marriageCandidatesOf(member.id).length === 0 && <span className="dim2">暂无适配人选</span>}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 8, marginTop: 16 }}>
|
||||
{member.children.length > 0 && (
|
||||
<span className="dim2">
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { useGameStore } from '../store'
|
||||
import { YearlyReport } from '../../game/types/domain'
|
||||
|
||||
export function PaperModal() {
|
||||
const report = useGameStore((s) => s.paperReport)
|
||||
const closePaper = useGameStore((s) => s.closePaper)
|
||||
if (!report) return null
|
||||
|
||||
const nets = report.nets
|
||||
const y = report.year
|
||||
|
||||
return (
|
||||
<div className="modal-outer" onClick={closePaper}>
|
||||
<div className="modal yearpaper-modal" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="modal-title" style={{ fontSize: '1.3rem' }}>岁 末 族 簿</div>
|
||||
<div className="modal-cat">{y}年 全 族 收 支 与 人 丁 情 形</div>
|
||||
<div className="modal-text" style={{ textAlign: 'center', fontSize: '0.98rem', lineHeight: 2.1 }}>
|
||||
<div>灵石盈亏 <b className={nets >= 0 ? 'good' : 'bad'}>{nets >= 0 ? `+${nets}` : nets}</b> 枚</div>
|
||||
<div>人丁 <b className="good">新增 {report.births}</b> · <b className="bad">辞世 {report.deaths}</b></div>
|
||||
<div>家族声望 <b>{report.rep}</b> · 宗族战力 <b>{report.power}</b></div>
|
||||
{report.deaths > report.births && <div className="bad">丁口在减 —— 传宗接代是头等大事</div>}
|
||||
{report.births > report.deaths && <div className="good">丁口渐旺,香火有望。</div>}
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
||||
<button className="btn btn-primary" onClick={closePaper}>
|
||||
翻 过 此 页
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user