Bind player rankings and fair play to recorded season events (by Codex)
This commit is contained in:
1 parent
6b4aa9772d
commit
738ecc7a09
27 files changed
+436
-36
No files matched your search
@@ -11,7 +11,7 @@ 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"};
|
||||
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"};
|
||||
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)); };
|
||||
@@ -44,6 +44,21 @@ int main(int argc, char **argv) {
|
||||
if (!session.save_game(out / "input.obs", 0, false, error)) throw std::runtime_error(error);
|
||||
modern::set_current_world(nullptr);
|
||||
}
|
||||
if(mode=="prepare-rankings-archived") {
|
||||
std::string person,league;
|
||||
{
|
||||
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);auto &g=session.state();league=g.world_league_id.at(0);
|
||||
const auto read=Json::parse(cli::dump_json(session.ui_read(cli::Json::Object{{"kind","player-rankings"},{"leagueId",league},{"scope",0}},0)));
|
||||
person=read.at("data").at("categories")[0][0].at("player").at("id");
|
||||
const auto found=std::find(g.world_player_id.begin(),g.world_player_id.end(),person);if(found==g.world_player_id.end())throw std::runtime_error("archive fixture player missing");const auto player=size_t(found-g.world_player_id.begin());
|
||||
for(auto &slot:g.squad_slots)if((slot&0x0fff)==player)slot=kEmptySlot;
|
||||
std::string error;if(!session.save_game(out/"archived.obs",0,false,error))throw std::runtime_error(error);
|
||||
write("synthetic-mutation.json",{{"qa_only",true},{"kind","remove-current-squad-membership"},{"playerId",person},{"archive","unchanged"},{"real_retirement",false}});
|
||||
}
|
||||
modern::set_current_world(nullptr);auto fixture=EngineBridge::open(world,out/"archived.obs");const auto bundle=fixture->snapshot(),index=fixture->read({{"kind","report-index"}}),read=fixture->read({{"kind","player-rankings"},{"leagueId",league},{"scope",0}});const auto value=engine_rankings_projection(bundle,index,read,league,0);
|
||||
if(value.at("categories")[0][0].at("player")!=person||!value.at("categories")[0][0].at("currentTeam").is_null())throw std::runtime_error("archived-only counterexample not retained");write("rankings.json",read);std::cout<<"synthetic archived-only rankings fixture passed\n";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");
|
||||
@@ -337,6 +352,13 @@ int main(int argc, char **argv) {
|
||||
write("saved.json",link->save_copy(out/"reports.obs"));link.reset();link=EngineBridge::open(world,out/"reports.obs");
|
||||
if(link->read({{"kind","report-index"}}).at("data")!=index_read.at("data"))throw std::runtime_error("report index changed after OBS restart");
|
||||
}
|
||||
if(mode=="verify-rankings") {
|
||||
const auto index=link->read({{"kind","report-index"}}),catalogue=engine_report_index(before,index);write("rankings-index.json",index);Json all=Json::array();
|
||||
for(const auto &league:catalogue.at("leagues"))for(int scope=0;scope<2;++scope){const Json request={{"kind","player-rankings"},{"leagueId",league.at("id")},{"scope",scope}};const auto read=link->read(request);write("latest-read.json",read);(void)engine_rankings_projection(before,index,read,league.at("id"),scope);if(link->read(request)!=read)throw std::runtime_error("rankings read is not repeatable");all.push_back(read);}
|
||||
const auto fair=link->read({{"kind","fairplay"}});write("fairplay.json",fair);(void)engine_fairplay_projection(before,index,fair);write("all-rankings.json",all);
|
||||
if(link->snapshot()!=before)throw std::runtime_error("rankings changed engine");write("saved.json",link->save_copy(out/"rankings.obs"));link.reset();link=EngineBridge::open(world,out/"rankings.obs");
|
||||
if(link->read({{"kind","fairplay"}}).at("data")!=fair.at("data"))throw std::runtime_error("fairplay changed after OBS restart");
|
||||
}
|
||||
if(mode=="verify-other") {
|
||||
const auto index=link->read({{"kind","other-index"}}),data=engine_other_index(before,index);write("other-index.json",index);Json all=Json::array();
|
||||
for(const auto &v:data.at("views"))for(int round=1;round<=v.at("rounds").get<int>();++round) {
|
||||
|
||||
Reference in new issue
Block a user