From 50875bb65cc4cdba92f6745d2430a92d85474872 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 22:59:12 +0800 Subject: test(desktop): P15 选职业→第一天任务→完成判定→Done 全链路回归(既有事件通道) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 从 WorldBootstrap.occupationStateFor(选择职业入口)取四职业第一天 Offered 任务, acceptTask 转 Active,再用该模板对应信号推到 Done:交易/对话模板走 InteractionEvent → signalOfInteraction(玩家买/卖、玩家对话),到达瓦片/夜水边/观察由调用方折叠信号。 - 覆盖农夫送粮、渔夫夜捕、货郎收货、书生观察记事等四职业首日模板,验证池内生成与终态。 - Desktop 94 / Kernel 83 全绿;不改 Sim.step 数值路径。 --- src/LivingVillage.Desktop.Tests/DesktopTests.fs | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/LivingVillage.Desktop.Tests/DesktopTests.fs') diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs index 5f2d6df..00e445b 100644 --- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs +++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs @@ -277,3 +277,53 @@ type OccupationFlowTests () = Assert.AreEqual( Some (Occupation.dailyTaskOf 42UL (Occupation.occupationSeedOf Occupation.Farmer) 1L Occupation.Farmer).Value, day1.Today) + + [] + member _.ChosenOccupationFirstDayTaskReachesDoneThroughItsSignal () = + // 既有事件通道:交易/对话模板由 InteractionEvent 经 signalOfInteraction 推进; + // 到达瓦片/夜水边/观察由调用方折叠为信号(Sim.step 不感知)。 + let eventOf (template: Occupation.TaskTemplateId) : Sim.InteractionEvent option = + match template with + | Occupation.DeliverGrain -> + Some { Tick = 0L; Kind = Sim.TradeEvent(NpcId 1, Sim.playerId, Food, 1, 1.0f) } + | Occupation.SellFish -> + Some { Tick = 0L; Kind = Sim.TradeEvent(NpcId 1, Sim.playerId, Fish, 1, 1.0f) } + | Occupation.Resell -> + Some { Tick = 0L; Kind = Sim.TradeEvent(NpcId 1, Sim.playerId, Spice, 1, 1.0f) } + | Occupation.BuyGoods -> + Some { Tick = 0L; Kind = Sim.TradeEvent(Sim.playerId, NpcId 1, Spice, 1, 1.0f) } + | Occupation.HelpWork + | Occupation.MarketInquiry + | Occupation.ReasonDebate -> + Some + { Tick = 0L + Kind = + Sim.DialogueEvent + { Tick = 0L + Actor = Sim.playerId + Target = NpcId 0 + Intent = SmallTalk + Response = Friendly + Valence = 0.3f } } + | Occupation.TillSoil + | Occupation.NightCatch + | Occupation.ObserveNotes -> None + let foldedSignal (template: Occupation.TaskTemplateId) : Occupation.TaskSignal = + match template with + | Occupation.TillSoil -> Occupation.ArrivedAt(52, 38) + | Occupation.NightCatch -> Occupation.NightAtWater + | Occupation.ObserveNotes -> Occupation.Observed + | _ -> failwith "event-backed template" + for kind in Occupation.all do + let state = WorldBootstrap.occupationStateFor 42UL kind 0L + let offered = state.Today.Value + Assert.AreEqual(Occupation.Offered, offered.State) + Assert.IsTrue(Occupation.taskPoolOf kind |> List.contains offered.TemplateId) + let active = { state with Today = Some(Occupation.acceptTask offered) } + let completed = + match eventOf offered.TemplateId with + | Some event -> Occupation.advanceTask event active + | None -> + { active with + Today = active.Today |> Option.map (Occupation.applySignal (foldedSignal offered.TemplateId)) } + Assert.AreEqual(Occupation.Done, completed.Today.Value.State) -- cgit v1.2.3