Files

45 lines
2.7 KiB
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#include "gateway/aura_state.hpp"
#include <array>
#include <cstdint>
#include <iostream>
#include <stdexcept>
namespace {
unsigned checks=0;
void check(bool value,const char* reason) { ++checks;if(!value)throw std::runtime_error(reason); }
constexpr uint32_t state(unsigned ordinal) { return uint32_t(1)<<(ordinal-1); }
}
int main() {
using gateway::translate_aura_states;
auto empty=translate_aura_states(0);
check(empty.native_flags==0 && empty.held_source_flags==0,"zero clears every native eligibility flag");
constexpr std::array<unsigned,6> source{1,2,4,5,7,12},native{1,2,4,5,7,13};
for(unsigned ordinal=1;ordinal<=32;++ordinal) {
auto value=translate_aura_states(state(ordinal));bool supported=false;
for(unsigned i=0;i<source.size();++i)if(source[i]==ordinal) {
check(value.native_flags==state(native[i]),"named ordinal to bit mapping");
check(value.held_source_flags==0,"supported source bit consumed");supported=true;
}
if(!supported) {
check(value.native_flags==0,"unsupported source ordinal must not alias native meaning");
check(value.held_source_flags==state(ordinal),"unknown or held bit preserved as held");
}
}
const uint32_t supported=state(1)|state(2)|state(4)|state(5)|state(7)|state(12);
auto mixed=translate_aura_states(UINT32_MAX);
check(mixed.native_flags==(state(1)|state(2)|state(4)|state(5)|state(7)|state(13)),"combined named states");
check(mixed.held_source_flags==~supported,"all held and unknown bits partitioned");
check((mixed.native_flags&state(12))==0,"source health35 must not become native faerie fire");
check(translate_aura_states(state(6)).native_flags==0,"source critical hit must not become native health25");
check(translate_aura_states(state(9)).native_flags==0,"source health15 must not become native dazed");
check(translate_aura_states(state(5)).native_flags==state(5),"active Seal enables native Judgement (20271 CasterAuraState 5)");
check(translate_aura_states(state(7)).native_flags==state(7),"hunter parry enables native Counterattack (19306 CasterAuraState 7)");
// Server health thresholds and transitions are authoritative: source Unit
// sets below20/35 bits; we preserve both and accept actual zero removal.
auto wounded=translate_aura_states(state(2)|state(12));
check(wounded.native_flags==(state(2)|state(13)),"source below20 includes below35");
check(translate_aura_states(state(12)).native_flags==state(13),"source removes20 while35 remains");
check(translate_aura_states(0).native_flags==0,"server removes health states on recovery");
std::cout<<"aura-state checks: "<<checks<<"\n";
}