30 lines
2.1 KiB
Python
30 lines
2.1 KiB
Python
from pathlib import Path
|
|
from lupa import LuaRuntime
|
|
source=(Path(__file__).resolve().parents[1]/'ale/azerothai_experience.lua').read_text()
|
|
l=LuaRuntime();l.execute('''
|
|
now=100000;os.time=function()return now end;events={};writes={};ddl=false
|
|
function CreateLuaEvent()end
|
|
function RegisterPlayerEvent(n,f)events[n]=f end
|
|
function AuthDBExecute(s)table.insert(writes,s)end
|
|
function AuthDBQuery(s)
|
|
if s:find('CREATE TABLE',1,true) then ddl=true;return nil end
|
|
if s:find('azerothai_lifecycle',1,true) then return {GetString=function()return 'A' end,GetUInt32=function()return 12 end} end
|
|
assert(ddl)
|
|
return {GetUInt32=function(_,i)return ({[0]=7,[1]=99990,[3]=50,[4]=0,[7]=5})[i] end,GetString=function()return 'Wolf' end,GetFloat=function()return 10 end,NextRow=function()return false end}
|
|
end
|
|
p={level=5,account=12};function p:GetGUIDLow()return 1 end;function p:GetAccountId()return self.account end;function p:GetName()return 'A' end
|
|
function p:IsPlayerbot()return true end;function p:GetBotAI()return {HasGameClientMaster=function()return p.controlled end} end
|
|
function p:GetMapId()return 0 end;function p:GetLevel()return self.level end;function p:GetX()return 10 end;function p:GetY()return 10 end
|
|
enemy={x=10};function enemy:ToCreature()return self end;function enemy:GetEntry()return 50 end;function enemy:GetX()return self.x end;function enemy:GetY()return 10 end;function enemy:GetName()return 'Wolf' end
|
|
''');l.execute(source)
|
|
l.execute('''
|
|
assert(AzerothAILearnedDanger(p,enemy));enemy.x=500;assert(not AzerothAILearnedDanger(p,enemy));enemy.x=10
|
|
p.level=8;assert(not AzerothAILearnedDanger(p,enemy));p.level=5
|
|
p.account=99;events[8](8,enemy,p);assert(#writes==0);p.account=12
|
|
p.controlled=true;events[8](8,enemy,p);assert(#writes==0);p.controlled=false
|
|
events[8](8,enemy,p);assert(#writes==1);events[8](8,enemy,p);assert(#writes==1)
|
|
''')
|
|
# Reload the whole module: durable SQL memory must still affect target selection.
|
|
l.execute(source);l.execute("assert(AzerothAILearnedDanger(p,enemy));now=400000;assert(not AzerothAILearnedDanger(p,enemy))")
|
|
print('Death memory: identity, human control, duplicate event, radius, level reassessment, expiry and reload persistence passed')
|