-- The H5 steward's policy: no automatic recruitment, training or investment. local Auto = {} ---@param a any ---@param event any ---@param run? any ---@return any function Auto.Choose(a,event,run) local best,score=nil,-math.huge for _,option in ipairs(event.opts or {}) do local e=option.e or {} local v=(e.battle and a.autoMode~="争先") and -1e6 or 0 if e.battle and run and a.engine then local battle=a.engine.battlePreview(a.state,run,option) if battle and battle.failed then v=v-1e9 end end v=v+(a.autoMode=="求名" and (e.prestige or 0) or (e.silver or 0))*120 v=v+(e.loyalty or 0)*4+(e.exp or 0)*1.5 -math.max(0,(e.time or 1)-1)*60+((e.power or 1)-1)*40 if v>score then best,score=option,v end end return best end ---@param a any ---@return boolean function Auto.Step(a) if not a.autoOn then return false end local E,s=a.engine,a.state for _,run in ipairs(s.runs) do if run.journeyDecision then a.autoOn=false return false end end local changed=false for _,run in ipairs(s.runs) do if run.battleNotice then E.acknowledgeBattle(s,run.id) changed=true end if run.pendingEvent then local opt=Auto.Choose(a,run.pendingEvent,run) if opt then E.applyChoice(s,run,opt) if run.battleNotice then E.acknowledgeBattle(s,run.id) end changed=true end end end local claimed=E.commitAll(s,false) if claimed then a:Toast("托管交割 · +"..E.fmtNum(claimed.silver).." 两") changed=true end local healed=0 for _,e in ipairs(s.escorts) do if healed>=2 then break end if e.at.loyalty<=45 and s.gift>=E.GIFT_COST then local result=E.pacify(s,e.id) if result.ok then healed=healed+1 changed=true end end end for _,e in ipairs(s.escorts) do if e.at.loyalty<=25 then a.autoOn=false a:Toast("托管已暂停 · "..e.name.."忠诚过低,请先安抚") return true end end for _=1,3 do if #s.runs>=E.parallelLimit(s) then break end local sent=false local busy=E.occupied(s) local businesses=E.businessList() for i=#businesses,1,-1 do local biz=businesses[i] local need=E.businessPower(s,biz) if E.businessUnlocked(s,biz) and E.shopOpened(s,biz) then local pool={} for _,e in ipairs(s.escorts) do if not E.support.call(busy,"has",e.id) and e.at.loyalty>35 then pool[#pool+1]=e end end E.support.call(pool,"sort",function(x,y) return E.teamPower(s,{y.id})-E.teamPower(s,{x.id}) end) local team={} for _,e in ipairs(pool) do team[#team+1]=e.id if E.teamPower(s,team)>=need then break end end if #team>0 and E.teamPower(s,team)>=need then local result=E.startRun(s,biz.id,team) if result.ok then sent=true changed=true break end end end end if not sent then break end end return changed end return Auto