Merge main into feature/ava2-unlock
Conflicts resolved by keeping both sides: AVA2 attribute lock materials (50348/50349) and battle pass tickets from main alongside the unlock branch's costume enchants, talismans and new rings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ SRC=ROOT/'src/server/game/src'
|
||||
# The quiet-INFO branch must stay in the real ChatPacket; the stub below mirrors it.
|
||||
assert 'if (m_portQuietInfo && type == CHAT_TYPE_INFO)' in (SRC/'char.cpp').read_bytes().decode('latin1')
|
||||
assert '"mt_switchbot", do_port_switchbot' in (SRC/'cmd.cpp').read_bytes().decode('latin1')
|
||||
lock_use=(SRC/'port_attr_lock.cpp').read_text().split('const char* PortAttrLockUse(',1)[1]
|
||||
code=r'''
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
@@ -51,6 +52,7 @@ class CItem {public:
|
||||
const TPlayerItemAttribute& GetAttribute(int i){return attrs[i];}BYTE GetAttributeType(int i){return attrs[i].bType;}
|
||||
int GetAttributeCount(){int n=0;for(int i=0;i<5;++i)n+=attrs[i].bType!=0;return n;}
|
||||
CHARACTER* GetOwner(){return owner;}BYTE GetWindow(){return window;}unsigned GetCell(){return cell;}
|
||||
bool isLocked(){return false;}int GetCount(){return count;}void SetCount(int n){count=n;}
|
||||
bool IsEquipped(){return equipped;}bool IsExchanging(){return exchanging;}
|
||||
};
|
||||
using LPITEM=CItem*;
|
||||
@@ -97,6 +99,7 @@ struct CHARACTER_MANAGER{
|
||||
static std::map<DWORD,unsigned> locks;static bool lockFail=false;
|
||||
unsigned PortAttrLockGet(CItem* item){return locks[item->id];}
|
||||
bool PortAttrLockSet(CHARACTER*,CItem* item,unsigned mask){if(lockFail)return false;locks[item->id]=mask;return true;}
|
||||
const char* PortAttrLockUse(@LOCK_USE@
|
||||
static CHARACTER ch;
|
||||
static void cmd(const char* text){clockms+=300;ch.messages.clear();do_port_switchbot(&ch,text);}
|
||||
static long tick(){for(auto& e:events)if(!e->cancelled&&e->func){long r=e->func(e.get(),0);if(!r)e->func=nullptr;return r;}return -1;}
|
||||
@@ -170,12 +173,19 @@ int main(){
|
||||
ch.vid.id=100;ch.messages.clear();assert(tick()==0 && ch.messages.empty() && g_portSwitchbots.empty());
|
||||
assert(ch.uses==6);
|
||||
|
||||
// Lock toggle: filled slots only, at most 2 groups and never every filled slot, not on the rolling item.
|
||||
// AVA2 lock costs: no material, partial attributes, persistence failure never consume.
|
||||
CItem lockMaterial{2100,50348,ITEM_USE,USE_CHANGE_ATTRIBUTE,-1,40};lockMaterial.owner=&ch;lockMaterial.count=20;
|
||||
CItem unlockMaterial{2101,50349,ITEM_USE,USE_CHANGE_ATTRIBUTE,-1,41};unlockMaterial.owner=&ch;unlockMaterial.count=20;
|
||||
cmd("1 lock 10 0");assert(last()=="MTSB1 error lock material");
|
||||
ch.inventory.push_back(&lockMaterial);ch.inventory.push_back(&unlockMaterial);
|
||||
cmd("1 lock 10 0");assert(last()=="MTSB1 error lock five_attr" && lockMaterial.count==20);
|
||||
armor.attrs[3]={APPLY_MAX_HP,500};armor.attrs[4]={APPLY_STR,1};
|
||||
// Lock toggle: five slots filled, max two groups, not on the rolling item.
|
||||
armor.attrs[0]={APPLY_STR,2};armor.attrs[1]={APPLY_CRITICAL,1};armor.attrs[2]={APPLY_ATTBONUS_MONSTER,2};
|
||||
cmd("1 lock 10 0");assert(last()=="MTSB1 lock 10 11209 1");
|
||||
cmd("1 lock 10 2");assert(last()=="MTSB1 lock 10 11209 5");
|
||||
cmd("1 lock 10 1");assert(last()=="MTSB1 error lock max");
|
||||
cmd("1 lock 10 3");assert(last()=="MTSB1 error lock slot");
|
||||
cmd("1 lock 10 3");assert(last()=="MTSB1 error lock max");
|
||||
cmd("1 lock 10 5");assert(last()=="MTSB1 error lock slot");
|
||||
cmd("1 lock 10 0");assert(last()=="MTSB1 lock 10 11209 4" && locks[1001]==4);
|
||||
cmd("1 lock 10 1");assert(last()=="MTSB1 lock 10 11209 6");
|
||||
@@ -183,7 +193,8 @@ int main(){
|
||||
cmd("1 lock 30 0");assert(last()=="MTSB1 error lock no_attr");
|
||||
cmd("1 lock 99 0");assert(last()=="MTSB1 error lock item");
|
||||
cmd("1 lock 10");assert(last()=="MTSB1 error lock invalid");
|
||||
lockFail=true;cmd("1 lock 10 1");assert(last()=="MTSB1 error lock db" && locks[1001]==6);lockFail=false;
|
||||
assert(lockMaterial.count==17 && unlockMaterial.count==19);
|
||||
lockFail=true;cmd("1 lock 10 1");assert(last()=="MTSB1 error lock db" && locks[1001]==6);lockFail=false;assert(unlockMaterial.count==19);
|
||||
ch.rolls={{{APPLY_STR,2}}};cmd("1 start 10 71084 5 1 3 12");cmd("1 lock 10 1");assert(last()=="MTSB1 error lock running");
|
||||
cmd("1 stop");
|
||||
// Addon weapon: slots 0 and 1 lock together and count as one group.
|
||||
@@ -200,7 +211,7 @@ int main(){
|
||||
cmd("1 start 99999999999 71084 5 1 3 12");assert(ch.messages.empty()); // overlong token
|
||||
puts("PASS: allowed targets, validation, alternatives, original UseItem path, quiet INFO, stop reasons, VID drop");
|
||||
}
|
||||
'''
|
||||
'''.replace('@LOCK_USE@',lock_use)
|
||||
with tempfile.TemporaryDirectory(prefix='mt-switchbot-') 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)
|
||||
|
||||
Reference in New Issue
Block a user