59 lines
4.0 KiB
C++
59 lines
4.0 KiB
C++
#include "gateway/spell_modifiers.hpp"
|
|
#include "gateway/spell_modifier_group_profile.hpp"
|
|
#include <algorithm>
|
|
#include <bit>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
|
|
using namespace gateway;
|
|
using namespace gateway::spell_modifier;
|
|
namespace {
|
|
unsigned checks=0;
|
|
void require(bool ok,const char* message){++checks;if(!ok){std::cerr<<message<<'\n';std::exit(1);}}
|
|
bool contains(const std::vector<LegacyPacket>& packets,uint32_t opcode,const Bytes& body){
|
|
return std::any_of(packets.begin(),packets.end(),[&](const auto& p){return p.opcode==opcode && p.body==body;});
|
|
}
|
|
}
|
|
int main(){
|
|
// Actual pinned private membership: Charge100 -> family4 bit121.
|
|
// Source op11 uses milliseconds; the native flat amount remains -2000.
|
|
std::array<int32_t,64> state{};state[0]=-2000;
|
|
auto packets=translate_group_snapshot(1,11,Kind::Flat,state,1);
|
|
require(contains(packets,0x690027,{1,0,0,0,11,1,0,0,0,0,0,250,196,121}),"Charge private group/flat packet differs");
|
|
// Actual Renew139 membership -> family6 bit123, source mask bit6.
|
|
state.fill(0);state[6]=30;
|
|
packets=translate_group_snapshot(5,8,Kind::Percent,state,uint64_t(1)<<6);
|
|
require(contains(packets,0x690028,{1,0,0,0,8,1,0,0,0,102,102,166,63,123}),"Renew percent factor or group differs");
|
|
state[6]=0;
|
|
packets=translate_group_snapshot(5,8,Kind::Percent,state,uint64_t(1)<<6);
|
|
require(contains(packets,0x690028,{1,0,0,0,8,1,0,0,0,0,0,128,63,123}),"Percent removal must restore factor one");
|
|
require(translate_group_snapshot(5,8,Kind::Percent,state,0).empty(),"Unavailable values must not be invented");
|
|
require(translate_group_snapshot(6,8,Kind::Percent,state,~uint64_t(0)).empty(),"Unsupported class received a route");
|
|
require(translate_group_snapshot(5,33,Kind::Percent,state,~uint64_t(0)).empty(),"Unqualified source operation received a route");
|
|
// Rip1079 has a primary energy row at index0 and a secondary combo row.
|
|
// The secondary row must not suppress the proven primary-cost mapping.
|
|
state.fill(0);state[3]=-20;
|
|
packets=translate_group_snapshot(11,14,Kind::Percent,state,uint64_t(1)<<3);
|
|
require(contains(packets,0x690028,{1,0,0,0,14,1,0,0,0,205,204,76,63,112}),"Secondary combo row incorrectly blocked primary-cost factor");
|
|
state.fill(0);
|
|
state[1]=30;
|
|
packets=translate_group_snapshot(5,8,Kind::Percent,state,~uint64_t(0));
|
|
require(contains(packets,0x690028,{1,0,0,0,8,1,0,0,0,102,102,166,63,115}),"Inner Fire percent group (bit115) not released");
|
|
// Mixed pair: Turtle base*(1+P)+F; native (base+F')*(1+P) -> F'=F/(1+P).
|
|
auto f32=[](float v){Bytes b;le(b,std::bit_cast<uint32_t>(v),4);return b;};
|
|
auto flat_body=[&](float v){Bytes b{1,0,0,0,8,1,0,0,0};auto x=f32(v);b.insert(b.end(),x.begin(),x.end());b.push_back(115);return b;};
|
|
std::array<int32_t,64> flat{},pct{};flat[1]=26;pct[1]=30;
|
|
auto mixed=translate_group_state(5,8,flat,pct,~uint64_t(0));
|
|
require(contains(mixed,0x690027,flat_body(float(26.0/1.3))),"Mixed flat not divided by partner percent");
|
|
require(contains(mixed,0x690028,{1,0,0,0,8,1,0,0,0,102,102,166,63,115}),"Mixed percent missing");
|
|
// A percent change re-sends the partner flat; a flat change sends only flat.
|
|
pct[1]=0;mixed=translate_group_state(5,8,flat,pct,~uint64_t(0),ChangedSource{Kind::Percent,1});
|
|
require(contains(mixed,0x690027,flat_body(26.0f)) && contains(mixed,0x690028,{1,0,0,0,8,1,0,0,0,0,0,128,63,115}),"Percent change must re-send flat partner");
|
|
mixed=translate_group_state(5,8,flat,pct,~uint64_t(0),ChangedSource{Kind::Flat,1});
|
|
require(std::none_of(mixed.begin(),mixed.end(),[](const auto& p){return p.opcode==0x690028;}),"Flat change re-sent percent");
|
|
pct[1]=-100;mixed=translate_group_state(5,8,flat,pct,~uint64_t(0));
|
|
require(std::none_of(mixed.begin(),mixed.end(),[](const auto& p){return p.opcode==0x690027 && p.body.back()==115;}),"P=-100 has no native flat equivalent");
|
|
require(!group_profile::ReleaseQualified,"Offline profile must not advertise release qualification");
|
|
std::cout<<checks<<" group projection checks passed\n";
|
|
}
|