React earlier to hardcore danger and audit native retreat outcomes
Core tests / core (push) Successful in 48s
Core tests / core (push) Successful in 48s
This commit is contained in:
@@ -4,7 +4,9 @@ setup='''
|
||||
now=1000;os.time=function()return now end;calls={};people={}
|
||||
function AuthDBQuery(sql)local i=1;return {GetUInt32=function(_,n)return n==0 and i or 10+i end,GetString=function()return i==1 and 'A' or 'B'end,NextRow=function()i=i+1;return i<=2 end} end
|
||||
function GetPlayersInWorld()return people end
|
||||
function CreateLuaEvent(fn)tick=fn end
|
||||
function CreateLuaEvent(fn,ms)if ms==2000 then tick=fn end end
|
||||
function RegisterPlayerEvent()end
|
||||
auditRows={};function AuthDBExecute(sql)table.insert(auditRows,sql)end
|
||||
function PrintInfo()end
|
||||
function PrintError(s)error(s)end
|
||||
function make(id,name)
|
||||
@@ -13,6 +15,9 @@ function make(id,name)
|
||||
function p:IsPlayerbot()return not self.human end;function p:IsDead()return self.dead end;function p:GetBotAI()return self.ai end
|
||||
function p:GetHealthPct()return self.hp end;function p:IsInCombat()return self.combat end
|
||||
function p:IsTaxi()return self.taxi end;function p:IsCasting()return self.cast end;function p:IsRooted()return false end
|
||||
function p:GetX()return self.x or 0 end;function p:GetY()return 0 end
|
||||
function p:GetUnfriendlyUnitsInRange()return self.friendly and {} or self.selected and {self.selected} or {} end;function p:GetSelection()return self.selected end;function p:StopSpellCast()self.cast=false;self.interrupted=true end
|
||||
function p:AttackStop()self.attackStopped=true end;function p:MoveStop()self.waited=true end
|
||||
function p:GetGroup()return self.group end;function p:GetVictim()return self.enemy end;function p:GetLevel()return 5 end
|
||||
function p:GetDistance()return self.distance end;function p:GetMapId()return 0 end;function p:GetPhaseMask()return 1 end
|
||||
function p.ai:GetMaster()return p.master end;function p.ai:SetMaster(m)p.master=m end
|
||||
@@ -27,11 +32,21 @@ function step(n)now=now+n;tick()end
|
||||
'''
|
||||
def new():
|
||||
l=LuaRuntime();l.execute(setup);l.execute((Path(__file__).resolve().parents[1]/'ale/azerothai_survival.lua').read_text());l.execute('AzerothAISetSurvivalEnabled(true)');return l
|
||||
l=new();l.execute("A.combat=true;A.hp=20;step(0);assert(calls[1]=='flee');step(10);assert(#calls==1);step(10);assert(#calls==2)")
|
||||
l=new();l.execute("A.combat=true;A.hp=20;step(0);assert(calls[1]=='flee');step(2);assert(#calls==1);step(6);assert(#calls==2)")
|
||||
l=new();l.execute("group();A.human=true;B.combat=true;B.hp=20;step(0);assert(#calls==0)")
|
||||
l=new();l.execute("group();step(0);assert(calls[1]=='follow' and B.master==A)")
|
||||
l=new();l.execute("group();B.distance=100;step(0);assert(#calls==0)")
|
||||
l=new();l.execute("group();B.distance=250;step(0);assert(#calls==0)")
|
||||
l=new();l.execute("A.combat=true;A.hp=20;A.controlled=true;step(0);assert(#calls==0)")
|
||||
l=new();l.execute("A.combat=true;A.hp=20;step(0);A.combat=false;step(20);assert(calls[2]=='eat' and calls[3]=='drink')")
|
||||
l=new();l.execute("group();AzerothAISetSurvivalEnabled(false);step(0);assert(#calls==0)")
|
||||
print('Native survival: retreat cooldown, recovery, regroup range, human-party protection, and disabled grouping passed')
|
||||
|
||||
l=new();l.execute("A.combat=true;A.hp=45;A.cast=true;step(0);assert(A.interrupted and calls[1]=='flee')")
|
||||
l=new();l.execute("A.combat=true;A.hp=100;A.enemy={GetLevel=function()return 8 end,ToCreature=function()return nil end,IsHostileTo=function()return true end};step(0);assert(calls[1]=='flee')")
|
||||
l=new();l.execute("A.selected={GetGUID=function()return 99 end,GetLevel=function()return 5 end,ToCreature=function(self)return self end,GetRank=function()return 1 end,IsHostileTo=function()return true end};step(0);assert(A.attackStopped and calls[1]=='flee')")
|
||||
l=new();l.execute("A.friendly=true;A.selected={GetLevel=function()return 80 end,ToCreature=function()return nil end};step(0);assert(#calls==0)")
|
||||
l=new();l.execute("A.combat=true;A.hp=40;step(0);A.x=10;step(2);A.combat=false;step(2);assert(string.find(auditRows[#auditRows], '6F75742D6F662D636F6D626174'))")
|
||||
l=new();l.execute("A.combat=true;A.hp=40;step(0);A.hp=70;step(30);assert(string.find(auditRows[#auditRows], '6E6F2D6D6F76656D656E74'))")
|
||||
l=new();l.execute("group();B.distance=150;step(0);assert(B.master==A)")
|
||||
l=new();l.execute("group();A.distance=40;step(0);assert(A.waited);A.waited=false;step(22);assert(not A.waited)")
|
||||
print('Earlier retreat, casting interruption, hostile/elite avoidance, bounded leader waiting, longer regroup and observed retreat outcomes passed')
|
||||
|
||||
Reference in New Issue
Block a user