Persist fatal encounters and audit resident readiness with party outcome metrics
Core tests / core (push) Successful in 42s
Core tests / core (push) Successful in 42s
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from pathlib import Path
|
||||
from lupa import LuaRuntime
|
||||
source=(Path(__file__).resolve().parents[1]/'ale/azerothai_readiness.lua').read_text()
|
||||
setup='''
|
||||
now=1000;os.time=function()return now end;calls={}
|
||||
function WorldDBQuery()return {GetUInt32=function(_,i)return i==0 and 10 or 11 end,NextRow=function()return false end}end
|
||||
function AuthDBQuery()return {GetUInt32=function(_,i)return i==0 and 1 or 12 end,GetString=function()return 'A' end,NextRow=function()return false end}end
|
||||
function CreateLuaEvent(fn)tick=fn end;function PrintError(s)error(s)end
|
||||
p={ai={}};function GetPlayersInWorld()return {p}end
|
||||
function p:GetGUIDLow()return 1 end;function p:GetAccountId()return 12 end;function p:GetName()return 'A' end
|
||||
function p:IsPlayerbot()return true end;function p:GetBotAI()return self.ai end;function p.ai:HasGameClientMaster()return p.human end
|
||||
function p:IsDead()return p.dead end;function p:IsInCombat()return p.combat end;function p:IsCasting()return false end;function p:IsTaxi()return false end
|
||||
function p:GetGroup()return p.group end;function p:GetFreeTalentPoints()return 1 end
|
||||
function p:GetItemByPos(_,slot)if slot==15 then return {IsBroken=function()return true end,GetUInt32Value=function(_,i)return i==0x003D and 50 or 0 end}end end
|
||||
function p.ai:GetInventoryItems()return {{GetEntry=function()return 10 end,GetCount=function()return 3 end}}end
|
||||
function p:CanUseItem()return true end;function p:GetPowerType()return 0 end
|
||||
function p.ai:DoSpecificAction(s)table.insert(calls,s)end;function p.ai:ChangeStrategy(s)table.insert(calls,s)end;function p.ai:HasCheat()return p.goldCheat end
|
||||
function AzerothAISurvivalOverride()return p.recovering end
|
||||
'''
|
||||
def new():
|
||||
l=LuaRuntime();l.execute(setup);l.execute(source);return l
|
||||
l=new();l.execute("tick();local r=AzerothAIReadinessSnapshot(p);assert(r.foodCount==3 and r.drinkCount==0 and r.brokenItems==1 and r.freeTalents==1);assert(#calls==4);tick();assert(#calls==4)")
|
||||
for condition in ['human','combat','dead','recovering']:
|
||||
l=new();l.execute(f'p.{condition}=true;tick();assert(#calls==0)')
|
||||
l=new();l.execute("p.group={IsRaidGroup=function()return false end,GetMembersCount=function()return 2 end,GetMembers=function()return {p} end};tick();assert(#calls==0)")
|
||||
l=new();l.execute("p.goldCheat=true;tick();assert(#calls==2,'No repair or purchase under gold cheat')")
|
||||
print('Readiness: inventory counts, broken gear, cooldown, combat/death/recovery/human/group guards and normal-cost actions passed')
|
||||
Reference in New Issue
Block a user