feat: port AVA2 travel/teleport, attribute lock materials, and battlepass ticket activation
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Exercise the production AVA2 entrance handler, including refusal paths."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
SRC=Path(__file__).resolve().parents[2]/'src/server/game/src'
|
||||
CODE=r'''
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
enum {CHAT_TYPE_COMMAND=5};
|
||||
long long get_global_time(){return 1790900000;}
|
||||
namespace quest {
|
||||
struct PC {bool loaded=true,running=false;bool IsLoaded(){return loaded;}bool IsRunning(){return running;}};
|
||||
struct CQuestManager {
|
||||
PC pc;bool exists=true;static CQuestManager& instance(){static CQuestManager m;return m;}
|
||||
PC* GetPCForce(unsigned){return exists?&pc:nullptr;}
|
||||
};
|
||||
}
|
||||
struct Character {
|
||||
unsigned level=75;bool dead=false,stun=false,warping=false,handle=true,canWarp=true,mapAvailable=true;
|
||||
unsigned calls=0;long x=0,y=0,map=-1;std::vector<std::string> messages;
|
||||
unsigned GetPlayerID(){return 7;}unsigned GetLevel(){return level;}
|
||||
bool IsDead(){return dead;}bool IsStun(){return stun;}bool IsWarping(){return warping;}
|
||||
bool CanHandleItem(){return handle;}bool CanWarp(){return canWarp;}
|
||||
bool WarpSet(long a,long b,long c){++calls;x=a;y=b;map=c;return mapAvailable;}
|
||||
void ChatPacket(int,const char* format,...){char out[512];va_list args;va_start(args,format);vsnprintf(out,sizeof(out),format,args);va_end(args);messages.emplace_back(out);}
|
||||
};
|
||||
using LPCHARACTER=Character*;
|
||||
#include "port_ava2_travel.h"
|
||||
int main(){
|
||||
Character ch;auto& manager=quest::CQuestManager::instance();
|
||||
PortTrackTravel(&ch,1,691);assert(ch.calls==0 && ch.messages.back()=="MTF1 error 1 unsupported");
|
||||
// AVA2's dragon entrance: world coordinates, no private instance index.
|
||||
PortTrackTravel(&ch,2,2493);assert(ch.calls==1 && ch.x==180000 && ch.y==1219900 && ch.map==0);
|
||||
assert(ch.messages.back()=="MTF1 end 2 0");
|
||||
for(const auto& destination:kPortTrackDestinations){
|
||||
ch.level=destination.minLevel-1;unsigned before=ch.calls;PortTrackTravel(&ch,3,destination.boss);
|
||||
assert(ch.calls==before && ch.messages.back()=="MTF1 error 3 level");
|
||||
ch.level=destination.maxLevel+1;PortTrackTravel(&ch,3,destination.boss);assert(ch.calls==before);
|
||||
ch.level=destination.minLevel;PortTrackTravel(&ch,3,destination.boss);assert(ch.calls==before+1);
|
||||
ch.level=destination.maxLevel;PortTrackTravel(&ch,3,destination.boss);assert(ch.calls==before+2);
|
||||
}
|
||||
ch.level=75;
|
||||
for(bool* flag:{&ch.dead,&ch.stun,&ch.warping,&manager.pc.running}){
|
||||
*flag=true;unsigned before=ch.calls;PortTrackTravel(&ch,4,2493);
|
||||
assert(ch.calls==before && ch.messages.back()=="MTF1 error 4 busy");*flag=false;
|
||||
}
|
||||
for(bool* flag:{&ch.handle,&ch.canWarp,&manager.pc.loaded,&manager.exists}){
|
||||
*flag=false;unsigned before=ch.calls;PortTrackTravel(&ch,4,2493);
|
||||
assert(ch.calls==before && ch.messages.back()=="MTF1 error 4 busy");*flag=true;
|
||||
}
|
||||
ch.mapAvailable=false;PortTrackTravel(&ch,5,2493);assert(ch.messages.back()=="MTF1 error 5 unavailable");
|
||||
puts("PASS: AVA2 entrance destinations, inclusive level limits, busy/quest/warp/map refusals");
|
||||
}
|
||||
'''
|
||||
with tempfile.TemporaryDirectory(prefix='mt-travel-') as folder:
|
||||
path=Path(folder);(path/'test.cpp').write_text(CODE)
|
||||
subprocess.run(['c++','-std=c++17','-Wall','-I'+str(SRC),str(path/'test.cpp'),'-o',str(path/'test')],check=True)
|
||||
subprocess.run([str(path/'test')],check=True)
|
||||
Reference in New Issue
Block a user