Files
Viano-Core/tests/clientless/test_adventure_destination_level.py
T
Nico 49712aadfe
GCC PCH / build (push) Waiting to run
clang PCH / build (push) Canceled after 0s
Improve AdventureBot travel recovery and destination eligibility
2026-10-29 11:10:27 +01:00

39 lines
2.0 KiB
Python

"""Compile the real destination eligibility method with native-level fixtures."""
from pathlib import Path
import subprocess,tempfile
root=Path(__file__).resolve().parents[2]
s=(root/'src/server/game/World/AdventureLocationMgr.cpp').read_text()
a=s.index('bool AdventureLocationMgr::LevelEligible(');b=s.index('\nbool AdventureLocationMgr::IsWorkstation',a)
code=r'''
#include <cassert>
#include <string>
#include <unordered_map>
struct Player{unsigned level=60;unsigned getLevel()const{return level;}};
struct AdventureLocation{unsigned InstanceMap=0,AreaId=0,ZoneId=0;};
struct Area{bool KnownLevel=true;unsigned MinLevel=1;};
struct Areas{auto Area(unsigned id)->::Area{return {id!=0,id};}}areas;auto sAdventureAreaMgr=&areas;
struct AdventureLocationMgr{
std::unordered_map<unsigned,unsigned>_instanceMinimum{{533,80},{36,15}};
bool LevelEligible(Player const*,AdventureLocation const&,std::string const&,bool strictArea=false)const;
};
'''+s[a:b]+r'''
int main(){
AdventureLocationMgr mgr;Player p;AdventureLocation naxx{533,0,0};
assert(!mgr.LevelEligible(&p,naxx,"raid"));p.level=79;assert(!mgr.LevelEligible(&p,naxx,"raid"));
p.level=80;assert(mgr.LevelEligible(&p,naxx,"raid"));
AdventureLocation deadmines{36,0,0};p.level=14;assert(!mgr.LevelEligible(&p,deadmines,"instance"));
p.level=15;assert(mgr.LevelEligible(&p,deadmines,"instance"));
AdventureLocation unknown{999,0,0};assert(!mgr.LevelEligible(&p,unknown,"raid"));
AdventureLocation zone{0,60,60};p.level=59;
assert(mgr.LevelEligible(&p,zone,"adventure")); // own area policy retains its separate tolerance
assert(!mgr.LevelEligible(&p,zone,"adventure",true));
p.level=60;assert(mgr.LevelEligible(&p,zone,"adventure",true));
assert(!mgr.LevelEligible(nullptr,zone,"adventure",true));
}
'''
with tempfile.TemporaryDirectory()as d:
p=Path(d);(p/'test.cpp').write_text(code)
subprocess.run(['c++','-std=c++17',str(p/'test.cpp'),'-o',str(p/'test')],check=True)
subprocess.run([str(p/'test')],check=True)
print('Native dungeon/raid minimum levels, unknown destinations and strict adventure invitation levels passed')