Files
EscapistsReintroduced/tests/test_optional_motorbikes.py
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

27 lines
1.6 KiB
Python

"""Execute production soft-dependency, prefab and seat admission rules."""
from policy_harness import ROOT, body, run
p = ROOT/'addons/core/Scripts/Game/ERR/10_AI/ERR_OptionalMotorbikes.c'
methods = '\n'.join(body(p, key) for key in ('static bool Loaded(', 'static bool Seats(', 'static bool Candidate('))
methods = methods.replace('array<string> addons', 'Array<string> addons')
run(r'''
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
struct string:std::string{using std::string::string;void ToLower(){std::transform(begin(),end(),begin(),[](unsigned char c){return std::tolower(c);});}bool Contains(string s){return find(s)!=npos;}bool EndsWith(string s){return size()>=s.size()&&compare(size()-s.size(),s.size(),s)==0;}};
template<class T>struct Array:std::vector<T>{using std::vector<T>::vector;bool Contains(T s){return std::find(this->begin(),this->end(),s)!=this->end();}};
''' + methods + r'''
int main(){
Array<string> mods={"6503091A7B264FC3","61B84088181A8FA4","629B2BA37EFFD577"};
assert(Loaded(mods));assert(!Loaded({}));
for(int i=0;i<3;i++){auto missing=mods;missing.erase(missing.begin()+i);assert(!Loaded(missing));}
assert(Seats(1,0,1,2));assert(!Seats(1,1,0,2));assert(!Seats(1,0,0,1));assert(!Seats(1,0,2,3));
assert(Candidate("{FFC159091F467E53}Prefabs/Vehicles/Wheeled/RX100/WCS_RX100_FIA.et"));
assert(!Candidate("Prefabs/Vehicles/Wheeled/RX100/WCS_RX100_Base.et"));
assert(!Candidate("Prefabs/Vehicles/Wheeled/RX100/WCS_RX100_wreck.et"));
assert(!Candidate("Prefabs/Characters/RX100.et"));
}
''')
print('PASS: motorbikes require all mounted addons and exactly two crew seats; base/wreck prefabs rejected')