"""Execute production NeedsRole/Complete against actual party compositions.""" from pathlib import Path import subprocess,tempfile root=Path(__file__).resolve().parents[2] source=(root/'src/server/game/World/AdventureGroupMgr.cpp').read_text() def function(signature): a=source.index(signature);b=source.index('{',a);e=b+1;depth=1 while depth: depth+=(source[e]=='{')-(source[e]=='}');e+=1 return source[a:e] code=r''' #include "AdventureGroupPolicy.h" #include #include #include #include #include using uint8=unsigned char; constexpr unsigned CLASS_WARRIOR=1,CLASS_PALADIN=2,CLASS_DEATH_KNIGHT=6,CLASS_DRUID=11; namespace lfg{constexpr uint8 PLAYER_ROLE_LEADER=1,PLAYER_ROLE_TANK=2,PLAYER_ROLE_HEALER=4,PLAYER_ROLE_DAMAGE=8;} struct Guid{unsigned id=0;unsigned GetCounter()const{return id;}bool operator==(Guid other)const{return id==other.id;}bool operator<(Guid other)const{return idmembers;Ref*first=nullptr; struct Slot{Guid guid;};std::vectorGetMemberSlots(){std::vectorslots;for(auto g:members)slots.push_back({g});return slots;} Guid GetLeaderGUID(){return leader;}unsigned GetMembersCount(){return members.size();}Ref*GetFirstMember(){return first;}uint8 GetLfgRoles(Guid){return 0;}}; namespace ObjectAccessor{std::unordered_mapplayers;Player*FindPlayer(Guid g){auto i=players.find(g.id);return i==players.end()?nullptr:i->second;}} struct Lua{Profile*GetAdventureProfile(unsigned id){auto p=ObjectAccessor::FindPlayer({id});return p&&p->session.bot?&p->profile:nullptr;}}lua;auto sClientlessLuaEngine=&lua; struct PlayerAI{static bool IsPlayerHealer(Player*){return false;}static unsigned GetPlayerSpec(Player*p){return p->spec;}}; struct AdventureGroupPlan{bool Forming=true;std::string Intent="groupformation",NextIntent="instance";unsigned Capacity=5;}; struct Behavior{AdventureGroupPlan plan;AdventureGroupPlan GroupPlan(Player*){return plan;}}behavior;auto sAdventureBehaviorMgr=&behavior; namespace GameTime{long now=100;long GetGameTime(){return now;}} struct AdventureGroupMgr{struct Record{Guid Inviter;long InviteUntil=0;};std::map_records;unsigned PendingInvites(Player*,Player*except=nullptr)const;bool SurplusRole(Player*);bool BotLed(Player*)const{return true;}bool NeedsRole(Player*,Player*);bool Complete(Player*);bool CanInvite(Player*,Player*p){return p->eligible;}}; ''' for signature in ['std::string Activity(', 'unsigned Capacity(', 'uint8 BrowserRole(', 'unsigned AdventureGroupMgr::PendingInvites(', 'bool AdventureGroupMgr::SurplusRole(', 'bool AdventureGroupMgr::NeedsRole(', 'bool AdventureGroupMgr::Complete(']:code+='\n'+function(signature) code+=r''' int main(){ AdventureGroupMgr manager;Group group;std::vectorplayers(7);std::vectorrefs; refs.reserve(5); for(unsigned i=0;i