Bind native statistics to recorded careers and correct cup winners (by Codex)
This commit is contained in:
1 parent
e3ea03a05d
commit
eb140cdb1c
24 files changed
+296
-33
No files matched your search
@@ -15,25 +15,26 @@ using namespace bmh::modern_ui;
|
||||
int main(int argc, char **argv) {
|
||||
try {
|
||||
const std::string mode=argc>1?argv[1]:"";
|
||||
const std::set<std::string> modes{"prepare","prepare-two","prepare-national","prepare-almanac","inspect","inspect-friendlies","inspect-almanac","verify","verify-lineup","verify-sports","verify-bank","verify-commerce","verify-contracts","verify-calendar","verify-friendlies","verify-national","verify-almanac","verify-shootouts","verify-reports","verify-fixtures","verify-other","verify-rankings","prepare-rankings-archived","verify-create","inspect-coach-identity","prepare-coach-identity","verify-coach-almanac","verify-files"};
|
||||
const std::set<std::string> modes{"prepare","prepare-two","prepare-national","prepare-almanac","inspect","inspect-friendlies","inspect-almanac","verify","verify-lineup","verify-sports","verify-bank","verify-commerce","verify-contracts","verify-calendar","verify-friendlies","verify-national","verify-almanac","verify-shootouts","verify-reports","verify-fixtures","verify-other","verify-rankings","prepare-rankings-archived","verify-create","inspect-coach-identity","prepare-coach-identity","verify-coach-almanac","verify-files","verify-statistics","prepare-statistics","inspect-statistics"};
|
||||
if(argc!=4||!modes.contains(mode))throw std::runtime_error("usage: modern_engine_bridge_probe <prepare[-two|-national|-almanac]|inspect[-friendlies|-almanac]|verify[-lineup|-sports|-bank|-commerce|-contracts|-calendar|-friendlies|-national|-almanac|-shootouts]> <world.obw> <new-output-directory>");
|
||||
const fs::path world = argv[2], out = argv[3]; fs::create_directories(out);
|
||||
const auto write = [&](const char *file, const Json &j) { editor::write_atomic(out / file, j.dump(2)); };
|
||||
if (mode == "prepare-almanac" || std::string(argv[1]) == "prepare-national" || std::string(argv[1]) == "prepare" || std::string(argv[1]) == "prepare-two") {
|
||||
if (mode == "prepare-statistics" || mode == "prepare-almanac" || std::string(argv[1]) == "prepare-national" || std::string(argv[1]) == "prepare" || std::string(argv[1]) == "prepare-two") {
|
||||
auto package = modern::open_world_package(world);
|
||||
content::Mount mount(world, package.classic); modern::set_current_world(package.world);
|
||||
modern::app::ModernSession session(mount.root(), 17u);
|
||||
ui::SetupOptions options; options.mode = 3; if(mode=="prepare-almanac") options.world=false; if (std::string(argv[1]) == "prepare-national") options.league = false; options.managers = std::string(argv[1]) == "prepare-two" ? 2 : 1;
|
||||
ui::SetupOptions options; options.mode = 3; if(mode=="prepare-almanac"||mode=="prepare-statistics") options.world=false; if (std::string(argv[1]) == "prepare-national") options.league = false; options.managers = std::string(argv[1]) == "prepare-two" ? 2 : 1;
|
||||
ui::ManagerChoice manager; manager.name = "Codex Engine QA"; manager.master_club = 0;
|
||||
std::string error; ui::CareerInitializationResult result;
|
||||
if (!session.confirm_manager(options, manager, error)) throw std::runtime_error(error);
|
||||
if (options.managers == 2) { manager.name = "Codex Opponent QA"; manager.master_club = 1; manager.portrait = 1; if (!session.confirm_manager(options, manager, error)) throw std::runtime_error(error); }
|
||||
if (!session.finish(result, error)) throw std::runtime_error(error);
|
||||
if (mode == "prepare-national" || mode == "prepare-almanac") {
|
||||
if (mode == "prepare-national" || mode == "prepare-almanac" || mode == "prepare-statistics") {
|
||||
uint64_t rev = 0; bool found = false; Json expiry = Json::object(), log = Json::array();
|
||||
for (int k = 0; k < 200; ++k) {
|
||||
const auto desk = Json::parse(cli::dump_json(session.ui_read(cli::Json::Object{{"kind","desktop"}},rev)));
|
||||
if (mode=="prepare-national" && desk.at("meta").at("scope").at("role") == "national") { found = true; break; }
|
||||
if(mode=="prepare-statistics"&&!session.state().almanac.finished.empty()){found=true;break;}
|
||||
if(mode=="prepare-almanac") {const auto index=Json::parse(cli::dump_json(session.read_almanac(cli::Json::Object{{"kind","index"}})));if(index.value("ok",false)&&index.at("years").size()>=2){found=true;break;}}
|
||||
const auto &meta = desk.at("meta");
|
||||
const Json command{{"messageType","command"},{"contractVersion",meta.at("contractVersion")},{"requestId","request:prepare-national-"+std::to_string(k)},{"careerId",meta.at("careerId")},{"expectedRevision",meta.at("stateRevision")},{"owner",{{"managerId",meta.at("scope").at("managerId")}}},{"kind","session.advance"},{"payload",{{"contractExpiry",expiry}}}};
|
||||
@@ -127,9 +128,25 @@ int main(int argc, char **argv) {
|
||||
const auto &season=session.state().almanac.current;bool found=false;Json recorded=Json::array();for(size_t i=initial;i<season.matches.size();++i){const auto &match=season.matches[i];for(int manager:{int(match.home_manager),int(match.away_manager)})if(manager>=0){const auto &person=season.managers.at(size_t(manager));recorded.push_back({{"managerIndex",person.index},{"name",person.name},{"matchType",match.type}});if(match.type==7||match.type==8){if(person.index!=2||person.name!="Alex Berger")throw std::runtime_error("national archive used another human");found=true;}}}
|
||||
if(!found)throw std::runtime_error("no human national match recorded");write("recorded-managers.json",recorded);write("returned.json",Json::parse(cli::dump_json(session.ui_read(cli::Json::Object{{"kind","session"}},revision))));std::string error;const int active=session.state().memory.u8(::bmh::layout::ActiveManager);if(!session.save_game(out/"after-national.obs",active,false,error))throw std::runtime_error(error);modern::set_current_world(nullptr);std::cout<<"national archive attributed to third human\n";return 0;
|
||||
}
|
||||
if(mode=="inspect-statistics") {
|
||||
auto package=modern::open_world_package(world);content::Mount mount(world,package.classic);modern::set_current_world(package.world);modern::app::ModernSession session(mount.root(),1u,out/"input.obs",false);
|
||||
write("winner-records.json",Json::parse(cli::dump_json(session.read_statistics(cli::Json::Object{{"kind","winners"}}))));modern::set_current_world(nullptr);return 0;
|
||||
}
|
||||
auto link = EngineBridge::open(world, out / "input.obs");
|
||||
const auto before = link->snapshot(); write("before.json", before);
|
||||
if (before != link->snapshot()) throw std::runtime_error("reads changed the engine projection");
|
||||
if(mode=="verify-statistics") {
|
||||
Json all=Json::array();
|
||||
const auto run=[&](const Json &query){const auto read=link->read({{"kind","statistics"},{"query",query}});auto value=engine_statistics_projection(before,read);if(link->read({{"kind","statistics"},{"query",query}})!=read)throw std::runtime_error("statistics read not repeatable");all.push_back({{"query",query},{"read",read},{"projection",value}});return value;};
|
||||
for(int section=0;section<9;++section)run({{"section",section}});
|
||||
for(int country=0;country<6;++country){run({{"section",3},{"country",country}});run({{"section",4},{"country",country}});}
|
||||
for(int category:{0,1,5})run({{"section",7},{"category",category}});
|
||||
const auto index=run({{"section",7}});for(const auto &country:index.at("countries"))run({{"section",7},{"winner_country",country.at("id")}});
|
||||
run({{"section",2},{"absolute",true},{"curves",{false,true,false,true,false,true}}});
|
||||
if(link->snapshot()!=before)throw std::runtime_error("statistics reads changed session");
|
||||
for(const auto &query:Json::array({Json{{"section",9}},Json{{"unknown",true}},Json{{"section",7},{"winner_country","nation:missing"}}})){const auto result=link->read({{"kind","statistics"},{"query",query}});if(result.value("messageType","")!="error"||link->snapshot()!=before)throw std::runtime_error("invalid statistics filter not rejected purely");}
|
||||
write("all-statistics.json",all);write("saved.json",link->save_copy(out/"unchanged.obs"));write("receipt.json",{{"status","passed"},{"reads",int(all.size())},{"invalidFilters",3},{"readOnly",true}});std::cout<<"real statistics filters, series and read purity passed\n";return 0;
|
||||
}
|
||||
if(mode=="verify-files") {
|
||||
auto store=make_career_files(out/"library",world);const auto meta=link->file_metadata();write("metadata.json",meta);
|
||||
const auto first=store.put("Erste Saison",[&](const auto &path){link->save_copy(path);});
|
||||
|
||||
Reference in new issue
Block a user