diff options
Diffstat (limited to 'src/LivingVillage.Desktop/WorldBootstrap.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/WorldBootstrap.fs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/WorldBootstrap.fs b/src/LivingVillage.Desktop/WorldBootstrap.fs index e75855f..e0ac037 100644 --- a/src/LivingVillage.Desktop/WorldBootstrap.fs +++ b/src/LivingVillage.Desktop/WorldBootstrap.fs @@ -29,6 +29,45 @@ module WorldBootstrap = let refreshOccupationToday (seed: uint64) (state: Occupation.State) (nowTick: int64) : Occupation.State = Occupation.refreshState seed (Occupation.occupationSeedOf state.Profile.Kind) state.Profile.Kind nowTick state + // ---- P66 任务目标具体化(design §2.4-3)---- + // 可达候选集合完全由世界/样板场景派生;Kernel 只做纯 hash 定点。 + /// 可达 NPC:世界中实际存在的村民 id(顺序稳定)。 + /// 可达瓦片:样板场景的菜地(VegetableGarden)世界瓦片 —— 设计口径「自家地块」, + /// 跨 legacy/riverscape 一致且必在陆地上。 + let reachableTargets (world: World) : Occupation.TaskTargets = + let npcs = world.Npcs |> Array.map (fun npc -> npc.Id) |> Array.toList + let tiles = + VillagePresentation.scene.Elements + |> List.choose (fun element -> + match element.Prop with + | VillagePresentation.VegetableGarden -> + let tile = VillagePresentation.worldTileForSceneTile element.Position + Some(tile.X, tile.Y) + | _ -> None) + { Npcs = npcs; Tiles = tiles } + + /// 新档职业状态(P66):按真实世界的可达候选集合定点当日任务。 + let occupationStateForWorld (seed: uint64) (kind: Occupation.Kind) (nowTick: int64) (world: World) : Occupation.State = + let baseState = Occupation.stateOf kind + { baseState with + Today = + Occupation.dailyTaskOfWith + (reachableTargets world) + seed + (Occupation.occupationSeedOf kind) + (Occupation.dayIndexOf nowTick) + kind } + + /// 跨日刷新(P66):按真实世界的可达候选集合重算跨日当天任务;同日原样保留。 + let refreshOccupationTodayWorld (seed: uint64) (state: Occupation.State) (nowTick: int64) (world: World) : Occupation.State = + Occupation.refreshStateWith + (reachableTargets world) + seed + (Occupation.occupationSeedOf state.Profile.Kind) + state.Profile.Kind + nowTick + state + /// 开局身份年鉴(design §3):带职业建世界后写入一条 `StoryAnnal`「以…为生」, /// 形成个人传记线。Game 与测试共用同一口径。 let appendIdentityAnnal (state: Occupation.State) (world: World) : World = |
