diff options
Diffstat (limited to 'src/LivingVillage.Desktop/Interaction.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/Interaction.fs | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/src/LivingVillage.Desktop/Interaction.fs b/src/LivingVillage.Desktop/Interaction.fs index 48bc3e7..68f90d7 100644 --- a/src/LivingVillage.Desktop/Interaction.fs +++ b/src/LivingVillage.Desktop/Interaction.fs @@ -34,6 +34,7 @@ type M5Command = | Intent6 | BuyFromTarget | SellToTarget + | AcceptTask | Observe | ToggleNeeds | ShowChronicle @@ -333,6 +334,15 @@ module M5Interaction = | None -> next withAnnal, Some nextState | None -> next, None + // P54:玩家对话是真实事件(Actor=玩家),驱动对话类当日任务。 + let advanced, taskMessage = + match storyTask with + | Some taskState -> + let next, message = + TaskRuntime.advanceWithEvent + { Tick = storyWorld.Tick; Kind = DialogueEvent outcome } taskState + Some next, message + | None -> None, None storyWorld, { view with Panel = WorldPanel @@ -340,8 +350,11 @@ module M5Interaction = Chronicle = Sim.annalText storyWorld Prompt = None PromptTargetPos = None - Task = storyTask - Status = sprintf "dialogue intent=%A response=%A" outcome.Intent outcome.Response + Task = advanced + Status = + match taskMessage with + | Some message -> "task|" + message + | None -> sprintf "dialogue intent=%A response=%A" outcome.Intent outcome.Response StatusTick = Some storyWorld.Tick } | DialogueRejected(failure, next) -> next, @@ -365,6 +378,7 @@ module M5Interaction = | Intent6 | BuyFromTarget | SellToTarget -> view.Panel = DialoguePanel + | AcceptTask -> view.Panel = TaskPanel | Observe | ToggleNeeds | ShowChronicle @@ -428,6 +442,8 @@ module M5Interaction = let outcome = if command = BuyFromTarget then PlayerTrade.buyFood view.Task menu.Target world else PlayerTrade.sellFirst view.Task menu.Target world + // P54:交易完成当日任务时把短中文反馈一并带出。 + let taskMessage = TaskRuntime.completedMessage view.Task outcome.Occupation outcome.World, { view with Panel = WorldPanel @@ -435,17 +451,40 @@ module M5Interaction = Prompt = None PromptTargetPos = None Task = outcome.Occupation - Status = (if outcome.Succeeded then "trade ok|" else "trade fail|") + outcome.Message + Status = + (if outcome.Succeeded then "trade ok|" else "trade fail|") + + outcome.Message + + (match taskMessage with Some message -> "|" + message | None -> "") StatusTick = Some outcome.World.Tick } + | AcceptTask -> + match view.Task with + | None -> world, { view with Status = "task|无职业任务" } + | Some occupationState -> + let next, message = TaskRuntime.accept occupationState + world, + { view with + Task = Some next + Status = "task|" + (message |> Option.defaultValue "当前任务无需接受") } | Observe -> let observations = Sim.observeVisible (observationBounds world) world + // P54:「观察」是真实动作,驱动观察记事类任务。 + let task, taskMessage = + match view.Task with + | Some occupationState -> + let next, message = TaskRuntime.advanceWithSignal Occupation.Observed occupationState + Some next, message + | None -> None, None world, { view with Panel = ObservationPanel Observations = observations + Task = task Prompt = None PromptTargetPos = None - Status = sprintf "observation visible_npcs=%d" observations.Length } + Status = + match taskMessage with + | Some message -> "task|" + message + | None -> sprintf "observation visible_npcs=%d" observations.Length } | ToggleNeeds -> if view.Panel = NeedsPanel then world, refreshPrompt world { view with Panel = WorldPanel; Needs = None; Status = "needs panel closed" } @@ -545,6 +584,7 @@ module M5Interaction = | value when value.StartsWith("observation") -> "观察完成" | value when value.StartsWith("chronicle") -> "年鉴已打开" | "task panel open" -> "任务面板已打开" + | value when value.StartsWith("task|") -> value.Substring("task|".Length) | value when value.StartsWith("trade ok|") -> value.Substring("trade ok|".Length) | value when value.StartsWith("trade fail|") -> "交易失败:" + value.Substring("trade fail|".Length) | value when value.StartsWith("no dialogue") -> "当前没有可用对话" @@ -670,6 +710,9 @@ module M5Interaction = | None -> [ "今日暂无任务" ] | Some task -> [ sprintf "%s:%s" (Occupation.taskNameOf task.TemplateId) (taskStateText task.State) ] + @ (match task.State with + | Occupation.Offered -> [ "回车:接受任务" ] + | _ -> []) let storyLine = sprintf "剧情线:%s,%s" (Occupation.Story.lineNameOf occupationState.Profile.Kind) |
