Bind tactics and training drafts to confirmed engine commits (by Codex)

This commit is contained in:
Codex committed 2026-10-28 09:57:12 +01:00
1 parent 7d3b3f1101
commit f75e0f8e49
18 files changed
+398 -43

No files matched your search

+24 -1
View File
@@ -8,7 +8,7 @@ using namespace bmh;
using namespace bmh::modern_ui;
int main(int argc, char **argv) {
try {
if (argc != 4 || (std::string(argv[1]) != "prepare" && std::string(argv[1]) != "verify" && std::string(argv[1]) != "verify-lineup")) throw std::runtime_error("usage: modern_engine_bridge_probe prepare|verify|verify-lineup <world.obw> <new-output-directory>");
if (argc != 4 || (std::string(argv[1]) != "prepare" && std::string(argv[1]) != "verify" && std::string(argv[1]) != "verify-lineup" && std::string(argv[1]) != "verify-sports")) throw std::runtime_error("usage: modern_engine_bridge_probe prepare|verify|verify-lineup|verify-sports <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 (std::string(argv[1]) == "prepare") {
@@ -57,6 +57,29 @@ int main(int argc, char **argv) {
link = EngineBridge::open(world, out / "lineup.obs"); const auto loaded = link->snapshot(); write("lineup-loaded.json", loaded);
if (loaded.at("lineup").at("data").at("order") != order) throw std::runtime_error("lineup lost during OBS round trip");
}
if (std::string(argv[1]) == "verify-sports") {
auto tactics = engine_tactics_projection(before); tactics["values"][0] = 1; tactics["values"][7] = 7;
const auto tc = engine_tactics_command(before, tactics.at("values"), "request:sports-tactics");
const auto tr = link->command(tc); write("tactics-command.json", tc); write("tactics-response.json", tr);
if (tr.value("messageType", "") != "command_result" || link->command(tc) != tr) throw std::runtime_error(tr.dump());
const auto tactic_after = link->snapshot(); write("tactics-after.json", tactic_after);
if (engine_tactics_projection(tactic_after).at("values") != tactics.at("values")) throw std::runtime_error("tactics not applied");
auto training = engine_training_projection(tactic_after);
training["types"] = Json::array({1,3,2,2}); training["areas"] = Json::array({1,3,3,1,2,2,2,2,2});
const auto player = training.at("roster")[0].at("id").get<std::string>(); training["players"][player]["intensity"] = 3;
const auto pc = engine_training_command(tactic_after, training, "request:sports-training");
const auto pr = link->command(pc); write("training-command.json", pc); write("training-response.json", pr);
if (pr.value("messageType", "") != "command_result" || link->command(pc) != pr) throw std::runtime_error(pr.dump());
const auto after = link->snapshot(); write("sports-after.json", after); const auto actual = engine_training_projection(after);
if (actual.at("types") != training.at("types") || actual.at("areas") != training.at("areas") || actual.at("players").at(player).at("intensity") != 3 || !actual.at("initialized").get<bool>()) throw std::runtime_error("training not applied");
if (after.at("desktop").at("data").at("accounts") != before.at("desktop").at("data").at("accounts")) throw std::runtime_error("sports changed account");
auto stale = pc; stale["requestId"] = "request:stale-sports";
const auto rejected = link->command(stale); write("sports-rejected.json", rejected);
if (rejected.value("code", "") != "stale_revision" || link->snapshot() != after) throw std::runtime_error("stale sports request changed state");
write("sports-saved.json", link->save_copy(out / "sports.obs")); link.reset();
link = EngineBridge::open(world, out / "sports.obs"); const auto loaded = link->snapshot(); write("sports-loaded.json", loaded);
if (engine_tactics_projection(loaded).at("values") != tactics.at("values") || engine_training_projection(loaded).at("types") != training.at("types") || engine_training_projection(loaded).at("areas") != training.at("areas")) throw std::runtime_error("sports lost in OBS round trip");
}
std::cout << "engine bridge " << argv[1] << " passed\n"; return 0;
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
}