local UI = require("urhox-libs/UI") local W = require("Game/UI/Widgets") local Home = require("Game/UI/Home") local Dispatch = {} -- A read-only presentation model shared by the compact home and its details. ---@param a any ---@return table function Dispatch.Order(a) local E,s=a.engine,a.state local ids=a:SelectedIds() local power=E.teamPower(s,ids) local goal=E.cityGoal(s) if goal then local kind=goal.opened and "contract" or (goal.ready and "open" or "prepare") local need=kind=="prepare" and 50 or 70 local full=#s.runs>0 return {title=goal.name.." · "..(kind=="contract" and goal.ability or kind=="open" and "首批货物" or "短途押运"), reward=E.businessBaseSilver(E.businessById("civil"))*(kind=="contract" and goal.mul or 1), need=need,power=power,actionId="city-start",disabled=full or power=E.parallelLimit(s) return {title=biz.name,reward=E.businessBaseSilver(biz),need=need,power=power, actionId="ordinary-start",disabled=full or power1 then children[#children+1]=W.Hint("分程 "..((run.legIdx or 0)+1).." / "..run.legs.." · 途中报酬抵驿即入账") end if run.done then children[#children+1]=Home.Secondary("查看押镖结算",function() a:Invalidate() end,{id="run-settle-"..run.id}) end return Home.Card("在途镖队",children) end ---@param a any ---@return Widget function Dispatch.City(a) local E,s=a.engine,a.state local goal=E.cityGoal(s) local k=Home.Scale() local kind=goal.opened and "contract" or (goal.ready and "open" or "prepare") local label=kind=="contract" and goal.ability or kind=="open" and "首批货物" or "短途押运" local need=kind=="prepare" and 50 or 70 local ids=a:SelectedIds() local power=E.teamPower(s,ids) local base=E.businessBaseSilver(E.businessById("civil"))*(kind=="contract" and goal.mul or 1) local duration=kind=="open" and 18 or kind=="contract" and 12*goal.time or 12 ---@type Widget[] local order={W.Row({Home.Icon("cart",65*k), W.Column({Home.Text(goal.name.." · "..label,20,{fontWeight="bold"}), Home.Text("基础镖银:银两 "..W.Number(base),15), Home.Text("基础用时 "..string.format("%g",duration).." 秒 · 战力需 "..need,11,{fontColor="#806346"})}, {flexGrow=1,flexBasis=0,minWidth=0,gap=5*k}), Home.Secondary("调整队伍",function() a:Open("team") end,{id="team-picker",width=86*k})},{gap=9*k})} if #s.runs==0 then order[#order+1]=Home.Primary(power=E.parallelLimit(s) order[#order+1]=Home.Primary(full and "等待镖队归来" or "开始押运",function() a:Do("startRun",biz.id,a:SelectedIds()) end, {id="ordinary-start",disabled=full or power