Preserve human manager identity through national coach record swaps (by Codex)
This commit is contained in:
1 parent
ce1535fe2d
commit
693744a961
16 files changed
+203
-21
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include "modern/app/modern_session.hpp"
|
||||
#include "modern/content/world_package.hpp"
|
||||
#include "modern/ui/demo_opening.hpp"
|
||||
#include "modern/game/national.hpp"
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
@@ -12,7 +13,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","verify-rankings","prepare-rankings-archived","verify-create"};
|
||||
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"};
|
||||
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)); };
|
||||
@@ -85,6 +86,45 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
write("receipt.json",{{"status","passed"},{"cases",cases},{"invalidRequests",7},{"nationalOnly",true}});std::cout<<"real career creation, multiple managers, UTF-8, portrait styles and reload passed\n";return 0;
|
||||
}
|
||||
if(mode=="inspect-coach-identity") {
|
||||
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();modern::UiContext context;context.manager=0;
|
||||
const auto before=Json::parse(cli::dump_json(modern::ui_read(g,context,cli::Json::Object{{"kind","session"}})));write("before.json",before);const auto expected=before.at("data").at("managers").at(2);
|
||||
for(int i=0;i<4;++i)g.manager_records[size_t(i)*0xb0c+0x21c]=i==2?1:0;
|
||||
modern::national_coach_take_over(g,0,2);
|
||||
const auto after=Json::parse(cli::dump_json(modern::ui_read(g,context,cli::Json::Object{{"kind","desktop"}})));write("after.json",after);
|
||||
const auto session_after=Json::parse(cli::dump_json(modern::ui_read(g,context,cli::Json::Object{{"kind","session"}})));write("session-after.json",session_after);
|
||||
write("observations.json",{{"qa_only_eligibility_flags",true},{"chosenHumanSlot",2},{"expected",expected},{"actual",after.at("data").at("manager")},{"ownerMatches",after.at("meta").at("scope").at("managerId")==expected.at("id")},{"nameMatches",after.at("data").at("manager").at("name")==expected.at("name")}});
|
||||
const auto records=g.manager_records;const auto repeated=Json::parse(cli::dump_json(modern::ui_read(g,context,cli::Json::Object{{"kind","desktop"}})));if(repeated!=after||g.manager_records!=records)throw std::runtime_error("coach projection changed records");
|
||||
modern::national_coach_hand_back(g);const auto returned=Json::parse(cli::dump_json(modern::ui_read(g,context,cli::Json::Object{{"kind","session"}})));write("returned.json",returned);
|
||||
if(after.at("meta").at("scope").at("managerId")!=expected.at("id")||after.at("data").at("manager").at("name")!=expected.at("name")||returned.at("data")!=before.at("data"))throw std::runtime_error("coach identity or handback changed humans");
|
||||
if(session_after.at("data").at("managers").size()!=4)throw std::runtime_error("waiting human managers disappeared");
|
||||
modern::set_current_world(nullptr);std::cout<<"coach identity and handback verified\n";return 0;
|
||||
}
|
||||
if(mode=="prepare-coach-identity") {
|
||||
{
|
||||
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);uint64_t revision=0;Json expiry=Json::object(),log=Json::array();bool found=false;
|
||||
for(int turn=0;turn<400;++turn) {
|
||||
auto &g=session.state();if(g.manager_teams.size()==4)for(int i=0;i<4;++i)g.manager_records[size_t(i)*0xb0c+0x21c]=i==2?1:0;
|
||||
const auto desk=Json::parse(cli::dump_json(session.ui_read(cli::Json::Object{{"kind","desktop"}},revision)));
|
||||
if(desk.at("meta").at("scope").at("role")=="national") {write("national.json",desk);if(desk.at("data").at("manager").at("id")!="manager:3")throw std::runtime_error("unexpected coach in controlled career");found=true;break;}
|
||||
const auto &meta=desk.at("meta");const Json command={{"messageType","command"},{"contractVersion",meta.at("contractVersion")},{"requestId","request:coach-advance-"+std::to_string(turn)},{"careerId",meta.at("careerId")},{"expectedRevision",meta.at("stateRevision")},{"owner",{{"managerId",meta.at("scope").at("managerId")}}},{"kind","session.advance"},{"payload",{{"contractExpiry",expiry}}}};
|
||||
const auto reply=Json::parse(cli::dump_json(session.ui_command(cli::parse_json(command.dump()),revision)));log.push_back(reply);
|
||||
if(reply.value("messageType","")=="command_result")continue;if(reply.value("code","")=="decision_pending"){expiry[reply.at("message").at("args").at("playerId").get<std::string>()]={{"action","release"}};continue;}throw std::runtime_error(reply.dump());
|
||||
}
|
||||
write("advance.json",log);if(!found)throw std::runtime_error("controlled national desk not reached");std::string error;if(!session.save_game(out/"national.obs",0,false,error))throw std::runtime_error(error);
|
||||
const auto presentations=session.state().manager_presentations;session.state().manager_presentations.clear();if(!session.save_game(out/"national-legacy.obs",0,false,error))throw std::runtime_error(error);session.state().manager_presentations=presentations;
|
||||
}
|
||||
modern::set_current_world(nullptr);auto loaded=EngineBridge::open(world,out/"national.obs");const auto read=loaded->snapshot();write("loaded.json",read);if(read.at("desktop").at("data").at("manager").at("id")!="manager:3"||read.at("session").at("data").at("managers").size()!=4)throw std::runtime_error("coach identity lost on reload");std::cout<<"controlled real national desk with third human saved and reloaded\n";return 0;
|
||||
}
|
||||
if(mode=="verify-coach-almanac") {
|
||||
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);uint64_t revision=0;
|
||||
const auto initial=session.state().almanac.current.matches.size();const auto desk=Json::parse(cli::dump_json(session.ui_read(cli::Json::Object{{"kind","desktop"}},revision)));const auto &meta=desk.at("meta");
|
||||
const Json command={{"messageType","command"},{"contractVersion",meta.at("contractVersion")},{"requestId","request:coach-match"},{"careerId",meta.at("careerId")},{"expectedRevision",meta.at("stateRevision")},{"owner",{{"managerId",meta.at("scope").at("managerId")}}},{"kind","session.advance"},{"payload",Json::object()}};
|
||||
const auto reply=Json::parse(cli::dump_json(session.ui_command(cli::parse_json(command.dump()),revision)));write("advance.json",reply);if(reply.value("messageType","")!="command_result")throw std::runtime_error(reply.dump());
|
||||
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;
|
||||
}
|
||||
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");
|
||||
|
||||
Reference in new issue
Block a user