Formations can be used and saved in the line-up
The read "lineup" states the manager's eight formations (four given, four of his own) and the one in use; "lineup.setFormation" uses one, the assistant placing the eleven on it, or keeps the places as they stand as one of the own formations. The line-up page shows them as small pitches behind "Aufst.". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
7424b09738
commit
abbd4afe70
9 files changed
+153
-5
No files matched your search
@@ -9261,8 +9261,26 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
|
||||
if ((g_.squad_slots[range.first + row] & 0x0fff) == stored - 1) return row_ids[row];
|
||||
return nullptr;
|
||||
};
|
||||
// the eight formations of the manager (table of 0x160 bytes per manager, the hall's half at
|
||||
// +0xb0; each formation 11 depths, then 11 lanes): 1-4 are given, 5-8 his own. Record
|
||||
// +0x218 (+1 in the hall) says which exist; option byte 0 names the one in use, 0 a free
|
||||
// placement.
|
||||
A formations;
|
||||
const size_t formation_table = size_t(manager) * 0x160 + (g_.indoor ? 0xb0 : 0);
|
||||
const size_t formation_mask = size_t(manager) * 0xb0c + 0x218 + size_t(g_.indoor);
|
||||
if (formation_table + 8 * 0x16 <= g_.formations.size() && formation_mask < g_.manager_records.size())
|
||||
for (int f = 0; f < 8; ++f) {
|
||||
A places;
|
||||
for (size_t i = 0; i < 11; ++i)
|
||||
places.push_back(O{{"depth", int(int8_t(g_.formations[formation_table + size_t(f) * 0x16 + i]))},
|
||||
{"lane", int(int8_t(g_.formations[formation_table + size_t(f) * 0x16 + 11 + i]))}});
|
||||
formations.push_back(O{{"formation", f + 1}, {"own", f >= 4},
|
||||
{"available", (g_.manager_records[formation_mask] & (1u << f)) != 0}, {"positions", std::move(places)}});
|
||||
}
|
||||
const int formation_in_use = g_.manager_options.size() > size_t(manager) * 5 ? int(g_.manager_options[size_t(manager) * 5]) : 0;
|
||||
return modern::ui_snapshot(g_, context, request_id,
|
||||
O{{"kind", "lineup"}, {"teamId", modern::ui_team_id(g_, team)}, {"formationId", nullptr}, {"order", std::move(order)},
|
||||
{"formations", std::move(formations)}, {"formation", formation_in_use >= 1 && formation_in_use <= 8 ? formation_in_use : 0},
|
||||
{"setPieces", O{{"freeKick", taker(0xafc)}, {"penalty", taker(0xafe)}, {"corner", taker(0xb08)}}},
|
||||
{"surface", g_.indoor ? "indoor" : "outdoor"}, {"durationMinutes", g_.indoor ? 40 : 90}, {"starterCount", 11},
|
||||
{"pairs", std::move(pairs)},
|
||||
@@ -11168,6 +11186,39 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
}
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"lineup"}, "Anweisung übernommen.");
|
||||
} else if (kind == "lineup.setFormation") {
|
||||
// payload {formation 1-8}: the formation is used and the assistant places the eleven on it
|
||||
// (apply_pitch_formation_source). {formation 5-8, save: true}: the places of the eleven as
|
||||
// they stand become this own formation, which is used from then on
|
||||
// (save_pitch_formation_source).
|
||||
const int team = g_.manager_teams[size_t(manager)];
|
||||
const cli::Json* formation = ui_field(*payload, "formation");
|
||||
const cli::Json* save = ui_field(*payload, "save");
|
||||
const bool saving = save && save->boolean() && *save->boolean();
|
||||
if (!formation || !formation->integer() || *formation->integer() < 1 || *formation->integer() > 8 || (save && !save->boolean()) ||
|
||||
(saving && *formation->integer() < 5))
|
||||
return refuse("invalid_payload", "formation 1-8; save: true nur für die eigenen Formationen 5-8.");
|
||||
const size_t rec = size_t(manager) * 0xb0c, board = size_t(manager) * 0x840;
|
||||
if (rec + 0x288 >= g_.manager_records.size() || board + 11 * 0x58 > g_.tactics.size()) return refuse("lineup_refused", "Formationen sind hier nicht verfügbar.");
|
||||
const uint8_t weights = g_.manager_records[rec + 0x288];
|
||||
bool ok = false;
|
||||
if (saving) {
|
||||
std::array<uint8_t, 22> places{};
|
||||
for (size_t row = 0; row < 11; ++row) {
|
||||
places[row] = g_.tactics[board + row * 0x58 + 0x41];
|
||||
places[11 + row] = g_.tactics[board + row * 0x58 + 0x42];
|
||||
}
|
||||
ok = save_pitch_formation_source(g_, manager, team, int(*formation->integer()) - 1, weights, places);
|
||||
} else {
|
||||
ok = apply_pitch_formation_source(g_, manager, team, int(*formation->integer()) - 1, weights);
|
||||
}
|
||||
if (!ok) {
|
||||
restore();
|
||||
return refuse("lineup_refused", saving ? "Gespeichert wird nur eine vollständige Elf auf dem Feld."
|
||||
: "Diese Formation gibt es nicht, oder die Elf lässt sich so nicht aufstellen.");
|
||||
}
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"lineup", "tactics", "squad"}, saving ? "Formation gespeichert." : "Formation übernommen.");
|
||||
} else if (kind == "lineup.setPiece") {
|
||||
// payload {piece: "freeKick" | "penalty" | "corner", playerId} names one taker;
|
||||
// {auto: true} hands all three back to the assistant (the original's AUTO)
|
||||
|
||||
Reference in new issue
Block a user