Files
EscapistsReintroduced/tests/test_mission_rules.py
T
jakub cab998fb64 Combine Workshop addon and fix prison startup
Merge owned systems into one addon while preserving resource identities. Gate player admission on the replicated prison scene, restore the original framed door, and hold enemy AI until escape. Correct scenario branding and author metadata, include publishing assets, and retain regression and native verification evidence.
2026-09-20 16:42:52 +02:00

30 lines
1.6 KiB
Python

from policy_harness import ROOT,body,run
source=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_MissionRules.c'
rules='\n'.join(body(source,x) for x in ['static bool Terminal(', 'static bool CanTransition(', 'static bool DefenceComplete(', 'static bool ContactFresh(', 'static int Discovery(']).replace('ERR_Phase.', 'ERR_Phase::')
rules += '\n' + body(ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_PlayerRoster.c', 'static bool CanEnter(').replace('ERR_Phase.', 'ERR_Phase::')
run('''#include <cassert>
namespace ERR_Phase {enum {PREPARING,PRISON,RADIO_SEARCH,RADIO_DEFENCE,EXTRACTION,VICTORY,DEFEAT};}
'''+rules+'''
int main(){
for(int phase=-1;phase<=7;phase++){
assert(!CanEnter(true,phase));
assert(CanEnter(false,phase)==(phase>=1&&phase<=3));
}
for(int from=0;from<=6;from++)for(int to=0;to<=6;to++){
bool expected=(from<5&&to==from+1)||(from>=1&&from<=4&&to==6);
assert(CanTransition(from,to)==expected);
}
assert(!DefenceComplete(100,0,180,true));assert(DefenceComplete(180,0,180,true));
assert(!DefenceComplete(180,0,180,false));assert(!DefenceComplete(300,-1,180,true));
assert(!DefenceComplete(10,20,180,true));assert(!DefenceComplete(300,0,0,true));
assert(ContactFresh(0,120000));assert(!ContactFresh(0,120001));
assert(!ContactFresh(100,99));assert(!ContactFresh(-1,0));
for(int roll=0;roll<100;roll++){
assert(Discovery(0,roll,0)==1);assert(Discovery(0,roll,100)==2);
assert(Discovery(1,roll,0)==2);assert(Discovery(2,roll,0)==2);
assert(Discovery(0,roll,15)==(roll<15?2:1));
}
}
''')
print('PASS: all phase transitions, terminal states, defence boundaries, stale/future observations, intel discovery')