"""Execute spectator key-edge and retained firearm eligibility policies.""" from policy_harness import ROOT,body,run core=ROOT/'addons/core/Scripts/Game/ERR/00_Core' cycle=body(core/'ERR_Observer.c','static int Cycle(') firearm=body(core/'ERR_UnconsciousWeapon.c','static bool Firearm(').replace('EWeaponType.','EWeaponType::') run('''#include #include namespace EWeaponType {enum{WT_NONE,WT_RIFLE,WT_GRENADELAUNCHER,WT_SNIPERRIFLE,WT_ROCKETLAUNCHER,WT_MACHINEGUN,WT_HANDGUN,WT_FRAGGRENADE,WT_SMOKEGRENADE,WT_AUTOCANNON,WT_COUNT};} '''+cycle+body(core/'ERR_Observer.c','static bool Toggle(')+firearm+''' int main(){ for(bool enabled:{false,true})for(bool pressed:{false,true})for(bool previous:{false,true}) assert(Toggle(enabled,pressed,previous)==(enabled&&pressed&&!previous)); assert(Cycle(true,true,false,false,false)==-1); assert(Cycle(true,false,true,false,false)==1); assert(Cycle(true,true,false,true,false)==0); // held arrow does not repeat assert(Cycle(true,false,true,false,true)==0); assert(Cycle(true,true,true,false,false)==0); // opposing arrows cancel assert(Cycle(false,true,false,false,false)==0); // menus/chat consume input assert(Cycle(false,false,true,false,false)==0); assert(Cycle(true,false,true,true,false)==1); // direct direction change for(int kind=0;kind=1&&kind<=6)); assert(!Firearm(-1)&&!Firearm(100)); // no grenade/gadget/turret retention } ''') print('PASS: arrow press/release, held keys, opposing keys, disabled/menu input and firearm-only retention')