diff options
Diffstat (limited to 'src/LivingVillage.Kernel/Occupation.fs')
| -rw-r--r-- | src/LivingVillage.Kernel/Occupation.fs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/LivingVillage.Kernel/Occupation.fs b/src/LivingVillage.Kernel/Occupation.fs index c207395..45ef428 100644 --- a/src/LivingVillage.Kernel/Occupation.fs +++ b/src/LivingVillage.Kernel/Occupation.fs @@ -194,14 +194,25 @@ module Occupation = /// 挂在玩家侧的职业状态,随存档 v3 保存(design §2)。 /// Today = 当日任务(§3);TaskToken 保留为 v3 前缀占位扩展位(恒 0,暂未启用)。 + /// Backpack = 玩家背包侧车(design §2.4-1):开局 = profile.InitialInventory 的纯数据副本, + /// 不进 `Sim.World`、不动 `Sim.step` 数值路径;键值对保持声明顺序以稳定序列化。 type State = { Profile: Profile TaskToken: int Today: DailyTask option - StoryStage: int } + StoryStage: int + Backpack: (Sim.ItemKind * int) list } let stateOf (kind: Kind) : State = - { Profile = profileOf kind; TaskToken = 0; Today = None; StoryStage = 0 } + { Profile = profileOf kind + TaskToken = 0 + Today = None + StoryStage = 0 + Backpack = (profileOf kind).InitialInventory } + + /// 背包内某物品数量(纯函数;无则 0)。 + let backpackQuantity (item: Sim.ItemKind) (state: State) : int = + state.Backpack |> List.sumBy (fun (kind, quantity) -> if kind = item then quantity else 0) // ---- 既有事件通道 → 任务信号桥(design §3:完成判定统一走 InteractionEvent)---- |
