Start Modern managers with the assistant's attitude control; name live tactic values
A new Modern manager's assistant adapts the attitude to the score, as the computer clubs do, until the manager sets it himself; an idle human club no longer plays whole matches at the most defensive attitude (12-season simulation: 1.40 instead of 1.12 goals per match, league average 1.44). The live tactics board shows values in words, and refused live commands are written to stderr. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6970dfa20a
commit
f2dcf94d2b
5 files changed
+28
-2
No files matched your search
@@ -33,6 +33,7 @@ describe deliberate changes; they are not a list of every known compatibility li
|
||||
- [src/modern/content/world_expand.cpp](../src/modern/content/world_expand.cpp): Modern worlds have league sizes, clubs and players of their own; players whose nation has no single-byte nationality code carry a substitute foreign code.
|
||||
- [src/modern/game/career.cpp](../src/modern/game/career.cpp): in a Modern world a club's place in the strength band of its league follows the data set's ranking of the squads instead of the table place, and its players keep their relative values (balance.md).
|
||||
- [src/modern/game/career.cpp](../src/modern/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||
- [src/modern/app/modern_session.cpp](../src/modern/app/modern_session.cpp): in Modern a new manager's assistant adapts the attitude to the score (as the computer clubs do) until the manager sets it himself; Classic starts at the most defensive attitude for whole matches.
|
||||
- [src/modern/game/career.cpp](../src/modern/game/career.cpp): retains an existing Modern club's league slot when a human joins, preserving its played results.
|
||||
- [src/modern/game/career.hpp](../src/modern/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/modern/game/desk_actions.cpp](../src/modern/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
|
||||
@@ -894,6 +894,9 @@ bool ModernSession::begin_manager_join(const ui::DeskRequest& origin, const ui::
|
||||
if (mem.u32(::bmh::layout::CompetitionSelection) == 1)
|
||||
for (int slot = current.managers; slot < options.managers; ++slot)
|
||||
draft.state.manager_options.at(size_t(slot) * 5 + 4) = 1;
|
||||
// a manager who joins starts with the assistant's attitude control as well (see apply_options)
|
||||
for (int slot = current.managers; slot < options.managers && size_t(slot) * 5 + 2 < draft.state.manager_options.size(); ++slot)
|
||||
draft.state.manager_options.at(size_t(slot) * 5 + 2) = 1;
|
||||
modern::career_managers_begin(draft.state, true);
|
||||
manager_join_ = std::move(draft);
|
||||
return true;
|
||||
@@ -1003,6 +1006,12 @@ void ModernSession::apply_options(const ui::SetupOptions& o) {
|
||||
if (o.league && !o.world)
|
||||
for (int m = 0; m < o.managers && size_t(m) * 5 + 4 < g_.manager_options.size(); ++m)
|
||||
g_.manager_options.at(size_t(m) * 5 + 4) = 1;
|
||||
// Modern deviates from Classic: a new manager's assistant adapts the attitude to the score, as
|
||||
// the computer clubs do. Classic starts every human club at the most defensive attitude for
|
||||
// whole matches, which costs an unaware manager most of his goals. Setting the attitude by
|
||||
// hand takes the control back.
|
||||
for (int m = 0; m < o.managers && size_t(m) * 5 + 2 < g_.manager_options.size(); ++m)
|
||||
g_.manager_options.at(size_t(m) * 5 + 2) = 1;
|
||||
modern::career_managers_begin(g_);
|
||||
options_applied_ = true;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ void App::engine_live_begin(const Json &state, const std::string &revision) {
|
||||
{"value", control.at("value")}});
|
||||
} catch (const std::exception &) { engine_live_tactics_ = Json::array(); }
|
||||
if (engine_live_tactics_.size() != 8) engine_live_tactics_ = Json::array();
|
||||
try { engine_live_assistant_ = engine_data_.at("tactics").at("data").value("assistantAttitude", 0) != 0; }
|
||||
catch (const std::exception &) { engine_live_assistant_ = false; }
|
||||
const auto fixture = engine_live_progress(Json(), state, engine_data_, engine_live_roster_);
|
||||
if (!fixture.value("ok", false) || !live_.open(fixture, "")) {
|
||||
// nothing the ticker can show: the kickoff is simply played to its end
|
||||
@@ -94,6 +96,7 @@ void App::engine_live_poll() {
|
||||
const Json response = result.value("response", Json::object()), state = result.value("live", Json::object());
|
||||
const bool accepted = response.value("messageType", "") == "command_result";
|
||||
if (accepted) engine_live_revision_ = response.value("newRevision", engine_live_revision_);
|
||||
else std::fprintf(stderr, "live command %s refused: %s%c", kind.c_str(), response.dump().c_str(), '\n');
|
||||
if (kind == "live.substitute") {
|
||||
if (accepted && engine_live_swap_.is_array() && engine_live_swap_.size() == 2) {
|
||||
// the engine swapped the two rows of the line-up; the team tab follows
|
||||
@@ -117,6 +120,7 @@ void App::engine_live_poll() {
|
||||
}
|
||||
if (kind == "live.tactics") {
|
||||
if (accepted && engine_live_tactics_sent_.is_array() && engine_live_tactics_sent_.size() == engine_live_tactics_.size()) {
|
||||
if (engine_live_tactics_[0].at("value") != engine_live_tactics_sent_[0]) engine_live_assistant_ = false;
|
||||
for (size_t i = 0; i < engine_live_tactics_.size(); ++i) engine_live_tactics_[i]["value"] = engine_live_tactics_sent_[i];
|
||||
live_feedback_ = "Taktik geändert.";
|
||||
} else if (!accepted) {
|
||||
|
||||
@@ -6,7 +6,18 @@ std::string live_text(const std::string &value, const std::string &css = {}) {
|
||||
std::string live_score_text(const Json &score) {
|
||||
return std::to_string(score[0].get<int>()) + " : " + std::to_string(score[1].get<int>());
|
||||
}
|
||||
// A value of the engine's tactics board in words: the attitude (item 0, lowest = most
|
||||
// defensive), the commitment (item 7) and the numbered variants of the play patterns.
|
||||
std::string live_tactic_value(size_t index, int value, int maximum) {
|
||||
if (index == 0 && maximum == 3) {
|
||||
static const std::array<const char *, 4> attitude{"Sehr defensiv", "Defensiv", "Offensiv", "Sehr offensiv"};
|
||||
if (value >= 0 && value <= 3) return attitude[size_t(value)];
|
||||
}
|
||||
if (index == 7) return std::to_string(value) + " von " + std::to_string(maximum);
|
||||
return "Variante " + std::to_string(value + 1) + " von " + std::to_string(maximum + 1);
|
||||
}
|
||||
const Json &live_match_by_id(const Json &rows, const Json &id) {
|
||||
|
||||
for (const auto &row : rows) if (row.at("id") == id) return row;
|
||||
throw editor::Error("live_match_unavailable");
|
||||
}
|
||||
@@ -103,7 +114,7 @@ std::string App::live_detail(const Json &owner, const Json &frame) {
|
||||
std::string out = "<div class=\"live-context\"><h3>" + live_text("Taktik in diesem Spiel") + "</h3>";
|
||||
for (size_t i = 0; i < engine_live_tactics_.size(); ++i)
|
||||
out += "<div class=\"live-tactic-row\">" + live_text(engine_live_tactics_[i].at("label").get<std::string>()) +
|
||||
live_text("Wert " + std::to_string(engine_live_tactics_[i].at("value").get<int>())) + "</div>";
|
||||
live_text(i == 0 && engine_live_assistant_ ? std::string("Assistent passt an") : live_tactic_value(i, engine_live_tactics_[i].at("value").get<int>(), engine_live_tactics_[i].at("max").get<int>())) + "</div>";
|
||||
return out + btn("live-intervene-tactics", "Taktik ändern", "", "id=\"live-tactics-edit\"") + "</div>";
|
||||
}
|
||||
if (live_tab_ == "tactics" && recorded)
|
||||
@@ -145,7 +156,7 @@ std::string App::live_dialog_markup(const Json &owner) {
|
||||
const bool engine_board = live_.running() && engine_live_tactics_.size() == 8;
|
||||
const auto &values = engine_board ? live_dialog_draft_.at("values") : live_dialog_draft_.at("tactics").at("values");
|
||||
for (size_t i = 0; i < names.size(); ++i)
|
||||
body += "<div class=\"live-tactic-row\">" + live_text(engine_board ? engine_live_tactics_[i].at("label").get<std::string>() : std::string(names[i])) + btn("live-tactic-cycle", "Wert " + std::to_string(values[i].get<int>()), "", "id=\"live-tactic-" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\"") + "</div>";
|
||||
body += "<div class=\"live-tactic-row\">" + live_text(engine_board ? engine_live_tactics_[i].at("label").get<std::string>() : std::string(names[i])) + btn("live-tactic-cycle", engine_board ? live_tactic_value(i, values[i].get<int>(), engine_live_tactics_[i].at("max").get<int>()) : "Wert " + std::to_string(values[i].get<int>()), "", "id=\"live-tactic-" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\"") + "</div>";
|
||||
}
|
||||
body += "<div class=\"live-dialog-actions\">" + btn("live-dialog-cancel", "Abbrechen", "", "id=\"live-dialog-cancel\"") +
|
||||
btn("live-dialog-apply", live_.running() ? (live_dialog_ == "lineup" ? "Wechsel ausführen" : "Taktik übernehmen") : "Demovorschau anzeigen", "", "id=\"live-dialog-apply\" " + std::string(live_dialog_ == "lineup" && (live_out_.empty() || live_in_.empty()) ? "disabled" : "")) + "</div>";
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
Json engine_live_roster_ = Json::array(), engine_live_swap_, engine_live_queue_;
|
||||
// The tactics board during a live kickoff: the engine's controls with the values in force.
|
||||
Json engine_live_tactics_ = Json::array(), engine_live_tactics_sent_;
|
||||
bool engine_live_assistant_ = false; // the assistant adapts the attitude until it is set by hand
|
||||
void engine_live_begin(const Json &state, const std::string &revision);
|
||||
void engine_live_send(const std::string &kind, const Json &payload);
|
||||
void engine_live_poll();
|
||||
|
||||
Reference in new issue
Block a user