diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-21 22:57:50 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-21 22:57:50 +0800 |
| commit | 60bbc83d9a1d047933e4128e7b48e1c61c925a14 (patch) | |
| tree | c41b351535add285f8644d8703fa6c4f1799eeb3 /src/LivingVillage.Desktop/MenuState.fs | |
| parent | e1d8d45cf08b4f30e33299eb40e865729e7adfd2 (diff) | |
| download | living-village-60bbc83d9a1d047933e4128e7b48e1c61c925a14.tar.gz | |
feat(desktop): P15 开局职业选择页——新档四选一+暂不选择,接入 v3 存档与当日任务
- MenuState:新增 OccupationSelect 页与 StartNewGameWith 命令;occupationOptions=农夫/渔夫/货郎/书生/暂不选择,
默认高亮「暂不选择」= 不写职业的旧行为;四选一确认后发 StartNewGameWith,ESC 返回主菜单(既有 MainMenu
行为与测试不变)。
- WorldBootstrap.occupationStateFor/refreshOccupationToday:按 seed+职业种子生成/跨日刷新当日 Offered 任务。
- Game:主菜单「开始新游戏」→ 职业选择页;选定后 initialWorldWithOccupation 注入 Money/Energy 与 Today,
m5View.Task 随之写入 v3 存档;游玩中按日刷新;autoplay/flow 默认走「暂不选择」保持旧演示行为;DrawMenu 渲染职业页。
- 测试 Desktop 93(新增 6):职业页选项顺序/默认 None/标签、确认命令与返回、bootstrap 四职业 Money/Energy+当日池内
Offered 任务、四职业 v3 round-trip(职业+任务逐字段)、T 面板显示所选职业的模板名与「待接受」、跨日刷新保持同日。
Diffstat (limited to 'src/LivingVillage.Desktop/MenuState.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/MenuState.fs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/MenuState.fs b/src/LivingVillage.Desktop/MenuState.fs index 2848e22..619ac58 100644 --- a/src/LivingVillage.Desktop/MenuState.fs +++ b/src/LivingVillage.Desktop/MenuState.fs @@ -4,6 +4,7 @@ open LivingVillage.Kernel type MenuPage = | MainMenu + | OccupationSelect | Settings | Controls | Playing @@ -33,6 +34,7 @@ type MenuCommand = | NoCommand | ContinueGame | StartNewGame + | StartNewGameWith of Occupation.Kind option | LoadGame | ApplySettings of SimulationControl | ExitGame @@ -100,9 +102,26 @@ module MenuState = | ControlsItem -> "操作说明" | ExitItem -> "退出" + /// 开局四选一 + 「暂不选择」(None = 旧行为,无职业)。 + let occupationOptions : Occupation.Kind option list = + [ Some Occupation.Farmer + Some Occupation.Fisher + Some Occupation.Peddler + Some Occupation.Scholar + None ] + + let occupationLabel (occupation: Occupation.Kind option) : string = + match occupation with + | Some kind -> Occupation.nameOf kind + | None -> "暂不选择" + + let selectedOccupation (state: MenuState) : Occupation.Kind option = + occupationOptions |> List.item state.Selected + let private optionsFor (state: MenuState) : int = match state.Page with | MainMenu -> items state |> List.length + | OccupationSelect -> occupationOptions.Length | Settings -> settings.Length | _ -> 0 @@ -150,6 +169,14 @@ module MenuState = let openSettings (state: MenuState) : MenuState = { state with Page = Settings; Selected = 0; ReturnPage = state.Page; Error = None } + /// 新档确认后进入职业选择页;默认选中「暂不选择」= 不写职业的旧行为。 + let openOccupationSelect (state: MenuState) : MenuState = + { state with + Page = OccupationSelect + Selected = occupationOptions.Length - 1 + ReturnPage = state.Page + Error = None } + let openControls (state: MenuState) : MenuState = { state with Page = Controls; Selected = 0; ReturnPage = state.Page; Error = None } @@ -187,6 +214,7 @@ module MenuState = | Back -> match state.Page with | MainMenu -> state, ExitGame + | OccupationSelect -> openMain state, NoCommand | Settings | Controls -> returnFromSubpage state, NoCommand | LoadError -> openMain state, NoCommand @@ -194,6 +222,7 @@ module MenuState = | Confirm -> match state.Page with | MainMenu -> confirmMain state + | OccupationSelect -> state, StartNewGameWith (selectedOccupation state) | Settings -> let nextSettings = selectedControl state { state with Settings = nextSettings }, ApplySettings nextSettings |
