46 lines
2.3 KiB
Python
46 lines
2.3 KiB
Python
"""Run the actual fixture method against a narrow native-damage API fake."""
|
|
from policy_harness import ROOT, body, run
|
|
p=ROOT/'addons/core/Scripts/Game/ERR/ERR_NativeCasualtyLoadProbe.c'
|
|
method=body(p,'protected bool IncapacitateGroundCasualty(')
|
|
method=method.replace('protected bool','bool').replace('m_Damage.','m_Damage->').replace('resilience.','resilience->').replace('ERR_Actors.','ERR_Actors::').replace('null','nullptr')
|
|
run('''
|
|
#include <cassert>
|
|
#include <initializer_list>
|
|
struct NativeHitZone { float health=100; float GetHealth(){return health;} };
|
|
using HitZone=NativeHitZone*;
|
|
struct Actor { bool alive=true; };
|
|
struct Damage {
|
|
NativeHitZone resilience; bool enabled=true, missing=false, swallow=false; int forces=0;
|
|
HitZone GetResilienceHitZone(){return missing ? nullptr : &resilience;}
|
|
bool IsDamageHandlingEnabled(){return enabled;}
|
|
void EnableDamageHandling(bool value){enabled=value;}
|
|
void ForceUnconsciousness(){forces++; if(enabled && !swallow)resilience.health=0;}
|
|
};
|
|
struct ERR_Actors {static bool Alive(Actor* actor){return actor && actor->alive;}};
|
|
Actor* m_Casualty; Damage* m_Damage;
|
|
bool Check(bool value,const char*){return value;}
|
|
template<class... Args> void PrintFormat(const char*,Args...){}
|
|
'''+method+'''
|
|
int main(){
|
|
Actor actor; m_Casualty=&actor;
|
|
for(bool original:{false,true}) {
|
|
Damage damage; m_Damage=&damage; damage.enabled=original;
|
|
assert(IncapacitateGroundCasualty());
|
|
assert(damage.forces==1 && damage.resilience.health==0 && actor.alive);
|
|
assert(damage.enabled==original);
|
|
// No second artificial reduction: already-zero initial state must fail.
|
|
assert(!IncapacitateGroundCasualty());
|
|
assert(damage.enabled==original);
|
|
}
|
|
Damage blocked; blocked.enabled=false; blocked.swallow=true; m_Damage=&blocked;
|
|
assert(!IncapacitateGroundCasualty());
|
|
assert(blocked.forces==1 && !blocked.enabled && actor.alive);
|
|
Damage missing; missing.missing=true; m_Damage=&missing;
|
|
assert(!IncapacitateGroundCasualty() && missing.forces==0);
|
|
m_Damage=nullptr; assert(!IncapacitateGroundCasualty());
|
|
Damage dead; m_Damage=&dead; actor.alive=false;
|
|
assert(!IncapacitateGroundCasualty() && dead.forces==0);
|
|
}
|
|
''')
|
|
print('PASS: actual fixture method permits one native resilience operation and restores either prior protection state, including failure paths')
|