Port lineup and transfer market to the native Modern UI (by Codex)
This commit is contained in:
1 parent
ec1d804d08
commit
bf3f910437
33 files changed
+3339
-29
No files matched your search
@@ -9,6 +9,8 @@
|
||||
#include "modern/ui/demo_environment.hpp"
|
||||
#include "modern/ui/demo_advertising.hpp"
|
||||
#include "modern/ui/demo_toto.hpp"
|
||||
#include "modern/ui/demo_lineup.hpp"
|
||||
#include "modern/ui/demo_transfer.hpp"
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@@ -65,6 +67,54 @@ void check_club_views(const fs::path &root, std::shared_ptr<const Catalog> world
|
||||
require(migrated["environment"] == initial.state["environment"] && migrated["advertising"] == initial.state["advertising"] && migrated["toto"] == initial.state["toto"], "Legacy club fields not initialized");
|
||||
require(migrated["cash"] == changed.state["cash"] && migrated["finance"] == changed.state["finance"], "Legacy migration reset wallet");
|
||||
}
|
||||
void check_squad_source(const fs::path &root, const std::shared_ptr<const Catalog> &world) {
|
||||
DemoSource source(world);
|
||||
const auto initial = source.snapshot();
|
||||
const auto club = initial.state.at("managers")[0].at("club").get<std::string>();
|
||||
require(valid_demo_lineup(initial.state, *world, club) && valid_demo_transfer(initial.state, *world, club),
|
||||
"Lineup/transfer initialization failed for a small synthetic squad");
|
||||
require(source.apply({initial.revision, "transfer", {{"kind", "search"}, {"query", "Synthetic"}}}).ok,
|
||||
"Transfer search failed through the source boundary");
|
||||
const auto searched = source.snapshot();
|
||||
require(!source.apply({initial.revision, "lineup", {{"kind", "weight"}, {"index", 0}}}).ok &&
|
||||
source.snapshot().revision == searched.revision && source.snapshot().state == searched.state,
|
||||
"Stale lineup request changed state");
|
||||
const auto points = searched.state.at("lineup").at("points");
|
||||
const auto &order = searched.state.at("lineup").at("order");
|
||||
require(order.size() >= 2, "Synthetic roster needs two players");
|
||||
require(source.apply({searched.revision, "lineup", {{"kind", "move"}, {"player", order[1]}, {"point", {6,1}}}}).ok,
|
||||
"Lineup move failed through the source boundary");
|
||||
auto changed = source.snapshot();
|
||||
require(tactics_diagram(changed.state.at("tactics"), "midnight", points) !=
|
||||
tactics_diagram(changed.state.at("tactics"), "midnight", changed.state.at("lineup").at("points")),
|
||||
"Tactics did not reflect edited lineup positions");
|
||||
for (const auto *key : {"cash", "deposit", "debt", "training", "tactics", "calendar", "reports", "finance", "contracts"})
|
||||
require(changed.state.at(key) == initial.state.at(key), "Squad preview changed unrelated game state");
|
||||
auto bad = Json{{"kind", "move"}, {"player", order[1]}, {"point", {19,1}}};
|
||||
require(!source.apply({changed.revision, "lineup", bad}).ok && source.snapshot().state == changed.state,
|
||||
"Rejected lineup position partially committed");
|
||||
const auto file = root / "squad-checkpoint.json";
|
||||
source.save(file, default_desktop());
|
||||
require(!source.dirty(), "Squad checkpoint did not clear dirty marker");
|
||||
source.apply({source.snapshot().revision, "transfer", {{"kind", "search"}, {"query", "Different"}}});
|
||||
source.load(file);
|
||||
require(source.snapshot().state == changed.state && !source.dirty(), "Squad preview did not roundtrip");
|
||||
auto invalid = changed.state; invalid["desktop"] = default_desktop();
|
||||
invalid["lineup"]["order"][0] = invalid["lineup"]["order"][1];
|
||||
{std::ofstream out(file);out << invalid.dump();}
|
||||
const auto before = source.snapshot(); bool rejected = false;
|
||||
try {source.load(file);} catch (const std::exception &) {rejected = true;}
|
||||
require(rejected && source.snapshot().state == before.state && source.snapshot().revision == before.revision,
|
||||
"Malformed squad checkpoint partially replaced the source");
|
||||
auto legacy = changed.state; legacy["desktop"] = default_desktop();
|
||||
legacy.erase("lineup"); legacy.erase("transfer");
|
||||
{std::ofstream out(file);out << legacy.dump();}
|
||||
source.load(file);
|
||||
require(source.snapshot().state.at("lineup") == initial.state.at("lineup") &&
|
||||
source.snapshot().state.at("transfer") == initial.state.at("transfer") &&
|
||||
source.snapshot().state.at("cash") == changed.state.at("cash"),
|
||||
"Legacy squad migration reset finances or failed to initialize defaults");
|
||||
}
|
||||
void check_finance_source(const fs::path &root,
|
||||
const std::shared_ptr<const Catalog> &base) {
|
||||
const auto folder = root / "finance-source";
|
||||
@@ -168,6 +218,8 @@ void check_finance_source(const fs::path &root,
|
||||
const auto changed = source.snapshot();
|
||||
require(change.ok && changed.revision == accepted.revision + 1 &&
|
||||
changed.state["contracts"] == demo_contracts(*world, "club:finance-next") &&
|
||||
changed.state["lineup"] == demo_lineup(*world, "club:finance-next") &&
|
||||
changed.state["transfer"] == demo_transfer(*world, "club:finance-next") &&
|
||||
changed.state["contracts"]["players"].contains("player:finance-next") &&
|
||||
!changed.state["contracts"]["players"].contains("player:a") &&
|
||||
changed.state["cash"] == accepted.state["cash"] &&
|
||||
@@ -469,6 +521,18 @@ int main(int argc, char **argv) try {
|
||||
require(diagram.width == 256 && diagram.height > 0,
|
||||
"Tactic SVG failed to decode");
|
||||
}
|
||||
const Json formation_points = {{0,4},{5,1},{5,3},{5,5},{5,7},{10,1},{10,3},{10,5},{10,7},{16,3},{16,5}};
|
||||
auto moved_points = formation_points;
|
||||
moved_points[1] = {6,1};
|
||||
require(tactics_diagram(demo_tactics(), "midnight", formation_points) !=
|
||||
tactics_diagram(demo_tactics(), "midnight", moved_points),
|
||||
"Tactic projection ignored the current lineup positions");
|
||||
auto invalid_points = formation_points;
|
||||
invalid_points[1] = invalid_points[0];
|
||||
bool duplicate_rejected = false;
|
||||
try { tactics_diagram(demo_tactics(), "midnight", invalid_points); }
|
||||
catch (const bmh::editor::Error &) { duplicate_rejected = true; }
|
||||
require(duplicate_rejected, "Tactic projection silently accepted duplicate lineup positions");
|
||||
const auto leap_days = calendar_days("2027-07-01");
|
||||
require(leap_days.size() == 366 && leap_days.front().weekday == 3 &&
|
||||
leap_days.back().iso == "2028-06-30" &&
|
||||
@@ -620,6 +684,7 @@ int main(int argc, char **argv) try {
|
||||
"Old checkpoint lost league preview or failed planning/indoor migration");
|
||||
check_finance_source(root, world);
|
||||
check_club_views(root, world);
|
||||
check_squad_source(root, world);
|
||||
GuiAssets absent(root / "missing-gui");
|
||||
require(!absent.available(),
|
||||
"World resources were mistaken for GUI resources");
|
||||
|
||||
Reference in new issue
Block a user