Compare commits

...
10 Commits
Author SHA1 Message Date
MichaelandClaude Fable 5.2 6a2d0d01f8 The venue of the next match is plain words without a marker
Dreierpack macOS arm64 / package (push) Canceled after 0s
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 20:29:34 +01:00
MichaelandClaude Fable 5.2 18b511f443 Crests on the home page stand free, crest photographs are white
The next-match widgets drop the cream disc behind the crests and draw them
larger; the photograph of a crest is plain white paper.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 20:11:43 +01:00
MichaelandClaude Fable 5.2 ff8068ea11 Marketing pays less; the forecast and the highscore know the new rules
Seen in a career on level 4, international marketing brought more than its
budget after two months: a point of reach is now worth 900 euros in the
first league instead of 1600 (lower leagues accordingly). The monthly
forecast of the advertising page includes the stadium sponsor, marketing,
rents and the further stages, and the highscore counts the four further
properties.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 19:36:23 +01:00
MichaelandClaude Fable 5.2 af677a735d Modern's own rules keep the books and write to the mailbox
Naming rights, marketing, the further properties and the stages now fill
items of the balance sheet (other income, public relations, rents,
periphery, other expenses). The manager gets a note in his mailbox when he
sells the stadium's name, when that contract ends, when a stage is
finished, after the annual general meeting and after a change of club.

The live demo QA driver is marked as not yet ported to the notebook.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 19:23:34 +01:00
MichaelandClaude Fable 5.2 dfe8a43440 The stadium model shows the stages of lounge and periphery
Clubhouse and shopping centre grow a storey per stage, the car park grows
along the road, the restaurant gets a second storey and the lounge a wider,
second row of glass. A crane stands while a stage is built. The card of a
building names its stage, what it brings and what the next one costs, and
orders it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 19:09:27 +01:00
MichaelandClaude Fable 5.2 8be27f8e57 The lounge and four buildings of the periphery can be extended in stages
Once it stands, the V.I.P. lounge goes up to four stages, the shopping
centre and the clubhouse to three, the car park to four, the restaurant to
two. A stage costs money and months of building and then brings a monthly
income by league. The stadium page lists them under "Ausbaustufen".

Engine: expansions.hpp, stadium read expansions, command stadium.expand;
saved in state/modern.json.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 18:47:23 +01:00
MichaelandClaude Fable 5.2 57b8b0f371 Four further properties at the bank; the tactics sketch sits a little higher
Town house, penthouse, estate house and old terraced house join the six
properties of the original: bought and sold at the day's price, moving by
a few percent every month and paying a monthly rent. The property board
shows all ten.

Engine: estates.hpp, bank read funds fund:6-9, bank.commit trades them;
saved in state/modern.json.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 17:18:31 +01:00
MichaelandClaude Fable 5.2 72e06aabdb Players wear shirt numbers the manager can change
Every player keeps a number from 1 to 99, unique within his squad. The
line-up shows it and changes it by a click; the tactics sketch and the
match sheet wear it too.

Engine: shirt_numbers.hpp, squad read player.shirtNumber, command
lineup.setNumber; saved in state/modern.json.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 16:58:34 +01:00
MichaelandClaude Fable 5.2 7b3f52d809 International marketing: a monthly budget builds up reach abroad
The reach grows over a year or two towards what the budget holds, falls
faster when the budget is cut, and brings income every month by league and
prestige. The investments page sets the budget and shows reach and income.

Engine: marketing.hpp, read advertising.internationalMarketing, command
marketing.commit; saved in state/modern.json. Also fixes the monthly amount
on the naming rights tile, which was shown a hundredth too small.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 16:33:10 +01:00
MichaelandClaude Fable 5.2 97acf0d74d Document the stadium name of the live read
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 15:09:22 +01:00
52 changed files with 1519 additions and 51 deletions

No files matched your search

+12
View File
@@ -1236,6 +1236,18 @@ add_test(NAME modern_assembly_tests COMMAND modern_assembly_tests)
add_executable(modern_naming_tests tests/modern_naming_tests.cpp)
target_link_libraries(modern_naming_tests PRIVATE bmh_season_modern)
add_test(NAME modern_naming_tests COMMAND modern_naming_tests)
add_executable(modern_marketing_tests tests/modern_marketing_tests.cpp)
target_link_libraries(modern_marketing_tests PRIVATE bmh_season_modern)
add_test(NAME modern_marketing_tests COMMAND modern_marketing_tests)
add_executable(modern_shirt_number_tests tests/modern_shirt_number_tests.cpp)
target_link_libraries(modern_shirt_number_tests PRIVATE bmh_season_modern)
add_test(NAME modern_shirt_number_tests COMMAND modern_shirt_number_tests)
add_executable(modern_estates_tests tests/modern_estates_tests.cpp)
target_link_libraries(modern_estates_tests PRIVATE bmh_season_modern)
add_test(NAME modern_estates_tests COMMAND modern_estates_tests)
add_executable(modern_expansion_tests tests/modern_expansion_tests.cpp)
target_link_libraries(modern_expansion_tests PRIVATE bmh_season_modern)
add_test(NAME modern_expansion_tests COMMAND modern_expansion_tests)
add_executable(modern_almanac_tests tests/modern_almanac_tests.cpp)
target_link_libraries(modern_almanac_tests PRIVATE bmh_modern_content)
add_test(NAME modern_almanac_tests COMMAND modern_almanac_tests)
+5 -4
View File
@@ -176,7 +176,7 @@ body.midnight .hw-item,body.matchday .hw-item {background-color:#ffffff14;} body
.hw.hero .hw-kicker {color:#f6a06b;}
.hw.hero .hw-foot,.hw.hero .hw-big span {color:#d9c9b4;}
.hw.hero .hw-empty {color:#d9c9b4;}
.hw-disc {display:flex;flex-shrink:0;align-items:center;justify-content:center;border-radius:200dp;background-color:#f9f4ed;border:6dp #f6a06b66;}
.hw-disc {display:flex;flex-shrink:0;align-items:center;justify-content:center;}
.hw-versus {display:block;width:124dp;height:124dp;line-height:118dp;margin:0 auto 18dp auto;border-radius:62dp;background-color:#c67139;color:#f9f4ed;font-family:Display;font-size:52dp;text-align:center;}
.hw-match-mid .hw-tag {display:block;align-self:center;margin:0;}
.hw.hero .hw-match-side strong {color:#f9f4ed;font-size:40dp;line-height:46dp;}
@@ -230,11 +230,11 @@ body.midnight .hw-item,body.matchday .hw-item {background-color:#ffffff14;} body
.hw-duel.won strong {color:#56633f;} .hw-duel.lost strong {color:#8c491a;}
.hw-duel small {display:block;font-size:26dp;color:#474238;}
/* photographs */
.hw.photo,.hw.photo.link:hover {padding:24dp 18dp 8dp 18dp;align-items:center;border:2dp #e2d8c4;border-bottom:5dp #d3c7b0;border-radius:10dp;background-color:#fdfaf3;}
.hw.photo,.hw.photo.link:hover {padding:24dp 18dp 8dp 18dp;align-items:center;border:2dp #e2d8c4;border-bottom:5dp #d3c7b0;border-radius:10dp;background-color:#ffffff;}
.hw.photo.turn-a {transform:rotate(-2.2deg);} .hw.photo.turn-b {transform:rotate(1.6deg);} .hw.photo.turn-c {transform:rotate(-1.2deg);}
.hw-tape {display:block;position:absolute;left:50%;top:-6dp;width:140dp;height:36dp;margin-left:-70dp;background-color:#e6d49ab8;transform:rotate(-3deg);}
.hw-photo-frame {display:flex;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background-color:#eee7db;}
.hw-photo-frame.crest {background-color:#f4efe4;}
.hw-photo-frame.crest {background-color:transparent;}
.hw-photo-caption {display:block;width:100%;height:44dp;line-height:44dp;margin-top:auto;text-align:center;font-family:Chalk;font-weight:bold;font-size:30dp;color:#474238;white-space:nowrap;overflow:hidden;}
/* the grid while a card moves or a menu is open */
.hw-cells {display:none;}
@@ -276,7 +276,6 @@ body.midnight .hw-item,body.matchday .hw-item {background-color:#ffffff14;} body
.hw.hero .hw-kicker {color:#8c491a;}
.hw.hero .hw-foot,.hw.hero .hw-big span,.hw.hero .hw-empty {color:#474238;}
.hw.hero .hw-match-side strong {color:#201e1d;font-size:46dp;line-height:52dp;}
.hw-disc {border:6dp #f9f4ed;background-color:#f9f4ed;}
.hw-dash {padding:0;border-radius:0dp;background-color:transparent;}
.hw-dash .hw-lamp {height:86dp;}
.hw-dash.row .hw-lamp {height:76dp;}
@@ -322,3 +321,5 @@ body.midnight .hw-item,body.matchday .hw-item {background-color:#ffffff14;} body
/* the ribbon is a button: back to the main menu */
.nb-ribbon,.nb-ribbon:hover,.nb-ribbon:focus {display:block;padding:0;margin:0;border:0dp;border-radius:0dp;background-color:transparent;decorator:none;}
.nb-ribbon:hover {top:2014dp;}
.hw-venue {display:block;margin-top:8dp;font-size:30dp;font-weight:bold;line-height:40dp;white-space:nowrap;color:#8a3f1c;}
.hw-match-mid .hw-venue {text-align:center;}
+2
View File
@@ -1147,3 +1147,5 @@ body .popup-box p.as-verdict {margin:14dp 0 0;text-align:center;font-size:31dp;}
.cs-sum.cs-age {width:230dp;}
.cs-cash .cs-label {overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
.pg-dlg.cs-sheet {height:1680dp;}
.sd-steps {display:block;flex:none;margin-top:9dp;padding-top:13dp;border-top:2dp var(--p-div);}
.sd-steps>* {margin-bottom:9dp;}
+5
View File
@@ -52,6 +52,10 @@ describe deliberate changes; they are not a list of every known compatibility li
- [src/modern/content/statistics.cpp](../src/modern/content/statistics.cpp): Modern chooses its own eleven of the day per league from the recorded facts of the matchday (goals, assists, cards, result, clean sheets) instead of the original's Sportschau rating, and words the ticker from several variants per event.
- [src/modern/game/matchday_setup.cpp](../src/modern/game/matchday_setup.cpp): in Modern worlds a referee may take a second match on a day with more matches than referees.
- [src/modern/game/month.cpp](../src/modern/game/month.cpp): in Modern every manager receives the monthly dividend of his own shares; the price product is kept in 64 bits until the division.
- [src/modern/game/estates.cpp](../src/modern/game/estates.cpp): Modern adds four properties to the bank whose prices move monthly and which pay a monthly rent.
- [src/modern/game/expansions.cpp](../src/modern/game/expansions.cpp): in Modern the V.I.P. lounge, the shopping centre, the clubhouse, the car park and the restaurant can be extended in further stages, which cost money and time and bring a monthly income.
- [src/modern/game/highscore.cpp](../src/modern/game/highscore.cpp): Modern's four further properties count among the assets at today's prices.
- [src/modern/game/marketing.cpp](../src/modern/game/marketing.cpp): in Modern a monthly budget for international marketing builds up reach abroad, which brings monthly income by league and prestige.
- [src/modern/game/naming_rights.cpp](../src/modern/game/naming_rights.cpp): in Modern a manager names his stadium and can sell the name to a sponsor for one to five years; the sponsor pays monthly and the name is fixed until the contract ends.
- [src/modern/game/season.cpp](../src/modern/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
- [src/modern/game/season.cpp](../src/modern/game/season.cpp): in Modern the age stops at 47, the most its five bits hold; real ages of a data set (a goalkeeper of 40) would otherwise run into the bits above.
@@ -64,6 +68,7 @@ describe deliberate changes; they are not a list of every known compatibility li
- [src/modern/ui/demo_calendar.cpp](../src/modern/ui/demo_calendar.cpp): the native season follows its saved start year (including leap days), rather than the HTML's fixed 2027/28.
- [src/modern/ui/engine_achievements.cpp](../src/modern/ui/engine_achievements.cpp): shows recorded manager history between seasons without inventing future results.
- [src/modern/ui/engine_balance.cpp](../src/modern/ui/engine_balance.cpp): viewing a balance is read-only and publishing a changed plan requires explicit confirmation.
- [src/modern/game/shirt_numbers.cpp](../src/modern/game/shirt_numbers.cpp): in Modern every player keeps a shirt number from 1 to 99, unique within his squad, which the manager of a club can change.
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
+4
View File
@@ -13,6 +13,10 @@ Grundlage ist der [Engine-Split](../ENGINE_SPLIT.md); die Oberfläche ist in
| [Trainingslager](trainingslager.md) | Katalog, Preis, Wirkung und die neue 6-Sterne-Stufe |
| [Jahreshauptversammlung](hauptversammlung.md) | Abstimmung am Saisonende, interessierte Vereine, Vereinswechsel |
| [Namensrecht](namensrecht.md) | Stadionname, Angebote der Sponsoren, monatliche Zahlung |
| [Internationale Vermarktung](vermarktung.md) | Monatsbudget, Reichweite im Ausland, Einnahmen |
| [Rückennummern](rueckennummern.md) | Nummern 1–99 je Spieler, eindeutig im Kader, änderbar |
| [Immobilien](immobilien.md) | vier weitere Immobilien der Bank mit Preisgang und Miete |
| [Ausbaustufen](ausbaustufen.md) | weitere Stufen von V.I.P.-Lounge und vier Peripheriegebäuden |
| [Datenformat](datenformat.md) | **Formatänderungen für Engine und Editor** (F1–F8) |
| [Agentenregeln](AGENTS.md) | Arbeitsregeln für diesen Bereich |
+61
View File
@@ -0,0 +1,61 @@
# Ausbaustufen von Lounge und Peripherie · Modern-Engine
Stand: 17. November 2026. Eine Modern-Regel über dem Original, das die V.I.P.-Lounge und diese
Gebäude nur als gebaut oder nicht gebaut kennt. Die Regeln des Originals für Bau, Zustand und
Einnahmen bleiben unverändert.
## Regel
| Gebäude | Stufen | Preis der 2. Stufe | Einnahme je weiterer Stufe und Monat (1. Liga) |
|---|---|---|---|
| V.I.P.-Lounge | 4 | 1 200 000 € | 45 000 € |
| Einkaufszentrum | 3 | 1 300 000 € | 40 000 € |
| Clubhaus | 3 | 600 000 € | 18 000 € |
| Parkplatz | 4 | 400 000 € | 12 000 € |
| Restaurant | 2 | 500 000 € | 16 000 € |
- Stufe 1 ist das Gebäude, wie das Original es baut. Ausbauen lässt es sich nur, wenn es
steht und nicht selbst im Bau ist (Lounge: Ausstattung 3 auf Stufe 2; Peripherie: Objekte
2 bis 5 des Stadions).
- Die dritte Stufe kostet das Doppelte, die vierte das Dreifache der zweiten. Die Bauzeit
beträgt 3, 4 und 5 Monate. Es wird je Gebäude nur eine Stufe zugleich gebaut. Bezahlt wird
beim Auftrag; reicht das Konto samt Kreditrahmen nicht, wird er abgelehnt.
- Jede fertige weitere Stufe bringt mit dem Monatswechsel Einnahmen: den Satz der ersten
Liga, in der zweiten 65 %, in der dritten 40 %, darunter 25 %. Steht das Gebäude nicht
mehr, ruhen die Einnahmen; die Stufen bleiben.
- Keine Zufallszahl. Vierter Schritt von `month_change` (`modern::expansions_month`).
- Bei einem [Vereinswechsel](hauptversammlung.md) bleiben die Stufen beim alten Stadion.
## Speichern
`state/modern.json` erhält das optionale Feld `expansions`: je Managerplatz `stage` (fünf
fertige weitere Stufen) und `months` (fünf Restbauzeiten).
## Anbindung
Read `stadium`: `expansions[]` mit `id` (`expansion:lounge`, `mall`, `clubhouse`, `parking`,
`restaurant`), `objectId`, `name`, `stage`, `maxStage`, `monthsLeft`, `monthlyIncome`,
`nextPrice`, `nextMonths`, `available`. Befehl `stadium.expand {expansionId, confirmed: true}`
(Fehler `confirmation_required`, `unknown_expansion`, `expansion_refused`).
## Darstellung
Das Kartonmodell des Stadions zeichnet die Stufe: Clubhaus und Einkaufszentrum je Stufe ein
Stockwerk höher, der Parkplatz in vier Schritten länger, das Restaurant in Stufe 2 mit zweitem
Stockwerk, die Lounge breiter und mit zweiter verglaster Reihe. Während des Baus steht ein
Kran; die Ansicht „Zukunft“ zeigt die Stufe als fertig. Die Karte eines Gebäudes nennt Stufe,
Ertrag, Preis und Bauzeit der nächsten Stufe und bietet den Ausbau an.
## Prüfung
`modern_expansion_tests` (ohne Spieldaten): Stufe 1 nur für Gebautes, Preis und Bauzeit,
Ablehnung ohne Gebäude, während des Baus und ohne Geld, Bau über die Monate, Einnahme ab
Fertigstellung, letzte Stufe, Einnahme nach Liga, Lounge im Bau zählt nicht als gebaut.
## Offen
- Die Wirkung der Lounge auf Zuschauer und Preise bleibt die des Originals; die weiteren
Stufen bringen nur die monatliche Einnahme.
- In der Bilanz stehen die Einnahmen unter „Stadionperipherie“, die Baukosten wie beim
übrigen Bauen unter „Sonstiges“ der Ausgaben.
- Sätze nicht in einem Langlauf gemessen.
-1
View File
@@ -135,7 +135,6 @@ Feld `assembly` von `session.advance`.
## Offen
- Schalter für Rauswürfe in den Optionen.
- Nachrichten zum Wechsel und zur Abstimmung im Posteingang.
- Aufgeben bei mehreren Menschen ist weiter nicht unterstützt; der Wechsel braucht es nicht,
weil der Manager seinen Platz behält.
- Wechselt ein Manager an einem Spieltag, spielt der alte Verein die schon angesetzte Partie
+48
View File
@@ -0,0 +1,48 @@
# Vier weitere Immobilien · Modern-Engine
Stand: 17. November 2026. Eine Modern-Regel neben den sechs Immobilien des Originals (den
Fonds seiner Bank), die unverändert bleiben.
## Regel
| Nr. | Immobilie | Startpreis |
|---|---|---|
| 6 | Stadthaus | 450 000 € |
| 7 | Penthouse | 1 200 000 € |
| 8 | Siedlungshaus | 280 000 € |
| 9 | Altbau-Reihenhaus | 650 000 € |
- Gekauft und verkauft wird zum Tagespreis, ohne Gebühr. Höchstens 20 Stück je Immobilie.
Der Kauf scheitert, wenn Konto und Kreditrahmen nicht reichen.
- **Preis:** Mit jedem Monatswechsel ändert sich jeder Preis um −2 bis +3 % (auf ganze
Tausender), nie unter die Hälfte und nie über das Dreifache des Startpreises. Der Zufall
dafür kommt aus einem eigenen Generator (Startwert aus Karriere, Monat und Immobilie) und
verbraucht keine Zahl des Spiels.
- **Miete:** Jedes Stück bringt im Monat 4 ‰ seines Preises, rund 4,8 % im Jahr.
- In die Vermögenswertung der [Jahreshauptversammlung](hauptversammlung.md) gehen sie zum
Tagespreis ein. Bei einem Vereinswechsel bleiben sie zurück.
- Dritter Schritt von `month_change` (`modern::estates_month`).
## Speichern
`state/modern.json`: `estates` (je Managerplatz vier Stückzahlen) und `estate_prices` (vier
Preise, 0 = Startpreis).
## Anbindung
Read `bank`: `funds` hat vier weitere Einträge `fund:6` bis `fund:9` mit `name`, `price`,
`owned`, `paid`, `maxToBuy`, dazu `monthlyRent` und `limit`. `bank.commit` mit `buy`/`sell`
und `assetId` `fund:6`–`fund:9` (Fehler `purchase_refused`, `sale_refused`, `unknown_asset`).
## Prüfung
`modern_estates_tests` (ohne Spieldaten): Startpreise, Miete, Kauf, Grenzen des Kaufs und
Verkaufs, Preisbewegung eines Monats, Mietzahlung, Verkauf zum Tagespreis, Höchstzahl,
Preisgrenzen über fünfzig Jahre.
## Offen
- `accounts.investments` des Reads `bank` nennt weiter nur die Anlagen des Originals.
- Die Miete steht in der Bilanz unter „Mieten, Zinsen+Tilgung“; Kauf und Verkauf sind wie
bei den übrigen Anlagen keine Bilanzposten.
- Die Sätze sind ein erster Ansatz und nicht in einem Langlauf gemessen.
+2 -3
View File
@@ -59,9 +59,8 @@ und `stadium.namingRights`, Feld `stadiumName` des Live-Reads.
## Offen
- Die Zahlung wird wie eine einfache Buchung geführt und erscheint in der Bilanz unter keinem
eigenen Posten.
- Die Zahlung steht in der Bilanz unter „Sonstiges“ der Einnahmen; einen eigenen Posten gibt
es nicht.
- Auf der leichtesten Stufe bucht das Spiel grundsätzlich kein Geld; dort ändert der Verkauf
nur den Namen.
- Keine Nachricht im Posteingang bei Verkauf und Vertragsende.
- Die Saisonwirkung auf die Wirtschaft ist nicht in einem Langlauf gemessen.
+40
View File
@@ -0,0 +1,40 @@
# Rückennummern · Modern-Engine
Stand: 17. November 2026. Eine Modern-Regel; Classic zählt eine Mannschaft nach dem Platz auf
dem Brett von 1 bis 11.
## Regel
- Jeder Spieler behält eine Nummer von 1 bis 99 (`ModernState::shirt_numbers`, 0 = noch keine).
- In einem Kader wird jede Nummer einmal getragen (`modern::squad_shirt_numbers`): Wer eine
Nummer hat, behält sie, bei zwei Spielern mit derselben der in der Kaderreihe vordere. Alle
anderen erhalten die niedrigste freie Nummer.
- Nach jedem Anstoß werden die getragenen Nummern der Menschenvereine festgeschrieben
(`modern::fix_shirt_numbers`). Davor folgen Nummern ohne Festlegung der Kaderreihe.
- Der Manager kann einem Spieler seines Vereins eine Nummer geben
(`modern::set_shirt_number`). Trägt sie schon ein anderer, tauschen die beiden.
- Ein Neuzugang, dessen Nummer vergeben ist, erhält die niedrigste freie; wird seine Nummer
frei, trägt er sie wieder.
- Keine Zufallszahl. Auf das Spielgeschehen haben die Nummern keinen Einfluss.
## Speichern
`state/modern.json` erhält das optionale Feld `shirt_numbers`: Paare `[Spieler, Nummer]` nur
für Spieler mit Nummer.
## Anbindung
Read `squad`: `player.shirtNumber` (bisher immer `null`). Befehl
`lineup.setNumber {playerId, number}` (Fehler `no_club`, `unknown_player`, `invalid_number`).
## Prüfung
`modern_shirt_number_tests` (ohne Spieldaten): 1 bis 20 in Kaderreihe, freie und getragene
Nummer, Tausch, Eindeutigkeit, Grenzen, Nummern bleiben beim Umstellen, Neuzugang mit
vergebener Nummer.
## Offen
- Computervereine zählen weiter nach der Kaderreihe; ihre Nummern werden nicht festgeschrieben.
- Der Almanach zeichnet keine Rückennummern auf.
- Die Nationalmannschaft hat keine eigenen Nummern.
+7 -4
View File
@@ -32,8 +32,8 @@ Revision kommt vom Aufrufer (Konsole bzw. AppController), der Read ändert nicht
| `tactics` | die acht Einstellungen (`tactic:0` Grundausrichtung bis `tactic:7` Einsatz) mit Wert und Maximum aus der EXE; die Bedeutung der Diagramm-Einstellungen 1–3, 5, 6 ist nicht belegt, daher neutrale Namen |
| `training` | Bälle je Spielertyp und Trainingsbereich (1–3) mit den Grenzen, je Spieler Intensität und Schwerpunkt, ob das Training eingerichtet ist, Automatik-Bits |
| `contracts` | je Spieler Restlaufzeit, Monatsgehalt, Versicherung, Prämien; das offene Angebot (`quote`: ID, Spieler, Monatsforderung für 1–4 Jahre, Höchstgehalt 200.000 €) |
| `advertising` | 14 Banden (`ad:board/<n>`), Trikot (`ad:shirt`), TV-Rechte (`ad:tv`) je mit Vertrag (Sponsor, Monatsbetrag, Restmonate, Verlängerung, Option) und den offenen Angeboten (`offer:ad-<Platz>-<Nr.>`, Sponsor, Betrag, Banden, Monate, `allowed`); die drei Budgets (Merchandising, Presse, Fanarbeit) mit Stand, Höchstbetrag, Lieferwochen; die Finanzvorschau des Originals |
| `stadium` | Umfeld (14 Objekte mit Namen und Bautagen; Verkehrsanbindung mit `stage` und `maxStage`: Classic 3, Modern-Welt 4; sonst `built`), die acht Anlagen (Stufe, Höchststufe, Bauwochen, ob ausbaubar), die acht Tribünenblöcke (Plätze, Höchstplätze, Sitzplätze, Dach, Bauwochen, Plätze nach dem Bau), Eintrittspreis (8–25 €); das offene Angebot des Stadion-Dialogs (`quote`: Umfeld mit Preis, oder Anlage mit Zielstufe, Preis, Bauwochen und dem Trinkgeld-Bereich 6–14 %). Dazu der Name: `name` (wie das Stadion heißt), `worldName` (Name des Datensatzes), `nameEditable`, `namingRights` (`null` oder `{sponsor, monthly, monthsLeft}`) und `namingOffers[]` (`id`, `sponsor`, `name`, `monthly`, `months`, `total`) |
| `advertising` | 14 Banden (`ad:board/<n>`), Trikot (`ad:shirt`), TV-Rechte (`ad:tv`) je mit Vertrag (Sponsor, Monatsbetrag, Restmonate, Verlängerung, Option) und den offenen Angeboten (`offer:ad-<Platz>-<Nr.>`, Sponsor, Betrag, Banden, Monate, `allowed`); die drei Budgets (Merchandising, Presse, Fanarbeit) mit Stand, Höchstbetrag, Lieferwochen; die Finanzvorschau des Originals. Dazu `internationalMarketing` (`budget`, `maxBudget`, `reach`, `targetReach`, `maxReach` in Promille, `income`, `incomeAtTarget`) |
| `stadium` | Umfeld (14 Objekte mit Namen und Bautagen; Verkehrsanbindung mit `stage` und `maxStage`: Classic 3, Modern-Welt 4; sonst `built`), die acht Anlagen (Stufe, Höchststufe, Bauwochen, ob ausbaubar), die acht Tribünenblöcke (Plätze, Höchstplätze, Sitzplätze, Dach, Bauwochen, Plätze nach dem Bau), Eintrittspreis (8–25 €); das offene Angebot des Stadion-Dialogs (`quote`: Umfeld mit Preis, oder Anlage mit Zielstufe, Preis, Bauwochen und dem Trinkgeld-Bereich 6–14 %). Dazu der Name: `name` (wie das Stadion heißt), `worldName` (Name des Datensatzes), `nameEditable`, `namingRights` (`null` oder `{sponsor, monthly, monthsLeft}`) und `namingOffers[]` (`id`, `sponsor`, `name`, `monthly`, `months`, `total`) sowie `expansions[]` (`id`, `objectId`, `name`, `stage`, `maxStage`, `monthsLeft`, `monthlyIncome`, `nextPrice`, `nextMonths`, `available`) |
| `balance` | `view` current/real/future, optional `edits [{id: balance:<0–17>, amount: Money}]`; liefert ursprüngliche Posten/Labels/Grenzen, sechs Zusatzwerte, Abschreibung, Nettoergebnis und Bilanzwarnung. Prognose auf eigener Kopie, kein RNG/Live-Publish. |
| `achievements` | Reine Manager-Saisonhistorie am Vereinsschreibtisch: `managerId`, aktuelles `teamId`, `currentSeasonYear`, `records` mit Jahr/Abschlussstatus, Liga-ID/Platz/Teilnehmerzahl und ursprünglichen Pokal-/Europapokalständen samt Text. Keine historische Vereinszuordnung erfinden. `available` bedeutet vorhandene Aufzeichnungen; `originalMenuAvailable` nennt zusätzlich die bisherige Ligaspiel-Sperre. Abgeschlossene Daten bleiben in der Modern UI auch zwischen Saisons lesbar; ungespielte neue Saisons werden nicht ergänzt. Kein RNG oder Schreibvorgang. |
| `transfer` | die Transferliste (`listing:<n>`: Spieler, Alter, Position, Stärke, Verkäufer, Ablöseforderung, Gehaltsreferenz pro Monat, Gehaltsforderung in %, Zahl der Angebote, eigene Listung, eigenes Gebot), der eigene Kader (gelistet oder nicht), Kontostand, Kreditrahmen; `details` je Spieler mit vollständigem Namen, Nationalität, Foto, Kondition/Technik/Form und sieben Fähigkeiten; `activeStrengths`/`teamStrengths` enthalten vier Positionen und Gesamtschnitt. `ownBid.monthlySalary` ist das gespeicherte Monatsgehalt; `annualSalary` bleibt als früher irreführend benannter Alias erhalten. `salaryReferencePeriod: month`. `loanAvailable` sperrt vereinslose Anbieter; `offerTerms` liefert Kauf-/Leihgebühr, jeweilige maximale Gebühr und maximales Monatsgehalt aus den Original-Editorgrenzen. `ownBid.loan` bezeichnet die gespeicherte Leihart. `ownBid.bonuses` sind sieben gespeicherte Prämienstufen. Die Projektion und Gebotsprüfung verwenden den weltabhängigen Modern-Pool, nicht Classic `0xb70` (#24). |
@@ -44,7 +44,7 @@ Revision kommt vom Aufrufer (Konsole bzw. AppController), der Read ändert nicht
| `environment` | das Umfeld (Diamond 3.6): drei Jugendteams, Co-Trainer, Arzt, Physiotherapeut (`environment:<Bereich>`), je Stufe 0–6, Monatskosten, Kosten je Stufe; die Jugendteams mit Stärke, Platz, Liga; ob die Akademie läuft |
| `toto` | der Tippschein ([Toto](toto.md)): `open` (elf Spiele), Spiele, Einsatz und Kosten (`Money`), Spalten, Regeln, letzte Abrechnung |
| `sponsor` | das Exklusiv-Sponsor-Angebot aus einem Trainingslager und ein vorgemerkter Vertrag (`monthly` als `Money`; `asset: null`, siehe [Trainingslager](trainingslager.md)) |
| `bank` | Konto, Festgeld, Kreditrahmen, Anlagen (alles `Money`), die 12 Aktien (Kurs, Vorkurs, Bestand, bezahlt, Höchstkauf, 30 Kurse Verlauf) und die angebotenen Fonds; `credit` verweist auf den Read `credit`, der Aktientipp zieht Zufall und kommt als `quote.request` |
| `bank` | Konto, Festgeld, Kreditrahmen, Anlagen (alles `Money`), die 12 Aktien (Kurs, Vorkurs, Bestand, bezahlt, Höchstkauf, 30 Kurse Verlauf) und die angebotenen Fonds; `credit` verweist auf den Read `credit`, der Aktientipp zieht Zufall und kommt als `quote.request`. Modern hängt vier [weitere Immobilien](immobilien.md) als `fund:6`–`fund:9` an (zusätzlich `monthlyRent`, `limit`); `bank.commit` handelt sie wie die übrigen |
| `credit` | der Kreditdialog (`lenderId` `bank` oder die Manager-ID eines anderen Menschen): `saved` (Darlehen, Gesamtbetrag, Rate, Laufzeit, vergangene Monate, Zahlungen), `fields` (acht Felder mit `field`, `label`, `value`, `editable`, `min`, `max`; Werte in ganzen Euro bzw. Monaten), `fees`, `refund`, `principalPaid` (`Money`). Optional `edits` [{field, value}] als Vorschau, nichts wird gebucht; Fehler `unknown_lender`, `credit_unavailable`, `invalid_credit_edit` |
| `assembly` | die [Jahreshauptversammlung](hauptversammlung.md) und die interessierten Vereine: `available` (false am Schreibtisch des Bundestrainers), `due` (am Schreibtisch „Saisonende“, solange in dieser Saison nicht abgestimmt ist), `dismissals`, `vote {sport, finance, supporters, yes, confirmed}` (Prozent), `club` und `offers[]` je mit `teamId`, `name`, `league`, `leagueIndex`, `leagueSize`, `strength` (Schnitt der Elf), `lines {goal, defence, midfield, attack}`, `positions[]` (Platz nach jedem Spieltag der Saison), `squad` (Spieler), `averageAge` (Altersschnitt des Kaders in Zehnteljahren), `results[]` (die letzten sechs Ligaspiele: `home`, `goalsFor`, `goalsAgainst`, `opponent`, `outcome` win/draw/loss), `stadiumCapacity` (Plätze des Stadions, das ein Manager dort erhält), `position`; Angebote zusätzlich `cash` (`Money`), dazu `cash` des Managers heute. Rein lesend, zieht keine Zufallszahl |
| `postmatch` | das Nachspiel des letzten `session.advance` (auch am Bundestrainer-Schreibtisch): `steps` (`results`, `report`, `team_of_the_day`, `overview`, `table` je mit `available`), `matches` (alle Spiele des Anstoßes im Almanach-Format), `reportMatchIds` (Spiele menschlicher Manager), `teamOfTheDay` (die Sportschau-Elf der Engine je Wettbewerb mit Spieler, Verein, Wertung; nur mit der Sportschau-Option der EXE, sonst leer und `team_of_the_day` nicht verfügbar), `tables` (die aktuellen Tabellen der Ligen des Spieltags). Rückblick und Abspielen ändern nichts; weiter geht es mit `session.advance` |
@@ -64,7 +64,7 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
`ModernSession::read_live` (für `DataSource::read_live`, Abfragen wie die Demo: `{kind: "fixture"}`, `{kind: "frame", sequence}`, optional `revision`, `fixture_id`). Die Engine rechnet einen Spieltag beim Anstoß im Ganzen; der Ticker spielt die **Aufzeichnung** der Spiele des letzten `session.advance` ab (`source: "engine-recording"`, Format `openbmh-live-fixture@1` der Demo):
- `matches`: die Spiele mit menschlichem Manager (höchstens vier), `owners`: die Manager mit Team und `match_id` (`view` ist `null`; die Aufstellung kommt aus dem `lineup`-Read).
- `matches` (die Spiele des Tickers) mit `capacity` (Plätze des Heimstadions, nur wenn der Heimverein von einem Manager geführt wird, sonst `null`), `attendance` (Zuschauer) und `weather` (`temperature` in °C, `rain` das Wetterbild 0–7 des Originals; Hallenturnier `null`), schon vor dem Anpfiff; ebenso jede Partie des angehaltenen Live-Anstoßs (aus der Spielgruppe).
- `matches` (die Spiele des Tickers) mit `stadiumName` (Name des Stadions eines von einem Menschen geführten Heimvereins, sonst `null`) und `capacity` (Plätze des Heimstadions, nur wenn der Heimverein von einem Manager geführt wird, sonst `null`), `attendance` (Zuschauer) und `weather` (`temperature` in °C, `rain` das Wetterbild 0–7 des Originals; Hallenturnier `null`), schon vor dem Anpfiff; ebenso jede Partie des angehaltenen Live-Anstoßs (aus der Spielgruppe).
- `frames` in Minutenfolge: Anpfiff, jedes Ereignis (Tor, Chance, Karten, Verletzung, Wechsel, Elfmeter), Halbzeit, Wiederanpfiff, Abpfiff; je Spiel Stand, Chancen, Gelb, Rot, Elfmeter, Spieler auf dem Feld. `events` (fortlaufend) mit Überschrift und Satz, Spieler, Seite, Stand.
- `conference`: die übrigen Spiele des Tages im Almanach-Format.
- `standings` (Live-Tabelle) je Frame: pro Liga eines Ticker-Spiels die Tabelle vor dem Spieltag plus alle Spiele dieser Runde im Anstoß mit dem Stand der Minute (beim Abpfiff das gewertete Ergebnis); Zeilen mit `rank`, `previousRank`, `team`, `played`, `won`, `drawn`, `lost`, `goalsFor`, `goalsAgainst`, `points`. In der Aufzeichnung trägt ein Frame nur die Tabellen, die sich in ihm geändert haben (der erste alle); `kind: frame` liefert den vollständigen Stand bis dahin. Der angehaltene Live-Anstoß liefert `standings` ebenso: je Ligagruppe mit einem Live-Spiel die Tabelle mit den Ständen der laufenden Spiele. Fehler: `live_unavailable` (noch kein Anstoß), `live_no_human_match`, `stale_live_revision`, `stale_live_fixture`, `invalid_live_sequence`.
@@ -95,6 +95,9 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
| `environment.commit` | `itemId`, `level` 0–6 | setzt ein Monatsbudget des Umfelds (keine Sofortbuchung, kein Zufall); unverändert: `outcome: no_change`; Fehler `environment_refused` |
| `manager.resign.commit` | `confirmed: true` | Aufgeben (neu in Modern, das Original kennt kein Aussteigen). Spielt nur ein Mensch (oder ist er der letzte), endet das Spiel wie mit dem Ablauf der festgelegten Dauer: die Highscore-Tabelle wird fortgeschrieben und angezeigt (der Hook der Saisonwende, erst Aktualisierung, dann Anzeige), `outcome: career_ended`, `ownershipChange` mit `archivedIdentity` (Manager `control: archived`, `status: resigned`, Amtszeiten mit `until` und `endReason: resigned`), `terminationReason: last_human_resigned`; danach antwortet jeder Befehl `career_ended`. Beim Ablauf der Dauer sind die Manager `retired`, die Amtszeiten enden mit `career_end`. Mit weiteren Menschen soll der Computer den Verein übernehmen; das braucht das Nachrücken aller Managertabellen und folgt (`resign_not_supported_yet`). Fehler `confirmation_required` |
| `manager.clubChange` | `teamId`, `confirmed: true` | der Manager wechselt zu einem der interessierten Vereine des Reads `assembly` und beginnt dort mit dessen Kasse ([Regeln](hauptversammlung.md)). Fehler: `confirmation_required`, `not_at_desk`, `no_club` (Bundestrainer), `club_change_refused` (Verein nicht auf der Liste) |
| `lineup.setNumber` | `playerId`, `number` 1–99 | die [Rückennummer](rueckennummern.md) eines Spielers des eigenen Vereins; wer die Nummer trug, übernimmt die bisherige des Spielers. Fehler: `no_club`, `unknown_player`, `invalid_number` |
| `marketing.commit` | `budget` (`Money`, 0–500 000 € in ganzen Tausendern) | das Monatsbudget der [internationalen Vermarktung](vermarktung.md). Fehler: `no_club`, `invalid_budget` |
| `stadium.expand` | `expansionId` (aus `expansions` des Reads `stadium`), `confirmed: true` | beginnt die nächste [Ausbaustufe](ausbaustufen.md) von Lounge oder Peripheriegebäude und bezahlt sie. Fehler: `confirmation_required`, `unknown_expansion`, `expansion_refused` |
| `stadium.rename` | `name` | benennt das eigene Stadion ([Regeln](namensrecht.md)): 1–40 Zeichen. Fehler: `no_club`, `invalid_name`, `name_sold` (der Name ist verkauft) |
| `stadium.namingRights` | `offerId` (`naming:<n>` aus dem Read `stadium`), `confirmed: true` | verkauft den Stadionnamen an den Sponsor des Angebots; er zahlt mit jedem Monatswechsel. Fehler: `confirmation_required`, `name_sold`, `unknown_offer` |
| `toto.submit` | `stake` (`Money` je Spalte), `columns` (bis 6 Spalten mit 11 Tipps: 1 Heim, 0 Unentschieden, 2 Auswärts) | gibt den Tippschein ab; Fehler `toto_refused` (z. B. kein offener Schein, Einsatzgrenzen, doppelte Spalte) |
+53
View File
@@ -0,0 +1,53 @@
# Internationale Vermarktung · Modern-Engine
Stand: 17. November 2026. Eine Modern-Regel; Classic kennt sie nicht.
## Regel
Der Manager legt ein Monatsbudget fest (0 bis 500 000 Euro in ganzen Tausendern). Das Budget
kauft Reichweite im Ausland; die Reichweite bringt jeden Monat Einnahmen.
```
Ziel = Budget / 500, höchstens 1000 (Promille)
je Monatswechsel:
Budget zahlen; reicht das Konto samt Kreditrahmen nicht, gilt der Monat als einer ohne Budget
Reichweite unter dem Ziel: + (Ziel − Reichweite) / 6, mindestens 1
Reichweite über dem Ziel: − (Reichweite − Ziel) / 4, mindestens 1
Einnahme = wirksam × Wert × (60 + Ansehen × 4/5) %
wirksam = Reichweite − Reichweite² / 2000 (die volle Reichweite zählt halb)
Wert = 900 / 400 / 170 / 70 / 70 Euro je Punkt (1. bis 5. Liga)
```
- Die Reichweite wächst über etwa ein bis zwei Jahre an und fällt schneller, wenn das Budget
gekürzt wird.
- In der ersten Liga trägt sich ein mittleres Budget deutlich (200 000 Euro Budget bringen
am Ziel rund 290 000 Euro im Monat bei mittlerem Ansehen); in der zweiten nur bei hohem Ansehen,
darunter gar nicht. Jeder weitere Punkt Reichweite ist weniger wert.
- Keine Zufallszahl. Die Regel läuft als zweiter Schritt von `month_change`
(`modern::marketing_month`).
- Bei einem [Vereinswechsel](hauptversammlung.md) bleibt die Reichweite beim alten Verein.
## Speichern
`state/modern.json` erhält das optionale Feld `marketing`: je Managerplatz `{budget, reach}`.
## Anbindung
Read `advertising`, Feld `internationalMarketing` (`budget`, `maxBudget`, `reach`,
`targetReach`, `maxReach`, `income`, `incomeAtTarget`); Befehl `marketing.commit {budget}`
(Fehler `no_club`, `invalid_budget`).
## Prüfung
`modern_marketing_tests` (ohne Spieldaten): Ziel je Budget, Grenzen des Budgets, Einnahme nach
Reichweite, Liga und Ansehen, Aufbau über die Monate, Überschuss am Ziel, Abbau ohne Budget,
unbezahlter Monat.
## Offen
- In der Bilanz steht das Budget unter „PR-Arbeit“, die Einnahme unter „Sonstiges“. Die
Monatsprognose der Werbeseite rechnet beides mit.
- Die Sätze wurden am 17. November 2026 nach einer Karriere auf Stufe 4 gesenkt (vorher 1600
Euro je Punkt in der ersten Liga: nach zwei Monaten schon über dem Budget). Über mehrere
Saisons sind sie nicht gemessen.
- Auf der leichtesten Stufe bucht das Spiel kein Geld; die Reichweite wächst dort trotzdem.
+5
View File
@@ -161,6 +161,11 @@ wurden tatsächlich gesichtet. Private GUI-Ressourcen und Bildschirmbelege
bleiben außerhalb dieses öffentlichen Repositories. Windows und macOS sind
nicht interaktiv geprüft; dies ist kein Engine- oder Plattformrelease.
> **Stand 17. November 2026:** Der Treiber unten zielt noch auf den früheren Schreibtisch und den
> alten Ticker (`#object-app-kickoff`, `#window-close`, `.live-*`). Seit dem Notizbuch und dem
> Spielbogen (`mv-*`) gibt es diese Elemente nicht mehr; der Treiber muss vor dem nächsten Lauf
> auf die neuen Kennungen umgestellt werden. Er ist bis dahin nicht lauffähig.
Der wiederholbare native Eingabelauf liegt in
`tools/modern_ui/live_demo_qa.py`. Beispiel mit selbst erzeugten Fixtures:
+121 -4
View File
@@ -13,6 +13,10 @@
#include "modern/content/world_save.hpp"
#include "modern/game/assembly.hpp"
#include "modern/game/naming_rights.hpp"
#include "modern/game/marketing.hpp"
#include "modern/game/shirt_numbers.hpp"
#include "modern/game/estates.hpp"
#include "modern/game/expansions.hpp"
#include "modern/game/balance_plan.hpp"
#include "modern/game/bank_credit.hpp"
#include "modern/game/career.hpp"
@@ -9494,6 +9498,25 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
A history,table;
for(size_t curve=0;curve<6;++curve){A values,absolute,relative;for(const auto value:data.series[curve])values.push_back(int64_t(value));auto graph=data;bool absolute_ok=true,relative_ok=true;try{graph.flags=0x7f;for(const auto& [x,y]:ui::stadium_data_points(graph,exe_,int(curve)))absolute.push_back(A{cli::Json(x),cli::Json(y)});}catch(const std::exception&){absolute_ok=false;}try{graph.flags=0xbf;for(const auto& [x,y]:ui::stadium_data_points(graph,exe_,int(curve)))relative.push_back(A{cli::Json(x),cli::Json(y)});}catch(const std::exception&){relative_ok=false;}history.push_back(O{{"name",ui::original_to_utf8(exe_.cstring(exe_.u32(::bmh::layout::Analytics_FormatError_ExecutableField+(6+uint32_t(curve))*4)))},{"values",std::move(values)},{"absolute",std::move(absolute)},{"relative",std::move(relative)},{"absoluteAvailable",absolute_ok},{"relativeAvailable",relative_ok}});}
for(size_t row=0;row<data.table.size();++row){A cells;for(const auto& value:data.table[row]){auto text=ui::original_to_utf8(value);if(row!=1&&row!=3)text.erase(0,text.find_first_not_of("% "));cells.push_back(std::move(text));}table.push_back(std::move(cells));}
// the further stages of lounge and periphery (ausbaustufen.md)
A expansions;
{
static constexpr const char* kExpansionId[modern::kExpansions] = {"lounge", "mall", "clubhouse", "parking", "restaurant"};
static constexpr const char* kExpansionObject[modern::kExpansions] = {"facility:vip_lounge", "periphery:2", "periphery:3", "periphery:4", "periphery:5"};
for (int k = 0; k < modern::kExpansions; ++k) {
const auto item = modern::Expansion(k);
const int32_t price = modern::expansion_price(g_, manager, item);
const int left = modern::expansion_months_left(g_, manager, item);
const bool built = modern::expansion_base_built(g_, manager, item);
expansions.push_back(O{{"id", std::string("expansion:") + kExpansionId[k]}, {"objectId", kExpansionObject[k]},
{"name", k == 0 ? text(734 + 3) : text(720 + size_t(k) + 1)},
{"stage", modern::expansion_stage(g_, manager, item)}, {"maxStage", int(modern::kExpansionStages[size_t(k)])},
{"monthsLeft", left}, {"monthlyIncome", modern::ui_money(int64_t(modern::expansion_income(g_, manager, item)))},
{"nextPrice", price ? modern::ui_money(int64_t(price)) : cli::Json(nullptr)},
{"nextMonths", price ? cli::Json(modern::expansion_build_months(g_, manager, item)) : cli::Json(nullptr)},
{"available", built && price != 0 && left == 0}});
}
}
// the name (managed_stadium_name), its sponsor while it is sold, and the sponsors' offers
cli::Json naming_contract = nullptr;
A naming_offers;
@@ -9533,7 +9556,7 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
}
return modern::ui_snapshot(g_, context, request_id,
O{{"kind", "stadium"}, {"name", managed_stadium_name(g_, manager)}, {"worldName", stadium_name}, {"nameEditable", !modern::naming_rights_sold(g_, manager)},
{"namingRights", std::move(naming_contract)}, {"namingOffers", std::move(naming_offers)}, {"teamId", modern::ui_team_id(g_, team)}, {"quote", std::move(quote)}, {"periphery", std::move(periphery)},
{"namingRights", std::move(naming_contract)}, {"namingOffers", std::move(naming_offers)}, {"expansions", std::move(expansions)}, {"teamId", modern::ui_team_id(g_, team)}, {"quote", std::move(quote)}, {"periphery", std::move(periphery)},
{"facilities", std::move(facilities)}, {"blocks", std::move(blocks)},
{"history",std::move(history)},{"table",std::move(table)},{"requiredAttendanceText",ui::original_to_utf8(data.required_attendance_text)},{"ticketPrice", modern::ui_money(data.ticket_price)}, {"ticketPriceRange", O{{"min", modern::ui_money(8)}, {"max", modern::ui_money(25)}}}});
}
@@ -9570,11 +9593,29 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
{"maximum", modern::ui_money(a.spending[i].maximum_amount)}, {"deliveryWeeks", int(a.spending[i].delivery_weeks)},
{"available", a.spending[i].available}});
return modern::ui_snapshot(g_, context, request_id,
O{{"kind", "advertising"}, {"teamId", modern::ui_team_id(g_, team)}, {"boards", std::move(boards)},
O{{"kind", "advertising"}, {"internationalMarketing", [&] {
// budget and reach of the manager's international marketing (vermarktung.md)
const auto entry = size_t(manager) < g_.marketing.size() ? g_.marketing[size_t(manager)] : modern::ModernState::Marketing{};
const int target = modern::marketing_target(entry.budget);
return O{{"budget", modern::ui_money(int64_t(entry.budget))}, {"maxBudget", modern::ui_money(int64_t(modern::kMarketingBudgetMax))},
{"reach", int(entry.reach)}, {"targetReach", target}, {"maxReach", modern::kMarketingReachMax},
{"income", modern::ui_money(int64_t(modern::marketing_income(g_, manager, entry.reach)))},
{"incomeAtTarget", modern::ui_money(int64_t(modern::marketing_income(g_, manager, target)))}};
}()},
{"teamId", modern::ui_team_id(g_, team)}, {"boards", std::move(boards)},
{"shirt", contract(a.shirt, "ad:shirt", 14)}, {"television", contract(a.television, "ad:tv", 15)},
{"budgets", std::move(budgets)},
{"preview", O{{"income", modern::ui_money(a.finance_preview.income)}, {"expenses", modern::ui_money(a.finance_preview.expenses)},
{"balance", modern::ui_money(a.finance_preview.balance)}}}});
{"preview", [&] {
// the month as the original forecasts it, with what Modern's own rules pay and cost a month:
// the stadium sponsor, marketing, rents and the further stages
int64_t more = 0, less = 0;
if (const auto* ground = modern::stadium_entry(g_, manager); ground && ground->months > 0) more += ground->monthly;
if (size_t(manager) < g_.marketing.size()) more += modern::marketing_income(g_, manager, g_.marketing[size_t(manager)].reach), less += g_.marketing[size_t(manager)].budget;
for (int k = 0; k < modern::kEstates; ++k) more += int64_t(modern::estates_held(g_, manager, k)) * modern::estate_rent(g_, k);
for (int k = 0; k < modern::kExpansions; ++k) more += modern::expansion_income(g_, manager, modern::Expansion(k));
return O{{"income", modern::ui_money(int64_t(a.finance_preview.income) + more)}, {"expenses", modern::ui_money(int64_t(a.finance_preview.expenses) + less)},
{"balance", modern::ui_money(int64_t(a.finance_preview.balance) + more - less)}};
}()}});
}
if (kind == "contracts") {
// per player: remaining months, monthly salary, insurance, the team bonuses; the open quote
@@ -9691,6 +9732,19 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
funds.push_back(O{{"id", "fund:" + std::to_string(i)}, {"name", property}, {"price", modern::ui_money(f.price)},
{"owned", int(f.owned)}, {"paid", modern::ui_money(f.paid)}, {"maxToBuy", f.max_to_buy}});
}
// the four further properties of Modern follow the six of the original as fund:6 to fund:9
{
static constexpr const char* kEstateNames[modern::kEstates] = {"Stadthaus", "Penthouse", "Siedlungshaus", "Altbau-Reihenhaus"};
const int64_t means = int64_t(b.balance) + int64_t(b.credit_line);
for (int k = 0; k < modern::kEstates; ++k) {
const int32_t price = modern::estate_price(g_, k);
const int held = modern::estates_held(g_, manager, k);
funds.push_back(O{{"id", "fund:" + std::to_string(6 + k)}, {"name", kEstateNames[k]}, {"price", modern::ui_money(int64_t(price))},
{"owned", held}, {"paid", modern::ui_money(int64_t(held) * price)},
{"maxToBuy", int(std::clamp<int64_t>(price > 0 ? means / price : 0, 0, modern::kEstateLimit - held))},
{"monthlyRent", modern::ui_money(int64_t(modern::estate_rent(g_, k)))}, {"limit", modern::kEstateLimit}});
}
}
// the interest of a year in hundredths of a percent, read off the rule that books it
// every day: what one day costs or earns on a sum of 36.5 million
constexpr int32_t probe = 36500000;
@@ -9778,6 +9832,7 @@ cli::Json ModernSession::finish_live(const std::string& request_id, uint64_t pre
g_.transfer_offer_selector = run.previous_offer_selector;
contract_expiry_presenter_installed_ = run.previous_contract_installed;
modern::journal_advance(g_, run.saved_state);
for (const int t : g_.manager_teams) if (t >= 0 && t < league_clubs()) modern::fix_shirt_numbers(g_, t); // the numbers stay with the players
modern::ensure_ui_identities(g_);
ui_last_advance_ = std::make_pair(run.from_date, g_.date);
ui_last_awards_ = std::move(run.awards);
@@ -9969,6 +10024,8 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
return false;
}
modern::assembly_baseline(g_, manager);
// a note in his mailbox, in the form of the original's messages
try { post_composed(g_, manager, ui::utf8_to_original("Vereinswechsel: Sie führen jetzt ") + g_.club_name(offer->team) + "."); } catch (const std::exception&) {}
int master = -1;
for (size_t m = 0; m * 2 + 1 < db_.raw_club_name_offsets.size() && master < 0; ++m)
if (uint16_t(db_.raw_club_name_offsets[m * 2] | db_.raw_club_name_offsets[m * 2 + 1] << 8) == g_.club_ids.at(size_t(offer->team))) master = int(m);
@@ -10008,6 +10065,10 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
return ask("Die Mitglieder haben den Manager abgewählt: Er muss den Verein wechseln.");
}
modern::assembly_remember(g_, manager, vote);
try {
post_composed(g_, manager, ui::utf8_to_original("Jahreshauptversammlung: " + std::to_string(vote.yes) + " % der Mitglieder stimmen für Sie. " +
(vote.confirmed ? "Sie bleiben im Amt." : must_leave ? "Sie sind abgewählt." : "Das bleibt ohne Folgen.")));
} catch (const std::exception&) {}
if (!new_club.empty() && !move_manager(new_club)) { restore(); managers_ = managers_before; return refuse("club_change_refused", error); }
}
}
@@ -10432,6 +10493,7 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
return rehearsal;
}
modern::journal_advance(g_, saved_state);
for (const int t : g_.manager_teams) if (t >= 0 && t < league_clubs()) modern::fix_shirt_numbers(g_, t); // the numbers stay with the players
modern::ensure_ui_identities(g_);
revision = previous + 1;
ui_last_advance_ = std::make_pair(saved_state.date, g_.date); // what read_live replays
@@ -11087,6 +11149,48 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
} else if (kind == "manager.join.commit") {
answer = ui_join_managers(*payload,request_id,revision);
if (ui_text(answer,"messageType")=="error") return answer;
} else if (kind == "stadium.expand") {
// payload {expansionId: "expansion:lounge|mall|clubhouse|parking|restaurant", confirmed: true}:
// starts the next stage of the building and pays for it (ausbaustufen.md)
const cli::Json* confirmed = ui_field(*payload, "confirmed");
if (!confirmed || !std::holds_alternative<bool>(confirmed->value) || !std::get<bool>(confirmed->value))
return refuse("confirmation_required", "Der Ausbau muss bestätigt werden (confirmed: true).");
static constexpr const char* kExpansionId[modern::kExpansions] = {"lounge", "mall", "clubhouse", "parking", "restaurant"};
int item = -1;
for (int k = 0; k < modern::kExpansions; ++k)
if (ui_text(*payload, "expansionId") == std::string("expansion:") + kExpansionId[k]) item = k;
if (item < 0) return refuse("unknown_expansion", "Diesen Ausbau gibt es nicht.");
if (!modern::start_expansion(g_, manager, modern::Expansion(item)))
return refuse("expansion_refused", "Ausbau nicht möglich: Das Gebäude steht nicht, wird gerade ausgebaut, ist fertig ausgebaut, oder das Konto reicht nicht.");
revision = previous + 1;
answer = modern::ui_command_result(request_id, previous, revision, {"stadium", "desktop"}, "Der Ausbau hat begonnen.");
} else if (kind == "lineup.setNumber") {
// payload {playerId, number 1-99}: the shirt number of a player of the manager's club; the
// player who wore the number takes the other's (rueckennummern.md)
const cli::Json* number = ui_field(*payload, "number");
const std::string id = ui_text(*payload, "playerId");
const int team = g_.manager_teams[size_t(manager)];
if (team < 0 || team >= league_clubs()) return refuse("no_club", "Am Schreibtisch des Bundestrainers gibt es keine Rückennummern.");
int player = -1;
const SquadRange range = squad_range(team);
for (size_t i = 0; i < range.count; ++i)
if (const int p = g_.squad_slots[range.first + i] & 0x0fff; p != 0x0fff && modern::ui_player_id(g_, p) == id) player = p;
if (player < 0) return refuse("unknown_player", "Spieler nicht im Kader: " + id);
if (!number || !number->integer() || !modern::set_shirt_number(g_, manager, player, int(*number->integer())))
return refuse("invalid_number", "Die Rückennummer liegt zwischen 1 und 99.");
revision = previous + 1;
answer = modern::ui_command_result(request_id, previous, revision, {"squad", "lineup", "tactics"}, "Rückennummer vergeben.");
} else if (kind == "marketing.commit") {
// payload {budget: Money}: the monthly budget for international marketing, in whole thousands
const cli::Json* amount = ui_field(*payload, "budget");
int64_t cents = -1;
try { cents = amount ? std::stoll(ui_text(*amount, "minor")) : -1; } catch (const std::exception&) { cents = -1; }
if (const int team = g_.manager_teams[size_t(manager)]; team < 0 || team >= league_clubs())
return refuse("no_club", "Am Schreibtisch des Bundestrainers gibt es keine Vermarktung.");
if (cents < 0 || cents % 100 || cents / 100 > modern::kMarketingBudgetMax || !modern::set_marketing_budget(g_, manager, int32_t(cents / 100)))
return refuse("invalid_budget", "Das Budget liegt zwischen 0 und 500.000 Euro in ganzen Tausendern.");
revision = previous + 1;
answer = modern::ui_command_result(request_id, previous, revision, {"advertising", "desktop"}, "Budget für die internationale Vermarktung übernommen.");
} else if (kind == "stadium.rename") {
// payload {name}: the manager names his stadium (namensrecht.md); not while the name is sold
if (const int team = g_.manager_teams[size_t(manager)]; team < 0 || team >= league_clubs())
@@ -11309,6 +11413,19 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
if ((!stock && !fund) || !count || !count->integer()) return refuse("invalid_payload", "assetId und count nötig.");
try { r.asset_index = std::stoi(asset.substr(stock ? 6 : 5)); } catch (const std::exception&) { return refuse("unknown_asset", asset); }
r.count = int(*count->integer());
if (fund && r.asset_index >= 6) {
// one of Modern's four further properties (immobilien.md): traded at today's price
const int k = r.asset_index - 6;
if (k >= modern::kEstates) return refuse("unknown_asset", asset);
if (!(action == "buy" ? modern::buy_estate(g_, manager, k, r.count) : modern::sell_estate(g_, manager, k, r.count)))
return refuse(action == "buy" ? "purchase_refused" : "sale_refused",
action == "buy" ? "Kauf nicht möglich: Konto, Anzahl oder die Grenze von 20 Stück." : "Verkauf nicht möglich: nicht so viele im Bestand.");
revision = previous + 1;
answer = modern::ui_command_result(request_id, previous, revision, {"bank", "desktop"}, action == "buy" ? "Immobilie gekauft." : "Immobilie verkauft.");
ui_answers_[request_id] = {body, answer};
ui_answer_order_.push_back(request_id);
return answer;
}
r.kind = stock ? (action == "buy" ? ui::BankRequestKind::buy_shares : ui::BankRequestKind::sell_shares)
: (action == "buy" ? ui::BankRequestKind::buy_fund : ui::BankRequestKind::sell_fund);
} else if (action == "credit") {
+4 -2
View File
@@ -21,6 +21,7 @@
#include "modern/game/desk_actions.hpp"
#include "modern/game/environment.hpp"
#include "modern/game/reschedule.hpp"
#include "modern/game/shirt_numbers.hpp"
namespace bmh::modern {
@@ -151,7 +152,7 @@ A allowed_commands(const ModernState& g, const UiContext& c) {
const int team = team_of(g, c.manager);
const bool national = team == no_team();
static constexpr const char* kAll[] = {
"session.advance", "lineup.commit", "lineup.setPiece", "lineup.setOrder", "lineup.setFormation", "tactics.commit", "friendly.book", "manager.resign.commit", "manager.clubChange", "stadium.rename", "stadium.namingRights",
"session.advance", "lineup.commit", "lineup.setPiece", "lineup.setOrder", "lineup.setFormation", "tactics.commit", "friendly.book", "manager.resign.commit", "manager.clubChange", "stadium.rename", "stadium.namingRights", "marketing.commit", "lineup.setNumber", "stadium.expand",
"training.commit", "camp.book", "bank.commit", "toto.submit", "quote.request", "contract.offer",
"stadium.commit", "advertising.accept", "budget.commit", "ticket.commit", "transfer.submit",
"sponsor.answer", "environment.commit", "fixture.reschedule", "contract.cancel", "news.update", "balance.commit", "settings.commit", "manager.join.commit"};
@@ -298,6 +299,7 @@ J squad_data(const ModernState& g, const UiContext& c, int team, const std::stri
}
}
A players;
const std::vector<int> shirts = squad_shirt_numbers(g, team);
for (size_t s = r.first; s < r.first + r.count && s < g.squad_slots.size(); ++s) {
const uint16_t e = g.squad_slots[s];
const int id = e & 0x0fff;
@@ -320,7 +322,7 @@ J squad_data(const ModernState& g, const UiContext& c, int team, const std::stri
for (int k = 0; k < 7; ++k) skills[kSkills[k]] = int(p.w368 >> (2 * k) & 3);
O row{{"player", O{{"id", pid}, {"name", first.empty() ? last : first + " " + last}, {"photoAssetId", photo_of(pid)},
{"nationIds", nation.empty() ? A{} : A{J(nation)}}, {"positions", A{J(kPositions[p.position()])}},
{"shirtNumber", nullptr}}},
{"shirtNumber", s - r.first < shirts.size() && shirts[s - r.first] ? J(shirts[s - r.first]) : J(nullptr)}}},
{"clubId", team < league_clubs() ? J(team_id(g, team)) : J(nullptr)},
{"squadTeamId", team_id(g, team)},
{"role", (e & 0x8000) ? "starter" : (e & 0x4000) ? "bench" : "reserve"},
+74
View File
@@ -194,6 +194,33 @@ void save_world_career(const std::filesystem::path& path, const World& world, co
return J(std::move(rows));
}()},
{"dismissals", state.dismissals},
{"expansions", [&] {
A rows;
for (const auto& e : state.expansions) {
A stage, months;
for (size_t k = 0; k < 5; ++k) stage.push_back(int64_t(e.stage[k])), months.push_back(int64_t(e.months[k]));
rows.push_back(O{{"stage", std::move(stage)}, {"months", std::move(months)}});
}
return J(std::move(rows));
}()},
{"estates", [&] {
A rows;
for (const auto& held : state.estates) rows.push_back(A{J(int64_t(held[0])), J(int64_t(held[1])), J(int64_t(held[2])), J(int64_t(held[3]))});
return J(std::move(rows));
}()},
{"estate_prices", A{J(int64_t(state.estate_prices[0])), J(int64_t(state.estate_prices[1])), J(int64_t(state.estate_prices[2])), J(int64_t(state.estate_prices[3]))}},
{"shirt_numbers", [&] {
// only the players who have a number: [player, number] pairs
A rows;
for (size_t p = 0; p < state.shirt_numbers.size(); ++p)
if (state.shirt_numbers[p]) rows.push_back(A{J(int64_t(p)), J(int64_t(state.shirt_numbers[p]))});
return J(std::move(rows));
}()},
{"marketing", [&] {
A rows;
for (const auto& m : state.marketing) rows.push_back(O{{"budget", int64_t(m.budget)}, {"reach", int64_t(m.reach)}});
return J(std::move(rows));
}()},
{"stadiums", [&] {
A rows;
for (const auto& s : state.stadiums)
@@ -276,6 +303,53 @@ SavedWorldCareer load_world_career(const std::filesystem::path& path, const Worl
if (const auto it = o->find("dismissals"); it != o->end() && std::holds_alternative<bool>(it->second.value))
out.state.dismissals = std::get<bool>(it->second.value);
}
// further stages of lounge and periphery (since 17 November 2026)
if (o->count("expansions"))
for (const J& row : arr(get(modern, "expansions"))) {
const A& stage = arr(get(row, "stage"));
const A& months = arr(get(row, "months"));
if (stage.size() != 5 || months.size() != 5) fail("invalid expansions");
ModernState::Expansions e;
for (size_t k = 0; k < 5; ++k) {
if (num(stage[k]) < 0 || num(stage[k]) > 3 || num(months[k]) < 0 || num(months[k]) > 12) fail("invalid expansions");
e.stage[k] = uint8_t(num(stage[k])), e.months[k] = uint8_t(num(months[k]));
}
out.state.expansions.push_back(e);
}
// the four further properties (since 17 November 2026)
if (o->count("estates") && o->count("estate_prices")) {
for (const J& row : arr(get(modern, "estates"))) {
const A& held = arr(row);
if (held.size() != 4) fail("invalid properties");
std::array<uint16_t, 4> pieces{};
for (size_t k = 0; k < 4; ++k) {
if (num(held[k]) < 0 || num(held[k]) > 20) fail("invalid properties");
pieces[k] = uint16_t(num(held[k]));
}
out.state.estates.push_back(pieces);
}
const A& prices = arr(get(modern, "estate_prices"));
if (prices.size() != 4) fail("invalid property prices");
for (size_t k = 0; k < 4; ++k) out.state.estate_prices[k] = uint32_t(num(prices[k]));
}
// shirt numbers (since 17 November 2026)
if (o->count("shirt_numbers"))
for (const J& row : arr(get(modern, "shirt_numbers"))) {
const A& pair = arr(row);
if (pair.size() != 2) fail("invalid shirt number");
const int64_t player = num(pair[0]), number = num(pair[1]);
if (player < 0 || size_t(player) >= out.state.players.size() || number < 1 || number > 99) fail("invalid shirt number");
if (out.state.shirt_numbers.size() <= size_t(player)) out.state.shirt_numbers.resize(out.state.players.size(), 0);
out.state.shirt_numbers[size_t(player)] = uint8_t(number);
}
// international marketing (since 17 November 2026)
if (o->count("marketing"))
for (const J& row : arr(get(modern, "marketing"))) {
ModernState::Marketing m;
m.budget = int32_t(num(get(row, "budget"))), m.reach = uint16_t(num(get(row, "reach")));
if (m.budget < 0 || m.budget > 500000 || m.reach > 1000) fail("invalid marketing state");
out.state.marketing.push_back(m);
}
// stadium names and naming rights (since 17 November 2026)
if (o->count("stadiums"))
for (const J& row : arr(get(modern, "stadiums"))) {
+2 -1
View File
@@ -8,6 +8,7 @@
#include "formats/executable_layout.hpp"
#include "game/random.hpp"
#include "game/schedule.hpp"
#include "modern/game/estates.hpp"
#include "modern/game/matchday.hpp"
namespace bmh::modern {
@@ -52,7 +53,7 @@ int64_t holdings(const ModernState& g, int m) {
const uint32_t at = ::bmh::layout::Analytics_SourceAssetMaskE_RuntimeField + uint32_t(m) * 0x78 + k * 0x18;
if (mem.has(at + 3)) sum -= int64_t(mem.u32(at));
}
return sum;
return sum + estates_value(g, m);
}
// What the club did in the cups of the running season: 2 a cup won, 1 a final lost, 0 otherwise.
+3
View File
@@ -698,6 +698,9 @@ bool change_club(ModernState& g, const LeImage& exe, int m, int team, int32_t ca
}
if (size_t(m) < g.pools.size()) g.pools[size_t(m)] = {};
if (size_t(m) < g.exclusive_sponsors.size()) g.exclusive_sponsors[size_t(m)] = {};
if (size_t(m) < g.expansions.size()) g.expansions[size_t(m)] = {}; // the further stages stand at the old ground
if (size_t(m) < g.estates.size()) g.estates[size_t(m)] = {}; // his further properties stay behind as well
if (size_t(m) < g.marketing.size()) g.marketing[size_t(m)] = {}; // the reach abroad was the old club's
if (size_t(m) < g.stadiums.size()) g.stadiums[size_t(m)] = {}; // the name and its sponsor belong to the old ground
// The club he leaves is a computer club again: its sales, bids and loans as a human club end.
+76
View File
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/game/estates.hpp"
#include <algorithm>
#include "game/random.hpp"
#include "modern/game/matchday.hpp"
#include "modern/game/modern_notes.hpp"
namespace bmh::modern {
namespace {
bool league_manager(const ModernState& g, int manager) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || g.manager_records.size() < size_t(manager + 1) * 0xb0c) return false;
const int team = g.manager_teams[size_t(manager)];
return team >= 0 && team < league_clubs();
}
} // namespace
int32_t estate_price(const ModernState& g, int k) {
if (k < 0 || k >= kEstates) return 0;
return g.estate_prices[size_t(k)] ? int32_t(g.estate_prices[size_t(k)]) : kEstateBasePrice[size_t(k)];
}
int estates_held(const ModernState& g, int manager, int k) {
return manager >= 0 && size_t(manager) < g.estates.size() && k >= 0 && k < kEstates ? g.estates[size_t(manager)][size_t(k)] : 0;
}
int64_t estates_value(const ModernState& g, int manager) {
int64_t sum = 0;
for (int k = 0; k < kEstates; ++k) sum += int64_t(estates_held(g, manager, k)) * estate_price(g, k);
return sum;
}
int32_t estate_rent(const ModernState& g, int k) { return estate_price(g, k) / 1000 * 4; }
// OpenBMH deviates from the original: Modern adds four properties to the bank whose prices move monthly and which pay a monthly rent.
bool buy_estate(ModernState& g, int manager, int k, int count) {
if (!league_manager(g, manager) || k < 0 || k >= kEstates || count < 1 || estates_held(g, manager, k) + count > kEstateLimit) return false;
const int64_t cost = int64_t(estate_price(g, k)) * count;
if (cost > INT32_MAX || !modern::book_money(g, manager, int32_t(cost), false)) return false;
if (g.estates.size() <= size_t(manager)) g.estates.resize(size_t(manager) + 1);
g.estates[size_t(manager)][size_t(k)] = uint16_t(estates_held(g, manager, k) + count);
return true;
}
bool sell_estate(ModernState& g, int manager, int k, int count) {
if (!league_manager(g, manager) || k < 0 || k >= kEstates || count < 1 || estates_held(g, manager, k) < count) return false;
modern::book_money(g, manager, -int32_t(int64_t(estate_price(g, k)) * count), true);
g.estates[size_t(manager)][size_t(k)] = uint16_t(estates_held(g, manager, k) - count);
return true;
}
void estates_month(ModernState& g) {
uint32_t salt = 2166136261u;
for (const unsigned char c : g.career_id) salt = (salt ^ c) * 16777619u;
for (int k = 0; k < kEstates; ++k) {
GameRandom draw(int32_t((uint64_t(salt) + uint64_t(g.date / 30) * 4099u + uint64_t(k) * 7907u + 29u) % 4000000u));
draw.range(0, 9); // (the first draw of a fresh seed is weak)
const int64_t base = kEstateBasePrice[size_t(k)];
const int64_t moved = int64_t(estate_price(g, k)) * (100 + draw.range(-2, 3)) / 100 / 1000 * 1000;
g.estate_prices[size_t(k)] = uint32_t(std::clamp<int64_t>(moved, base / 2, base * 3));
}
for (size_t m = 0; m < g.estates.size() && m < g.manager_teams.size(); ++m) {
if (!league_manager(g, int(m))) continue;
int64_t rent = 0;
for (int k = 0; k < kEstates; ++k) rent += int64_t(g.estates[m][size_t(k)]) * estate_rent(g, k);
if (rent > 0) {
modern::book_money(g, int(m), -int32_t(rent), true);
add_balance_item(g, int(m), BalanceItem::RentAndInterest, rent); // rents on the balance sheet
}
}
}
} // namespace bmh::modern
+40
View File
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// Four further properties of the bank (docs/new_engine/immobilien.md). A Modern rule beside
// the six properties of the original (the funds of its bank).
//
// A manager buys and sells them at the day's price. Every month the price of each moves by
// minus two to plus three percent (a generator of its own, seeded from the career, the month
// and the property; never below half or above three times its starting price), and every
// property held pays a rent of four per mille of its price. Draws no number of the game.
#include <array>
#include <cstdint>
#include "modern/game/modern_state.hpp"
namespace bmh::modern {
constexpr int kEstates = 4;
constexpr int kEstateLimit = 20; // pieces of one property a manager can hold
// Town house, penthouse, estate house, old terraced house: what they cost at the career's start.
constexpr std::array<int32_t, kEstates> kEstateBasePrice{450000, 1200000, 280000, 650000};
// Today's price of property k (0-3).
int32_t estate_price(const ModernState& g, int k);
// How many of property k the manager holds.
int estates_held(const ModernState& g, int manager, int k);
// The value of all he holds at today's prices.
int64_t estates_value(const ModernState& g, int manager);
// The rent a piece of property k pays a month.
int32_t estate_rent(const ModernState& g, int k);
// Buys or sells `count` pieces at today's price. False, with nothing changed, when the count,
// the limit, his holdings or his account (with the credit line) do not allow it.
bool buy_estate(ModernState& g, int manager, int k, int count);
bool sell_estate(ModernState& g, int manager, int k, int count);
// The month change: the prices move and the rents are paid.
void estates_month(ModernState& g);
} // namespace bmh::modern
+98
View File
@@ -0,0 +1,98 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/game/expansions.hpp"
#include <algorithm>
#include "game/schedule.hpp"
#include "modern/game/matchday.hpp"
#include "modern/game/modern_notes.hpp"
namespace bmh::modern {
namespace {
constexpr size_t kRecord = 0xb0c;
// The periphery objects of the four buildings (record +object: its state, +0x1e +object: days
// under construction); the lounge is facility 3 (+0x3c + 3 its level, +0x2c + 3 its weeks).
constexpr std::array<int, kExpansions> kObject{-1, 2, 3, 4, 5};
// What a further stage costs (times its number) and brings a month in the first league.
constexpr std::array<int32_t, kExpansions> kStagePrice{1200000, 1300000, 600000, 400000, 500000};
constexpr std::array<int32_t, kExpansions> kStageIncome{45000, 40000, 18000, 12000, 16000};
constexpr int kLeaguePercent[5] = {100, 65, 40, 25, 25};
int league_club(const ModernState& g, int manager) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || g.manager_records.size() < size_t(manager + 1) * kRecord) return -1;
const int team = g.manager_teams[size_t(manager)];
return team >= 0 && team < league_clubs() ? team : -1;
}
int extra(const ModernState& g, int manager, Expansion item) {
return manager >= 0 && size_t(manager) < g.expansions.size() ? g.expansions[size_t(manager)].stage[size_t(item)] : 0;
}
} // namespace
bool expansion_base_built(const ModernState& g, int manager, Expansion item) {
if (league_club(g, manager) < 0) return false;
const size_t rec = size_t(manager) * kRecord;
if (item == Expansion::lounge) return (g.manager_records[rec + 0x3c + 3] & 7) == 2 && g.manager_records[rec + 0x2c + 3] == 0;
const size_t object = size_t(kObject[size_t(item)]);
return g.manager_records[rec + object] != 0 && g.manager_records[rec + 0x1e + object] == 0;
}
int expansion_stage(const ModernState& g, int manager, Expansion item) {
return expansion_base_built(g, manager, item) ? 1 + extra(g, manager, item) : 0;
}
int expansion_months_left(const ModernState& g, int manager, Expansion item) {
return manager >= 0 && size_t(manager) < g.expansions.size() ? g.expansions[size_t(manager)].months[size_t(item)] : 0;
}
int32_t expansion_price(const ModernState& g, int manager, Expansion item) {
const int next = extra(g, manager, item) + 1;
return next + 1 > kExpansionStages[size_t(item)] ? 0 : kStagePrice[size_t(item)] * next;
}
int expansion_build_months(const ModernState& g, int manager, Expansion item) {
const int next = extra(g, manager, item) + 1;
return next + 1 > kExpansionStages[size_t(item)] ? 0 : 2 + next;
}
int32_t expansion_income(const ModernState& g, int manager, Expansion item) {
const int team = league_club(g, manager);
if (team < 0 || !expansion_base_built(g, manager, item)) return 0;
return kStageIncome[size_t(item)] * extra(g, manager, item) * kLeaguePercent[std::clamp(team_league(team), 0, 4)] / 100;
}
// OpenBMH deviates from the original: in Modern the V.I.P. lounge, the shopping centre, the clubhouse, the car park and the restaurant can be extended in further stages, which cost money and time and bring a monthly income.
bool start_expansion(ModernState& g, int manager, Expansion item) {
const int32_t price = expansion_price(g, manager, item);
if (!expansion_base_built(g, manager, item) || price == 0 || expansion_months_left(g, manager, item) != 0) return false;
const int months = expansion_build_months(g, manager, item);
if (!modern::book_money(g, manager, price, false, true)) return false; // as the original books building: other expenses
if (g.expansions.size() <= size_t(manager)) g.expansions.resize(size_t(manager) + 1);
g.expansions[size_t(manager)].months[size_t(item)] = uint8_t(months);
return true;
}
void expansions_month(ModernState& g) {
for (size_t m = 0; m < g.expansions.size() && m < g.manager_teams.size(); ++m) {
if (league_club(g, int(m)) < 0) continue;
auto& entry = g.expansions[m];
int64_t income = 0;
for (int k = 0; k < kExpansions; ++k) {
if (entry.months[size_t(k)] > 0 && --entry.months[size_t(k)] == 0 && entry.stage[size_t(k)] + 1 < kExpansionStages[size_t(k)]) {
++entry.stage[size_t(k)];
// the building's name of the texts: the lounge is facility 3 (text 737), the others periphery objects (720 + object)
const size_t text = k == 0 ? 737 : 720 + size_t(kObject[size_t(k)]);
if (g.texts && text < g.texts->strings.size())
post_note(g, int(m), g.texts->strings[text] + original_german(": Ausbaustufe ") + std::to_string(entry.stage[size_t(k)] + 1) + original_german(" ist fertig."));
}
income += expansion_income(g, int(m), Expansion(k));
}
if (income > 0) {
modern::book_money(g, int(m), -int32_t(income), true);
add_balance_item(g, int(m), BalanceItem::Periphery, income); // with the periphery on the balance sheet
}
}
}
} // namespace bmh::modern
+43
View File
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// Further stages of the V.I.P. lounge and of four buildings of the periphery
// (docs/new_engine/ausbaustufen.md). A Modern rule on top of the original, which knows the
// lounge and these buildings only as built or not.
//
// Once the building stands, the manager can extend it stage by stage: the lounge to four
// stages, the shopping centre and the clubhouse to three, the car park to four, the restaurant
// to two. A stage costs money and takes some months; every finished further stage brings a
// monthly income by league while the building stands. Draws no random number.
#include <array>
#include <cstdint>
#include "modern/game/modern_state.hpp"
namespace bmh::modern {
enum class Expansion : uint8_t { lounge, mall, clubhouse, parking, restaurant };
constexpr int kExpansions = 5;
constexpr std::array<uint8_t, kExpansions> kExpansionStages{4, 3, 3, 4, 2};
// Whether the building of the original stands and is not under construction.
bool expansion_base_built(const ModernState& g, int manager, Expansion item);
// The stage it has: 0 not built, 1 as the original builds it, up to kExpansionStages.
int expansion_stage(const ModernState& g, int manager, Expansion item);
// Months until the stage under construction is finished (0 = none).
int expansion_months_left(const ModernState& g, int manager, Expansion item);
// Price and building time of the next stage; 0 when there is none.
int32_t expansion_price(const ModernState& g, int manager, Expansion item);
int expansion_build_months(const ModernState& g, int manager, Expansion item);
// What its further stages bring a month now.
int32_t expansion_income(const ModernState& g, int manager, Expansion item);
// Starts the next stage and pays for it. False, with nothing changed, when the building does
// not stand, a stage is under construction, the last stage is reached or the account (with
// the credit line) cannot bear it.
bool start_expansion(ModernState& g, int manager, Expansion item);
// The month change: stages under construction get a month nearer, finished stages pay.
void expansions_month(ModernState& g);
} // namespace bmh::modern
+3
View File
@@ -2,6 +2,7 @@
#include "formats/executable_layout.hpp"
#include "modern/game/modern_state.hpp"
#include "modern/game/highscore.hpp"
#include "modern/game/estates.hpp"
#include "formats/native_state.hpp"
#include "formats/native_file.hpp"
@@ -56,6 +57,8 @@ int32_t net_assets(const ModernState& g, int m) {
}
for (uint32_t k = 0; k < 5; ++k)
sum -= g.memory.u32(::bmh::layout::Analytics_SourceAssetMaskE_RuntimeField + uint32_t(m) * 0x78 + k * 0x18);
// OpenBMH deviates from the original: Modern's four further properties count among the assets at today's prices.
sum += uint32_t(estates_value(g, m));
return signed32(sum);
}
uint32_t read32(const uint8_t* p) {
+58
View File
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/game/marketing.hpp"
#include <algorithm>
#include "game/schedule.hpp"
#include "modern/game/matchday.hpp"
#include "modern/game/modern_notes.hpp"
namespace bmh::modern {
namespace {
constexpr size_t kRecord = 0xb0c;
int league_club(const ModernState& g, int manager) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || g.manager_records.size() < size_t(manager + 1) * kRecord) return -1;
const int team = g.manager_teams[size_t(manager)];
return team >= 0 && team < league_clubs() ? team : -1;
}
} // namespace
int marketing_target(int32_t budget) { return std::clamp(int(budget / 500), 0, kMarketingReachMax); }
// OpenBMH deviates from the original: in Modern a monthly budget for international marketing builds up reach abroad, which brings monthly income by league and prestige.
int32_t marketing_income(const ModernState& g, int manager, int reach) {
const int team = league_club(g, manager);
if (team < 0 || reach <= 0) return 0;
// euros a month for a point of reach, by league
static constexpr int kValue[5] = {900, 400, 170, 70, 70};
reach = std::min(reach, kMarketingReachMax);
// every further point is worth less: the full reach counts as half of its points
const int64_t effective = reach - int64_t(reach) * reach / (2 * kMarketingReachMax);
const int prestige = g.manager_records[size_t(manager) * kRecord + 0x211];
return int32_t(effective * kValue[std::clamp(team_league(team), 0, 4)] * (60 + prestige * 4 / 5) / 100);
}
bool set_marketing_budget(ModernState& g, int manager, int32_t budget) {
if (league_club(g, manager) < 0 || budget < 0 || budget > kMarketingBudgetMax || budget % 1000) return false;
if (g.marketing.size() <= size_t(manager)) g.marketing.resize(size_t(manager) + 1);
g.marketing[size_t(manager)].budget = budget;
return true;
}
void marketing_month(ModernState& g) {
for (size_t m = 0; m < g.marketing.size() && m < g.manager_teams.size(); ++m) {
auto& entry = g.marketing[m];
if (league_club(g, int(m)) < 0 || (entry.budget == 0 && entry.reach == 0)) continue;
const bool paid = entry.budget > 0 && modern::book_money(g, int(m), entry.budget, false);
if (paid) add_balance_item(g, int(m), BalanceItem::PublicRelations, entry.budget); // the budget is public relations on the balance sheet
const int target = paid ? marketing_target(entry.budget) : 0;
if (target > entry.reach) entry.reach = uint16_t(entry.reach + std::max(1, (target - entry.reach) / 6));
else if (target < entry.reach) entry.reach = uint16_t(entry.reach - std::max(1, (entry.reach - target) / 4));
if (const int32_t income = marketing_income(g, int(m), entry.reach); income > 0) modern::book_money(g, int(m), -income, true, true); // other income on the balance sheet
}
}
} // namespace bmh::modern
+33
View File
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// International marketing (docs/new_engine/vermarktung.md). A Modern rule; Classic has none.
//
// A manager sets a monthly budget for making his club known abroad. The budget buys reach:
// every month the reach moves a sixth of the way towards what the budget can hold, and falls a
// quarter of the way when the budget is cut. Reach brings income every month - more in a higher
// league and with more prestige, and less for every further step of reach. It is an investment
// that pays after about a year and only for clubs of the upper leagues. Draws no random number.
#include <cstdint>
#include "modern/game/modern_state.hpp"
namespace bmh::modern {
constexpr int32_t kMarketingBudgetMax = 500000; // euros a month: the budget that holds the full reach
constexpr int kMarketingReachMax = 1000; // per mille
// The reach a budget can hold: a point for every 500 euros.
int marketing_target(int32_t budget);
// What the reach brings a month for the manager's club now (league, prestige).
int32_t marketing_income(const ModernState& g, int manager, int reach);
// Sets the monthly budget (0 to kMarketingBudgetMax in whole thousands). False, with nothing
// changed, for a manager without a league club or another amount.
bool set_marketing_budget(ModernState& g, int manager, int32_t budget);
// The month change: the budget is paid (not when the account cannot bear it - then the month
// counts as one without budget), the reach moves, and the reach pays.
void marketing_month(ModernState& g);
} // namespace bmh::modern
+60
View File
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// What Modern's own rules (naming rights, marketing, properties, stages) share with the
// original's bookkeeping: the items of the balance sheet and notes in the manager's mailbox.
#include <cstdint>
#include <string>
#include <string_view>
#include "game/messages.hpp"
#include "modern/game/modern_state.hpp"
namespace bmh::modern {
// The 18 items of a manager's balance sheet (record +0x85c, a dword each): seven kinds of
// income, then the expenses. book_money with its statistics flag fills OtherIncome and
// OtherExpense itself.
enum class BalanceItem : uint8_t {
ShirtAdvertising, BoardAdvertising, Television, Crowd, Periphery, RentAndInterest, OtherIncome,
Salaries, StadiumCosts, Academy, AssistantCoach, Doctor, Physio, TrainingCamps, Supporters, PublicRelations,
InterestAndRepayment, OtherExpense
};
// Adds an amount to an item of the manager's balance sheet. As in the original, the easiest
// level, which books no money, keeps no figures either.
inline void add_balance_item(ModernState& g, int manager, BalanceItem item, int64_t amount) {
if (g.level == 0 || manager < 0 || amount <= 0) return;
const size_t at = size_t(manager) * 0xb0c + 0x85c + size_t(item) * 4;
if (at + 4 > g.manager_records.size()) return;
uint32_t value = 0;
for (int i = 0; i < 4; ++i) value |= uint32_t(g.manager_records[at + size_t(i)]) << (8 * i);
value += uint32_t(amount);
for (int i = 0; i < 4; ++i) g.manager_records[at + size_t(i)] = uint8_t(value >> (8 * i));
}
// German text of the source code (UTF-8) in the single-byte form of the original's texts.
inline std::string original_german(std::string_view utf8) {
static constexpr std::pair<std::string_view, char> kLetters[] = {{"ä", '{'}, {"ö", '|'}, {"ü", '}'}, {"ß", '~'}, {"Ä", '['}, {"Ö", '\\'}, {"Ü", ']'}};
std::string out;
for (size_t i = 0; i < utf8.size();) {
bool found = false;
for (const auto& [letter, byte] : kLetters)
if (utf8.substr(i, letter.size()) == letter) {
out += byte, i += letter.size(), found = true;
break;
}
if (found) continue;
const unsigned char c = static_cast<unsigned char>(utf8[i++]);
out += c < 128 ? char(c) : '?';
}
return out;
}
// A note in the manager's mailbox. `text` is already in the original's form (original_german,
// names and amounts of the engine); the mailbox keeps its first 149 bytes.
inline void post_note(ModernState& g, int manager, const std::string& text) {
if (manager >= 0) post_composed(g, manager, text.substr(0, 149));
}
} // namespace bmh::modern
+23
View File
@@ -149,6 +149,29 @@ struct ModernState : GameState {
bool operator==(const StadiumName&) const = default;
};
std::vector<StadiumName> stadiums;
// International marketing (docs/new_engine/vermarktung.md), per manager slot: the monthly
// budget in euros and the reach it has built up so far, in per mille.
struct Marketing {
int32_t budget = 0;
uint16_t reach = 0;
bool operator==(const Marketing&) const = default;
};
std::vector<Marketing> marketing;
// Shirt numbers (docs/new_engine/rueckennummern.md) by player: 1-99, 0 = none yet.
std::vector<uint8_t> shirt_numbers;
// Four further properties of the bank (docs/new_engine/immobilien.md): what each manager
// holds of them, and today's prices (0 = the starting price).
std::vector<std::array<uint16_t, 4>> estates;
std::array<uint32_t, 4> estate_prices{};
// Further stages of the lounge and four buildings of the periphery
// (docs/new_engine/ausbaustufen.md), per manager slot and item (lounge, shopping centre,
// clubhouse, car park, restaurant): the further stages finished, and the months until the
// stage under construction is finished (0 = none).
struct Expansions {
std::array<uint8_t, 5> stage{}, months{};
bool operator==(const Expansions&) const = default;
};
std::vector<Expansions> expansions;
// Whether a manager the meeting votes out has to leave his club. On until the options offer it.
bool dismissals = true;
// Players whose age the data set gives (birth date); the others carry a placeholder the
+6
View File
@@ -5,6 +5,9 @@
#include "modern/game/environment.hpp"
#include "modern/game/month.hpp"
#include "modern/game/naming_rights.hpp"
#include "modern/game/marketing.hpp"
#include "modern/game/estates.hpp"
#include "modern/game/expansions.hpp"
#include "modern/game/desk_actions.hpp"
#include "game/trace.hpp"
@@ -949,6 +952,9 @@ void search_profile_news(ModernState& g, int manager, uint32_t list, int player)
void month_change(ModernState& g, WatcomRandom& rand, MinuteReport& report, GameRandom* game) {
modern::naming_rights_month(g); // Modern: the stadium sponsors pay (naming_rights.hpp)
modern::marketing_month(g); // Modern: international marketing costs and pays (marketing.hpp)
modern::estates_month(g); // Modern: the four further properties move and pay rent (estates.hpp)
modern::expansions_month(g); // Modern: further stages of lounge and periphery are built and pay (expansions.hpp)
StaticMemory& mem = g.memory;
std::vector<uint8_t>& r = g.manager_records;
const int managers = int(g.manager_teams.size());
+20 -2
View File
@@ -5,7 +5,9 @@
#include "game/random.hpp"
#include "game/schedule.hpp"
#include "formats/executable_layout.hpp"
#include "modern/game/matchday.hpp"
#include "modern/game/modern_notes.hpp"
namespace bmh::modern {
namespace {
@@ -18,6 +20,13 @@ int league_club(const ModernState& g, int manager) {
return team >= 0 && team < league_clubs() ? team : -1;
}
// The sponsor's name as the advertising list has it ("" where the texts are not loaded).
std::string sponsor_name(const ModernState& g, int sponsor) {
try {
return message_text(g, ::bmh::layout::Advertising_FormatError_ExecutableField3 + uint32_t(sponsor) * 4);
} catch (const std::exception&) { return {}; }
}
} // namespace
const ModernState::StadiumName* stadium_entry(const ModernState& g, int manager) {
@@ -78,6 +87,10 @@ bool sell_naming_rights(ModernState& g, int manager, int index) {
if (g.stadiums.size() <= size_t(manager)) g.stadiums.resize(size_t(manager) + 1);
auto& entry = g.stadiums[size_t(manager)];
entry.sponsor = offers[size_t(index)].sponsor, entry.monthly = offers[size_t(index)].monthly, entry.months = offers[size_t(index)].months;
if (const std::string sponsor = sponsor_name(g, entry.sponsor); !sponsor.empty()) try {
post_note(g, manager, original_german("Namensrecht: Das Stadion heißt jetzt ") + sponsor + original_german("-Arena. ") + sponsor + original_german(" zahlt ") +
format_amount(g, int32_t(entry.monthly)) + original_german(" im Monat, ") + std::to_string(entry.months) + " Monate lang.");
} catch (const std::exception&) {} // (a state without the texts: no note)
return true;
}
@@ -85,8 +98,13 @@ void naming_rights_month(ModernState& g) {
for (size_t m = 0; m < g.stadiums.size() && m < g.manager_teams.size(); ++m) {
auto& entry = g.stadiums[m];
if (entry.months == 0) continue;
if (league_club(g, int(m)) >= 0) modern::book_money(g, int(m), -int32_t(entry.monthly), true);
if (--entry.months == 0) entry.sponsor = 0xff, entry.monthly = 0;
// the payment counts as other income on the balance sheet
if (league_club(g, int(m)) >= 0) modern::book_money(g, int(m), -int32_t(entry.monthly), true, true);
if (--entry.months == 0) {
if (const std::string sponsor = sponsor_name(g, entry.sponsor); !sponsor.empty())
post_note(g, int(m), original_german("Der Namensvertrag mit ") + sponsor + original_german(" ist ausgelaufen. Das Stadion trägt wieder seinen eigenen Namen."));
entry.sponsor = 0xff, entry.monthly = 0;
}
}
}
+62
View File
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/game/shirt_numbers.hpp"
#include <array>
namespace bmh::modern {
// OpenBMH deviates from the original: in Modern every player keeps a shirt number from 1 to 99, unique within his squad, which the manager of a club can change.
std::vector<int> squad_shirt_numbers(const ModernState& g, int team) {
const SquadRange range = squad_range(team);
std::vector<int> numbers(range.count, 0);
std::array<bool, 100> taken{};
const auto player_at = [&](size_t row) {
const size_t slot = range.first + row;
const int player = slot < g.squad_slots.size() ? g.squad_slots[slot] & 0x0fff : 0x0fff;
return player == 0x0fff || size_t(player) >= g.players.size() ? -1 : player;
};
for (size_t row = 0; row < range.count; ++row) {
const int player = player_at(row);
const int kept = player >= 0 && size_t(player) < g.shirt_numbers.size() ? g.shirt_numbers[size_t(player)] : 0;
if (kept >= 1 && kept <= 99 && !taken[size_t(kept)]) numbers[row] = kept, taken[size_t(kept)] = true;
}
int next = 1;
for (size_t row = 0; row < range.count; ++row) {
if (player_at(row) < 0 || numbers[row] != 0) continue;
while (next < 99 && taken[size_t(next)]) ++next;
numbers[row] = next, taken[size_t(next)] = true;
}
return numbers;
}
void fix_shirt_numbers(ModernState& g, int team) {
const SquadRange range = squad_range(team);
const std::vector<int> numbers = squad_shirt_numbers(g, team);
for (size_t row = 0; row < numbers.size(); ++row) {
if (numbers[row] == 0) continue;
const size_t player = g.squad_slots[range.first + row] & 0x0fff;
if (g.shirt_numbers.size() <= player) g.shirt_numbers.resize(g.players.size(), 0);
if (player < g.shirt_numbers.size()) g.shirt_numbers[player] = uint8_t(numbers[row]);
}
}
bool set_shirt_number(ModernState& g, int manager, int player, int number) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || number < 1 || number > 99 || player < 0) return false;
const int team = g.manager_teams[size_t(manager)];
if (team < 0 || team >= league_clubs()) return false;
const SquadRange range = squad_range(team);
const std::vector<int> numbers = squad_shirt_numbers(g, team);
int own_row = -1, other_row = -1;
for (size_t row = 0; row < numbers.size(); ++row) {
if (numbers[row] == 0) continue;
if (int(g.squad_slots[range.first + row] & 0x0fff) == player) own_row = int(row);
else if (numbers[row] == number) other_row = int(row);
}
if (own_row < 0) return false;
fix_shirt_numbers(g, team);
if (other_row >= 0) g.shirt_numbers[g.squad_slots[range.first + size_t(other_row)] & 0x0fff] = uint8_t(numbers[size_t(own_row)]);
g.shirt_numbers[size_t(player)] = uint8_t(number);
return true;
}
} // namespace bmh::modern
+28
View File
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// Shirt numbers (docs/new_engine/rueckennummern.md). A Modern rule; Classic numbers a team
// 1 to 11 by its place on the board.
//
// Every player keeps a number from 1 to 99 (ModernState::shirt_numbers, 0 = none yet). Within
// a squad a number is worn once. A player without a number, or whose number another player of
// the squad already wears, gets the lowest free one. Draws no random number.
#include <vector>
#include "modern/game/modern_state.hpp"
namespace bmh::modern {
// The numbers the squad of a club wears, by squad row (0 for an empty row): the kept numbers
// first come first served in row order, the lowest free numbers for everybody else.
std::vector<int> squad_shirt_numbers(const ModernState& g, int team);
// Writes the numbers of squad_shirt_numbers into the players, so they stay when rows change.
void fix_shirt_numbers(ModernState& g, int team);
// Gives a player of the manager's club the number (1-99). The player who wore it takes the
// other's number. False, with nothing changed, for a player who is not in the squad or a
// number out of range.
bool set_shirt_number(ModernState& g, int manager, int player, int number);
} // namespace bmh::modern
+24 -4
View File
@@ -159,8 +159,24 @@ std::string App::render_advertising() {
use += "<div class=\"ad-use\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><span>" + esc(row.at("name").get<std::string>()) + "</span><span class=\"pg-mut\">" +
esc(limit > 0 ? std::to_string(int(std::lround(share))) + " % von " + ad_cash(limit) : amount) + "</span></div>" + pg_bar(share, i == 0 ? "soft" : i == 1 ? "accent" : "sage") + "</div>";
}
out += tile("ad-soon", "ad-spending-international", soon, "investment.scene.international", "Internationale Vermarktung", "Neu", "Noch nicht im Spiel", "Diese Investition folgt", false, "big", "—") + "</div><div class=\"pg-col pg-grow\"><div class=\"pg-panel pg-col\" style=\"" +
pg_css("gap:4px;") + "\">" + pg_kicker("Investitionen") + rows + "<div class=\"pg-kv\"><span>Internationale Vermarktung</span><strong class=\"pg-mut\">folgt</strong></div>" +
// international marketing: a monthly budget that builds up reach abroad, and what the reach brings
Json abroad;
if (engine_mode_) try { abroad = engine_data_.at("advertising").at("data").at("internationalMarketing"); } catch (const std::exception &) {}
const auto euros = [](const Json &money) { try { return std::stoll(money.at("minor").get<std::string>()); } catch (const std::exception &) { return 0LL; } }; // (ad_cash takes cents)
std::string abroad_rows = "<div class=\"pg-kv\"><span>Internationale Vermarktung</span><strong class=\"pg-mut\">folgt</strong></div>";
if (abroad.is_object()) {
const auto budget = ad_cash(euros(abroad.at("budget")));
const int reach = abroad.value("reach", 0), target = abroad.value("targetReach", 0);
out += tile("ad-marketing", "ad-spending-international", "", "investment.scene.international", "Internationale Vermarktung", "Monatsbudget", budget,
"Reichweite " + std::to_string(reach / 10) + " % · bringt " + ad_cash(euros(abroad.at("income"))) + " im Monat", false, "big", budget) + "</div>";
abroad_rows = "<div class=\"pg-kv\"><span>Internationale Vermarktung</span><strong>" + esc(budget) + " / Monat</strong></div><div class=\"pg-kv\"><span>Reichweite im Ausland</span><strong>" + std::to_string(reach / 10) + " % · Ziel " +
std::to_string(target / 10) + " %</strong></div><div class=\"pg-kv\"><span>Einnahmen daraus</span><strong class=\"ad-plus\">" + esc(ad_cash(euros(abroad.at("income")))) + " / Monat</strong></div>";
use += "<div class=\"ad-use\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><span>Reichweite im Ausland</span><span class=\"pg-mut\">" + std::to_string(reach / 10) + " % · am Ziel " +
esc(ad_cash(euros(abroad.at("incomeAtTarget")))) + " im Monat</span></div>" + pg_bar(reach / 10.0, "accent") + "</div>";
} else
out += tile("ad-soon", "ad-spending-international", soon, "investment.scene.international", "Internationale Vermarktung", "Neu", "Noch nicht im Spiel", "Diese Investition folgt", false, "big", "—") + "</div>";
out += "<div class=\"pg-col pg-grow\"><div class=\"pg-panel pg-col\" style=\"" +
pg_css("gap:4px;") + "\">" + pg_kicker("Investitionen") + rows + abroad_rows +
(delivery.empty() ? std::string() : "<span class=\"pg-tag accent\" style=\"align-self:flex-start;margin-top:" + pg(6) + ";\">" + esc(delivery) + "</span>") + "</div><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:4px;") + "\">" + pg_kicker("Vereinsprognose / Monat") + "<div class=\"pg-kv\"><span>Einnahmen</span><strong>" + esc(ad_cash(view.at("income").get<int64_t>())) +
"</strong></div><div class=\"pg-kv\"><span>Ausgaben</span><strong>" + esc(ad_cash(view.at("expenses").get<int64_t>())) + "</strong></div><div class=\"pg-kv\"><span>Saldo</span><strong class=\"" + (view.at("balance").get<int64_t>() >= 0 ? "ad-plus" : "ad-minus") + "\">" +
esc((view.at("balance").get<int64_t>() > 0 ? "+ " : "") + ad_cash(view.at("balance").get<int64_t>())) + "</strong></div></div>";
@@ -174,7 +190,11 @@ std::string App::render_advertising() {
} else lines.push_back("Presse und Fans bekommen gerade nichts!");
lines.push_back(!delivery.empty() ? "Fanartikel sind unterwegs – abwarten." : merchandise > 0 ? "Fanartikel zuletzt bestellt für " + ad_cash(merchandise) + "." : "Fanshop leer. Nachbestellen?");
if (view.at("balance").get<int64_t>() < 0) lines.push_back("Achtung: Der Monat schließt im Minus.");
lines.push_back("Ausland: kommt noch.");
if (!abroad.is_object()) lines.push_back("Ausland: kommt noch.");
else if (abroad.value("targetReach", 0) == 0 && abroad.value("reach", 0) == 0) lines.push_back("Ausland: noch kein Budget.");
else if (abroad.value("reach", 0) < abroad.value("targetReach", 0)) lines.push_back("Ausland: Die Reichweite wächst noch.");
else if (abroad.value("reach", 0) > abroad.value("targetReach", 0)) lines.push_back("Ausland: Die Reichweite schwindet!");
else lines.push_back("Ausland: Reichweite am Ziel.");
out += "<div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:8px;") + "\">" + pg_kicker("Auslastung der Budgets") + use + "</div><span class=\"pg-sp\"></span><div class=\"ad-memo\"><span class=\"ad-memo-tape\"></span><strong>Merkzettel</strong>";
for (const auto &line : lines) out += "<span>" + esc(line) + "</span>";
out += "</div></div>";
@@ -213,7 +233,7 @@ std::string App::render_advertising() {
const Json sold = ground.value("namingRights", Json());
out += tile("ad-naming", "ad-contract-naming", "", "advertising.scene.arena", "Namensrecht Stadion", sold.is_object() ? "Namensgeber" : "Name frei",
ground.value("name", std::string("Stadion")),
sold.is_object() ? ad_cash(std::stoll(sold.at("monthly").value("minor", std::string("0"))) / 100) + " monatlich · noch " + std::to_string(sold.value("monthsLeft", 0)) + " Monate" : std::string("Anklicken für Angebote"), false, "four") + "</div>";
sold.is_object() ? ad_cash(std::stoll(sold.at("monthly").value("minor", std::string("0")))) + " monatlich · noch " + std::to_string(sold.value("monthsLeft", 0)) + " Monate" : std::string("Anklicken für Angebote"), false, "four") + "</div>";
} else
out += tile("ad-soon", "ad-contract-naming", soon, "advertising.scene.arena", "Namensrecht Stadion", "Neu", "Noch nicht im Spiel", "Dieser Vertrag folgt", false, "four") + "</div>";
}
+1 -1
View File
@@ -8,7 +8,7 @@ bool App::bank_action(const std::string &action, Rml::Element *target) {
if (action == "bank-property" && target) {
// a house on the board is chosen: it is the one bought and sold
const auto index = target->GetAttribute<int>("data-id", -1);
if (bank_view_ != "properties" || index < 0 || index > 5) return true;
if (bank_view_ != "properties" || index < 0 || index > 9) return true;
bank_property_ = bank_owned_ = index;
focus_after_render_ = "bank-property-" + std::to_string(index);
refresh();
+1 -1
View File
@@ -146,7 +146,7 @@ std::string App::render_bank() {
const auto price = offer.at("price").get<int64_t>();
out += "</div><div class=\"pg-row pg-grow\" style=\"align-items:stretch;\"><div class=\"pg-panel pg-row pg-grow\" style=\"" + pg_css("gap:22px;padding:10px 16px;") + "\"><div style=\"width:" + pg(300) + ";\">" + pg_kicker("Ausgewählt") +
"<h3 class=\"pg-h\" style=\"font-size:" + pg(24) + ";line-height:" + pg(30) + ";\">" + esc(calm_name(offer.at("name").get<std::string>())) + "</h3><strong class=\"pg-big\">" + esc(bank_money(price)) + "</strong></div><div class=\"pg-grow\">" +
kv("Im Bestand", number(held) + " Stück") + kv("Wert heute", esc(bank_money(held * price))) + kv("Anteil am Konto", in_cash > 0 ? one(price * 100.0 / in_cash) + " %" : std::string("—")) +
kv("Im Bestand", number(held) + " Stück") + kv("Wert heute", esc(bank_money(held * price))) + (offer.contains("rent") ? kv("Miete je Stück", esc(bank_money(offer.at("rent").get<int64_t>())) + " / Monat") : std::string()) + kv("Anteil am Konto", in_cash > 0 ? one(price * 100.0 / in_cash) + " %" : std::string("—")) +
(offer.contains("maxToBuy") ? kv("Bezahlbar", number(offer.at("maxToBuy").get<int64_t>()) + " Stück") : kv("Auf dem Konto", esc(bank_money(in_cash)))) + "</div></div><div class=\"pg-col\" style=\"width:" + pg(300) + ";flex:none;justify-content:center;" + pg_css("gap:8px;") + "\">" +
calc("Kaufen", "property-buy", "primary bk-wide") + calc("Verkaufen", "property-sell", "bk-wide", held > 0) + "<span class=\"pg-mut\" style=\"display:block;text-align:center;font-size:" + pg(12.5) + ";\">Ein Haus am Brett anklicken, dann kaufen oder verkaufen.</span></div></div>";
} else if (bank_view_ == "stocks") {
+34
View File
@@ -255,3 +255,37 @@ void App::engine_assembly_choose(const std::string &team) {
popup_title_ = "Vereinswechsel";
popup_accept_ = "Wechseln";
}
// Shirt numbers: what the squad read says a player wears.
std::string App::engine_shirt(const std::string &player, size_t fallback) const {
if (engine_mode_) try {
for (const auto &row : engine_data_.at("squad").at("data").at("players"))
if (row.at("player").at("id") == player && row.at("player").at("shirtNumber").is_number_integer()) return std::to_string(row.at("player").at("shirtNumber").get<int>());
} catch (const std::exception &) {}
return std::to_string(fallback);
}
std::string App::engine_shirt_at(size_t place) const {
if (engine_mode_) try {
const auto &rows = engine_data_.at("squad").at("data").at("players");
if (place < rows.size() && rows[place].at("player").at("shirtNumber").is_number_integer()) return std::to_string(rows[place].at("player").at("shirtNumber").get<int>());
} catch (const std::exception &) {}
return std::to_string(place + 1);
}
// The next stage of the lounge or of a building of the periphery: what it costs, then the order.
void App::engine_expansion_ask(const std::string &expansion) {
std::string name, terms;
try {
for (const auto &row : engine_data_.at("stadium").at("data").at("expansions"))
if (row.value("id", std::string()) == expansion && !row.at("nextPrice").is_null() && row.value("available", false)) {
name = row.value("name", std::string());
terms = engine_price(row.at("nextPrice")) + ", " + std::to_string(row.value("nextMonths", 0)) + " Monate Bauzeit";
}
} catch (const std::exception &) {}
if (name.empty()) return;
confirmation(name + " um eine Stufe ausbauen? (" + terms + ")", [this, expansion] {
try {
engine_finance_submit(engine_expansion_command(engine_data_, expansion, editor::new_id("request:ui-")));
} catch (const std::exception &e) { message(e.what()); }
});
popup_title_ = "Ausbau";
popup_accept_ = "Ausbauen";
}
+6
View File
@@ -32,6 +32,12 @@ Json engine_ticket_command(const Json &bundle, int euros, const std::string &req
Json engine_environment_projection(const Json &bundle);
Json engine_environment_command(const Json &bundle, const std::string &item, int level, const std::string &request_id);
// The next stage of the lounge or of a building of the periphery (read "stadium", expansions).
Json engine_expansion_command(const Json &bundle, const std::string &expansion, const std::string &request_id);
// A player of the squad gets the shirt number 1-99.
Json engine_shirt_number_command(const Json &bundle, const std::string &player, int number, const std::string &request_id);
// The monthly budget for international marketing (read "advertising", internationalMarketing).
Json engine_marketing_command(const Json &bundle, int64_t euros, const std::string &request_id);
// The manager names his stadium, or sells its name to the sponsor of an offer (read "stadium").
Json engine_stadium_rename_command(const Json &bundle, const std::string &name, const std::string &request_id);
Json engine_naming_rights_command(const Json &bundle, const std::string &offer, const std::string &request_id);
+17
View File
@@ -15,6 +15,23 @@ bool App::engine_commerce_action(const std::string &action, Rml::Element *target
}
if (!action.starts_with("ad-") || menu_ != "advertising") return false;
const auto view = engine_advertising_projection(engine_data_);
if (action == "ad-marketing" && engine_fresh_ && !engine_busy_) {
Json abroad;
try { abroad = engine_data_.at("advertising").at("data").at("internationalMarketing"); } catch (const std::exception &) { return true; }
const auto euros = [](const Json &money) { try { return std::stoll(money.at("minor").get<std::string>()) / 100; } catch (const std::exception &) { return 0LL; } };
const auto meta = engine_data_.at("desktop").at("meta");
AmountRequest request;
request.title = "Internationale Vermarktung";
request.review_text = [](int64_t) { return "Monatliches Budget. Die Reichweite wächst und fällt über Monate; sie bringt Einnahmen nach Liga und Ansehen."; };
request.unit = "€";
request.value = euros(abroad.at("budget")); request.min = 0; request.max = euros(abroad.at("maxBudget"));
request.step = 1000; request.suggestion_step = 50000; request.review = true;
request.accept = [this, meta](int64_t value) {
if (engine_busy_ || !engine_fresh_ || menu_ != "advertising" || meta != engine_data_.at("desktop").at("meta")) return false;
engine_finance_submit(engine_marketing_command(engine_data_, value / 1000 * 1000, editor::new_id("request:ui-"))); return true;
};
open_amount(std::move(request)); return true;
}
if (action == "ad-naming" && engine_fresh_ && !engine_busy_) {
Json ground;
try { ground = engine_data_.at("stadium").at("data"); } catch (const std::exception &) { return true; }
+20 -1
View File
@@ -481,6 +481,7 @@ void App::engine_event(Rml::Event &event) {
const auto action = node->GetAttribute<Rml::String>("data-action", ""), id = node->GetAttribute<Rml::String>("data-id", "");
if (!popup_.empty()) {
if(action=="balance-discard"){engine_balance_action(action,node);return;}
if (action == "expansion-start") { const std::string expansion = id; popup_.clear(); reset_popup(); confirm_ = {}; dirty_ = true; engine_expansion_ask(expansion); return; }
if (action == "naming-accept") {
const std::string offer = id;
std::string name, terms;
@@ -521,7 +522,25 @@ void App::engine_event(Rml::Event &event) {
if (action == "popup-confirm") { auto callback=std::move(confirm_);auto text_callback=std::move(text_accept_);const auto text=field("popup-text");popup_.clear();reset_popup();dirty_=true;if(text_callback)text_callback(text);else if(callback)callback(); }
return;
}
if (engine_assembly_open_) { engine_assembly_action(action, id); return; } // the sheet of the interested clubs lies over everything
if (engine_assembly_open_) { engine_assembly_action(action, id); return; }
if (action == "expansion-start" && engine_fresh_ && !engine_busy_) { engine_expansion_ask(id); return; } // from the card of a building
if (action == "lineup-number" && engine_fresh_ && !engine_busy_ && menu_ == "lineup") {
// a new shirt number for the player; whoever wears it takes his
const std::string player = id;
const auto meta = engine_data_.at("desktop").at("meta");
AmountRequest request;
request.title = "Rückennummer";
request.review_text = [](int64_t) { return "Trägt schon ein anderer Spieler die Nummer, tauschen die beiden."; };
request.unit = "";
try { request.value = std::stoll(engine_shirt(player, 1)); } catch (const std::exception &) { request.value = 1; }
request.min = 1; request.max = 99; request.step = 1; request.suggestion_step = 1; request.review = false;
request.accept = [this, meta, player](int64_t value) {
if (engine_busy_ || !engine_fresh_ || meta != engine_data_.at("desktop").at("meta")) return false;
try { engine_finance_submit(engine_shirt_number_command(engine_data_, player, int(value), editor::new_id("request:ui-"))); } catch (const std::exception &) { return false; }
return true;
};
open_amount(std::move(request)); return;
} // the sheet of the interested clubs lies over everything
if (action == "engine-widget-warning" && menu_.empty() && !engine_busy_) {
const auto rows = engine_widgets_projection(engine_data_).at("warnings");
std::string text;
+12 -2
View File
@@ -378,12 +378,12 @@ Json engine_bank_projection(const Json &bundle) {
const bool stock = std::string(key) == "stocks";
const auto dest = stock ? "stocks" : "properties";
const auto &rows = data.at(key);
require(rows.is_array() && !rows.empty() && rows.size() <= size_t(stock ? 12 : 6), "Ungültiger Bankkatalog.");
require(rows.is_array() && !rows.empty() && rows.size() <= size_t(stock ? 12 : 10), "Ungültiger Bankkatalog."); // six properties of the original, four of Modern
std::set<std::string> ids;
for (const auto &row : rows) {
const auto id = row.at("id").get<std::string>();
bool known = false;
for (int i = 0; i < (stock ? 12 : 6); ++i) known |= id == std::string(stock ? "stock:" : "fund:") + std::to_string(i);
for (int i = 0; i < (stock ? 12 : 10); ++i) known |= id == std::string(stock ? "stock:" : "fund:") + std::to_string(i);
require(known && ids.insert(id).second, "Unbekannte oder doppelte Bankanlage.");
const auto price = engine_money_minor(row.at("price"));
const int owned = whole_in_range(row.at("owned"), 0, 65535), max = whole_in_range(row.at("maxToBuy"), 0, 99999999);
@@ -402,6 +402,7 @@ Json engine_bank_projection(const Json &bundle) {
stocks += price * owned;
} else {
item["image"] = "bank.property." + id.substr(5);
if (row.contains("monthlyRent")) item["rent"] = engine_money_minor(row.at("monthlyRent"));
properties += price * owned;
}
assets[dest].push_back(item); finance[dest].push_back(owned);
@@ -513,6 +514,15 @@ Json engine_environment_projection(const Json &bundle) {
}
return {{"ok", true}, {"rows", rows}};
}
Json engine_expansion_command(const Json &bundle, const std::string &expansion, const std::string &request_id) {
return sports_command(bundle, "stadium.expand", {{"expansionId", expansion}, {"confirmed", true}}, request_id);
}
Json engine_shirt_number_command(const Json &bundle, const std::string &player, int number, const std::string &request_id) {
return sports_command(bundle, "lineup.setNumber", {{"playerId", player}, {"number", number}}, request_id);
}
Json engine_marketing_command(const Json &bundle, int64_t euros, const std::string &request_id) {
return sports_command(bundle, "marketing.commit", {{"budget", {{"currency", "EUR"}, {"minorUnits", 2}, {"minor", std::to_string(euros * 100)}}}}, request_id);
}
Json engine_stadium_rename_command(const Json &bundle, const std::string &name, const std::string &request_id) {
return sports_command(bundle, "stadium.rename", {{"name", name}}, request_id);
}
+16
View File
@@ -76,6 +76,20 @@ Json engine_stadium_projection(const Json &bundle, bool future) {
super =
super && (future ? target : current) == b.at("maxPlaces").get<int64_t>() && seats && roof;
}
// the further stages of Modern (read stadium, expansions), by the object they belong to
const auto staged = [&](Json &row, const std::string &object) {
if (!d.contains("expansions")) return;
for (const auto &e : d.at("expansions")) {
if (e.value("objectId", std::string()) != object) continue;
const int left = e.value("monthsLeft", 0);
row["stage"] = e.value("stage", 0);
row["stages"] = e.value("maxStage", 1);
row["expanding"] = left > 0;
row["expansion"] = {{"id", e.value("id", std::string())}, {"months_left", left}, {"available", e.value("available", false)},
{"income", engine_money_minor(e.at("monthlyIncome"))},
{"price", e.at("nextPrice").is_null() ? Json() : Json(engine_money_minor(e.at("nextPrice")))}, {"months", e.value("nextMonths", Json())}};
}
};
for (size_t i = 0; i < 8; ++i) {
const auto &f = d.at("facilities")[i];
const int level = f.at("level"), weeks = f.at("constructionWeeks"),
@@ -97,6 +111,7 @@ Json engine_stadium_projection(const Json &bundle, bool future) {
{"building", weeks > 0},
{"available", f.at("upgradeAvailable")},
{"job", weeks > 0 ? Json{{"level", target}, {"weeks", weeks}} : Json()}});
staged(facilities.back(), f.at("id").get<std::string>());
}
for (size_t i = 0; i < 14; ++i) {
const auto &p = d.at("periphery")[i];
@@ -114,6 +129,7 @@ Json engine_stadium_projection(const Json &bundle, bool future) {
{"display_level", future && busy ? target : level},
{"building", busy},
{"job", busy ? Json{{"level", target}, {"weeks", days}} : Json()}});
staged(periphery.back(), p.at("id").get<std::string>());
}
return {{"ok", true},
{"club", d.at("teamId")},
+24
View File
@@ -217,6 +217,30 @@ bool App::engine_stadium_action(const std::string &action, Rml::Element *target)
refresh();
return true;
}
if (action == "stadium-expansions" && engine_fresh_ && !engine_busy_) {
// the further stages of the lounge and of four buildings: where each stands and what the next costs
Json rows;
try { rows = engine_data_.at("stadium").at("data").at("expansions"); } catch (const std::exception &) { return true; }
std::string body = "<div class=\"po-offers\">";
for (const auto &row : rows) {
const std::string id = row.value("id", std::string());
const int stage = row.value("stage", 0), most = row.value("maxStage", 1), left = row.value("monthsLeft", 0);
std::string state = stage == 0 ? "noch nicht gebaut" : "Stufe " + std::to_string(stage) + " von " + std::to_string(most);
if (stage > 1) state += " · bringt " + engine_price(row.at("monthlyIncome")) + " im Monat";
const std::string next = left > 0 ? "Die nächste Stufe ist in " + std::to_string(left) + (left == 1 ? " Monat fertig" : " Monaten fertig")
: stage == 0 ? std::string("Erst bauen, dann ausbauen")
: row.at("nextPrice").is_null() ? std::string("Fertig ausgebaut")
: "Nächste Stufe: " + engine_price(row.at("nextPrice")) + " · " + std::to_string(row.value("nextMonths", 0)) + " Monate Bauzeit";
body += "<div class=\"po-offer\"><div class=\"po-text\"><strong>" + esc(row.value("name", std::string())) + "</strong><span>" + esc(state) + "</span><span>" + esc(next) + "</span></div>" +
pg_button("expansion-start", "Ausbauen", "primary", "id=\"expansion-start-" + esc(id) + "\" data-id=\"" + esc(id) + "\" " + std::string(row.value("available", false) ? "" : "disabled=\"disabled\"")) + "</div>";
}
body += "</div>";
message("Die Lounge und vier Gebäude der Peripherie lassen sich in Stufen ausbauen. Jede weitere Stufe kostet Geld und Bauzeit und bringt danach jeden Monat Einnahmen.");
popup_title_ = "Ausbaustufen";
popup_close_ = "Schließen";
popup_body_ = body;
return true;
}
if (action == "stadium-rename" && engine_fresh_ && !engine_busy_) {
Json data;
try { data = engine_data_.at("stadium").at("data"); } catch (const std::exception &) { return true; }
+7 -2
View File
@@ -53,7 +53,12 @@ std::string App::render_lineup_page() {
size_t field = 0;
for (const auto &column : columns) {
const std::string key = column.key;
if (std::string(column.label) == "Nr.") { out += pg_td(slot < field_count ? std::to_string(slot + 1) : std::string("–"), column.width, "r"); continue; }
if (std::string(column.label) == "Nr.") {
// the shirt number; with the engine it can be changed by a click
if (engine_mode_) out += pg_td(btn("lineup-number", "<span>" + engine_shirt(id, size_t(slot + 1)) + "</span>", "pg-link", "id=\"lineup-number-" + esc(id) + "\" data-id=\"" + esc(id) + "\" title=\"Rückennummer ändern\""), column.width, "r", true);
else out += pg_td(slot < field_count ? std::to_string(slot + 1) : std::string("–"), column.width, "r");
continue;
}
if (std::string(column.label) == "Name") {
auto name = esc(row.at("name").get<std::string>());
if (row.at("pair_number").is_number_integer()) name += "</span><span class=\"pg-tag sage\" style=\"margin-left:" + pg(6) + ";\">P" + std::to_string(row.at("pair_number").get<int>());
@@ -91,7 +96,7 @@ std::string App::render_lineup_page() {
const bool selected = lineup_selected_ == row.at("id").get<std::string>();
const std::string level = condition.is_number_integer() ? (condition.get<int>() >= 85 ? "a" : condition.get<int>() >= 70 ? "b" : "c") : "n";
return btn("lineup-player", "<span class=\"lp-shirt-art\">" + picture(renderer_.diagram("lineup-shirt-" + shirt_colour + (selected ? "-s-" : "-n-") + level, lineup_shirt(shirt_colour, selected, condition), 160), shirt_size, shirt_size) +
"<span class=\"lp-num\">" + (index < size_t(field_count) ? std::to_string(index + 1) : std::string()) + "</span></span><span class=\"lp-name\">" + esc(last_name(row.at("name").get<std::string>())) + "</span>",
"<span class=\"lp-num\">" + (engine_mode_ ? engine_shirt(row.at("id").get<std::string>(), index + 1) : index < size_t(field_count) ? std::to_string(index + 1) : std::string()) + "</span></span><span class=\"lp-name\">" + esc(last_name(row.at("name").get<std::string>())) + "</span>",
std::string("lp-shirt") + (selected ? " sel" : ""), player_attrs(row, "lineup-player-") + (style.empty() ? std::string() : " style=\"" + style + "\""));
};
const double side_width = 900, pitch_height = 1512 - 27 - (indoor ? 420 : 250);
+2 -2
View File
@@ -204,7 +204,7 @@ std::string App::live_roster(const Json &owner) {
last = "<div class=\"mv-ko\"><span class=\"bar\"><div style=\"width:" + std::to_string(value) + "%;background-color:" +
(value > 70 ? "#56874a" : value > 50 ? "#d9a441" : "#c8372d") + ";\"></div></span><span>" + std::to_string(value) + "</span></div>";
}
out += "<div class=\"mv-tr\" data-live-player=\"" + esc(id) + "\">" + cell(std::to_string(i + 1), "w1") +
out += "<div class=\"mv-tr\" data-live-player=\"" + esc(id) + "\">" + cell(engine_shirt(id, i + 1), "w1") +
cell(live_position_text(row.value("position", Json())), "w2 l pos") +
"<span class=\"nm\"><span class=\"t\">" + esc(row.at("name").get<std::string>()) + "</span>" + badges + "</span>" +
cell(lineup_value(row.at(national ? "caps" : "strength")), "w3") + last + "</div>";
@@ -328,7 +328,7 @@ std::string App::live_dialog_markup(const Json &owner) {
if (chosen) names[bench] = rows[i].at("name").get<std::string>();
const std::string strength = lineup_value(rows[i].value("strength", Json())), condition = lineup_value(rows[i].value("condition", Json()));
lists[bench] += btn(bench ? "live-pick-in" : "live-pick-out",
"<span class=\"nr\">" + std::to_string(i + 1) + "</span><span class=\"ps\">" + esc(live_position_text(rows[i].value("position", Json()))) + "</span><span class=\"nm\">" +
"<span class=\"nr\">" + engine_shirt(id, i + 1) + "</span><span class=\"ps\">" + esc(live_position_text(rows[i].value("position", Json()))) + "</span><span class=\"nm\">" +
esc(rows[i].at("name").get<std::string>()) + "</span><span class=\"vl\">" + esc(strength + " · " + condition) + "</span>",
std::string("mv-pick") + (chosen ? " selected" : ""),
"id=\"live-pick-" + std::to_string(i) + "\" data-id=\"" + esc(id) + "\" aria-pressed=\"" + (chosen ? "true" : "false") + "\"");
+5
View File
@@ -53,6 +53,11 @@
void engine_assembly_ask(const Json &args);
void engine_assembly_clubs(bool forced);
void engine_assembly_choose(const std::string &team);
// The shirt number of a player of the squad at the desk, or of its n-th player; the fallback
// (the place on the board) where the engine gives none.
void engine_expansion_ask(const std::string &expansion); // the next stage of a building: asked, then ordered
std::string engine_shirt(const std::string &player, size_t fallback) const;
std::string engine_shirt_at(size_t place) const;
// The big sheet of the interested clubs: open or not, the club whose details are shown, and
// where its list was scrolled to before the sheet was drawn again.
bool engine_assembly_open_ = false;
+6 -4
View File
@@ -172,6 +172,8 @@ std::string App::notebook_card(const std::string &type, int cols, int rows, cons
return "<div class=\"hw-big\"><strong style=\"font-size:" + std::to_string(size) + "dp;line-height:" + std::to_string(size + 4) + "dp;\">" + esc(text) + "</strong>" + (sub.empty() ? "" : "<span>" + esc(sub) + "</span>") + "</div>";
};
const auto tag = [](const std::string &text, bool terra = false) { return "<span class=\"hw-tag" + std::string(terra ? " terra" : "") + "\">" + esc(text) + "</span>"; };
// home or away: plain words, no marker behind them
const auto place = [](const std::string &text) { return "<span class=\"hw-venue\">" + esc(text) + "</span>"; };
const auto foot = [](const std::string &text) { return "<span class=\"hw-foot\">" + esc(text) + "</span>"; };
const auto lines = [](const std::vector<std::pair<std::string, std::string>> &rows_) {
std::string out = "<div class=\"hw-lines\">";
@@ -196,13 +198,13 @@ std::string App::notebook_card(const std::string &type, int cols, int rows, cons
const bool home = venue == "Heimspiel";
const auto &other = fixture.at(home ? "away" : "home");
const std::string placed = opponent.is_object() ? "Platz " + opponent.value("rank", std::string("—")) + " · Stärke " + opponent.value("strength", std::string("—")) : std::string();
if (flat) return kicker(competition) + "<div class=\"hw-row\"><span class=\"hw-disc\" style=\"width:150dp;height:150dp;\">" + notebook_crest(other.at("team"), 106) + "</span><div class=\"hw-row-text\">" + big(other.at("name").get<std::string>(), 50) + tag(venue, !home) + "</div></div>";
if (flat) return kicker(competition) + "<div class=\"hw-row\"><span class=\"hw-disc\" style=\"width:150dp;height:150dp;\">" + notebook_crest(other.at("team"), 140) + "</span><div class=\"hw-row-text\">" + big(other.at("name").get<std::string>(), 50) + place(venue) + "</div></div>";
if (!wide)
return kicker(competition) + "<div class=\"hw-centre\"><span class=\"hw-disc\" style=\"width:230dp;height:230dp;\">" + notebook_crest(other.at("team"), 164) + "</span></div>" + big(other.at("name").get<std::string>(), 56) + tag(venue, !home) + foot(placed);
return kicker(competition) + "<div class=\"hw-centre\"><span class=\"hw-disc\" style=\"width:230dp;height:230dp;\">" + notebook_crest(other.at("team"), 216) + "</span></div>" + big(other.at("name").get<std::string>(), 56) + place(venue) + foot(placed);
const auto side = [&](const Json &team) {
return "<div class=\"hw-match-side\"><div class=\"hw-match-crest\"><span class=\"hw-disc\" style=\"width:250dp;height:250dp;\">" + notebook_crest(team.at("team"), 178) + "</span></div><strong>" + esc(team.at("name").get<std::string>()) + "</strong></div>";
return "<div class=\"hw-match-side\"><div class=\"hw-match-crest\"><span class=\"hw-disc\" style=\"width:250dp;height:250dp;\">" + notebook_crest(team.at("team"), 236) + "</span></div><strong>" + esc(team.at("name").get<std::string>()) + "</strong></div>";
};
return kicker("Nächstes Spiel · " + competition) + "<div class=\"hw-match\">" + side(fixture.at("home")) + "<div class=\"hw-match-mid\"><span class=\"hw-versus\">vs</span>" + tag(venue, !home) + "</div>" + side(fixture.at("away")) + "</div>" +
return kicker("Nächstes Spiel · " + competition) + "<div class=\"hw-match\">" + side(fixture.at("home")) + "<div class=\"hw-match-mid\"><span class=\"hw-versus\">vs</span>" + place(venue) + "</div>" + side(fixture.at("away")) + "</div>" +
foot(placed.empty() ? std::string() : "Gegner auf " + placed);
}
if (type == "news") {
+18 -8
View File
@@ -198,9 +198,16 @@ inline Scene build(const Json &overview, bool future, const std::string &sign) {
const auto around = [&](size_t i) -> const Json & { return i < periphery.size() ? periphery[i] : none; };
// levels count from 1; the model draws from 0
const auto grade = [&](size_t i) { const auto &f = facility(i); return std::clamp(f.value("display_level", f.value("level", 1)) - 1, 0, 3); };
const auto level = [&](size_t i) { const auto &p = around(i); return std::max(0, p.value("display_level", p.value("level", 0))); };
const auto most = [&](size_t i) { return std::max(1, around(i).value("max_level", 1)); };
const auto busy = [&](const Json &row) { return !future && row.value("building", false); };
// a building that Modern extends in stages (stage 1 = as built) is drawn by its stage; in the
// view of the future the stage under construction counts as finished
const auto stage_of = [&](const Json &row) { return row.contains("stage") ? row.value("stage", 0) + (future && row.value("expanding", false) && row.value("stage", 0) > 0 ? 1 : 0) : -1; };
const auto level = [&](size_t i) {
const auto &p = around(i);
const int built = std::max(0, p.value("display_level", p.value("level", 0)));
return stage_of(p) >= 0 && built > 0 ? std::max(1, stage_of(p)) : built;
};
const auto most = [&](size_t i) { return std::max(1, around(i).contains("stages") ? around(i).value("stages", 1) : around(i).value("max_level", 1)); };
const auto busy = [&](const Json &row) { return !future && (row.value("building", false) || row.value("expanding", false)); };
// ---- the stands: the four with the most room are the long and short sides ----
constexpr double G = 40, G2 = 58.5, H0 = 1.6;
@@ -345,10 +352,12 @@ inline Scene build(const Json &overview, bool future, const std::string &sign) {
hot("facility:1", bx - 1, box_quads(bx - 2, -bw, bx, bw, bz, bz + bh * 1.6));
// the lounge in the main stand; where there is none, its place is only marked
const bool lounge = facility(3).value("max_level", 2) > 2 || facility(3).value("display_level", facility(3).value("level", 1)) >= 2;
const int lounge_stage = lounge ? std::clamp(stage_of(facility(3)), 0, 4) : 0; // 0: not staged (the demo, an older engine)
const int lounge_size = facility(3).value("max_level", 2) <= 2 ? 2 : grade(3);
const double north_tall = 2.5 + depth_north * .6, vw = std::array<double, 5>{10, 16, 24, 34, 34}[size_t(std::clamp(lounge_size, 0, 4))], vy = -G - depth_north * .62, vz = H0 + (north_tall - H0) * .62;
BoxLook glass; glass.deco_y = windows_y(vy, -vw, vw, vz + .4, vz + 3, int(std::lround(vw / 2.2)), "#bfe0ea", .1); glass.top = "#e9dfc9";
items.push_back({-G - depth_north / 2 + .6, lounge ? paint(box(-vw, vy - 3.4, vw, vy, vz - .5, vz + 3.6, "#f6f0e2", glass))
const double lounge_rise = lounge_stage > 1 ? (lounge_stage - 1) * 1.5 : 0;
const double north_tall = 2.5 + depth_north * .6, vw = lounge_stage ? std::array<double, 5>{24, 20, 25, 30, 35}[size_t(lounge_stage)] : std::array<double, 5>{10, 16, 24, 34, 34}[size_t(std::clamp(lounge_size, 0, 4))], vy = -G - depth_north * .62, vz = H0 + (north_tall - H0) * .62;
BoxLook glass; glass.deco_y = windows_y(vy, -vw, vw, vz + .4, vz + 3, int(std::lround(vw / 2.2)), "#bfe0ea", .1) + (lounge_rise > 0 ? windows_y(vy, -vw, vw, vz + 3.5, vz + 3.2 + lounge_rise, int(std::lround(vw / 2.2)), "#d7ecf2", .1) : std::string()); glass.top = "#e9dfc9";
items.push_back({-G - depth_north / 2 + .6, lounge ? paint(box(-vw, vy - 3.4, vw, vy, vz - .5, vz + 3.6 + lounge_rise, "#f6f0e2", glass)) + (busy(facility(3)) && facility(3).value("expanding", false) ? crane(vw + 4, vy - 2, vz + 14) : std::string())
: poly({{-vw, vy, vz - .5}, {vw, vy, vz - .5}, {vw, vy, vz + 3.6}, {-vw, vy, vz + 3.6}}, "#ffffff", "fill-opacity=\".25\" stroke=\"#645c50\" stroke-width=\"1.1\" stroke-dasharray=\"4 3\"")});
hot("facility:3", -G - depth_north / 2 + .6, box_quads(-vw, vy - 3.4, vw, vy, vz - .5, vz + 3.6));
// three small houses in the corners of the forecourt: heating, comfort, upkeep
@@ -479,14 +488,15 @@ inline Scene build(const Json &overview, bool future, const std::string &sign) {
house(2, -46, -124, 44, -92, z, faces, "");
}
{
BoxLook look; look.top = "#a8452f"; look.deco_y = windows_y(-96, 66, 100, 1.2, 5, 6, "#bfe0ea", .2) + sign_y(72, -96, 7.6, "RESTAURANT", 5.4); look.deco_x = windows_x(100, -122, -96, 1.2, 5, 4, "#bfe0ea", .2);
const double rz = level(5) >= 2 ? 12 : 7; // stage two adds a storey
BoxLook look; look.top = "#a8452f"; look.deco_y = windows_y(-96, 66, 100, 1.2, 5, 6, "#bfe0ea", .2) + (rz > 7 ? windows_y(-96, 66, 100, 6.4, 10.4, 6, "#bfe0ea", .2) : std::string()) + sign_y(72, -96, rz + .6, "RESTAURANT", 5.4); look.deco_x = windows_x(100, -122, -96, 1.2, 5, 4, "#bfe0ea", .2) + (rz > 7 ? windows_x(100, -122, -96, 6.4, 10.4, 4, "#bfe0ea", .2) : std::string());
// tables under parasols in front of it
std::string terrace = paint(box(66, -96, 100, -86, 0, .6, "#d9b98a"));
for (const double x : {70.0, 78.0, 86.0, 94.0}) {
const auto q = project({x, -91, 3});
terrace += "<circle cx=\"" + num(q.x) + "\" cy=\"" + num(q.y) + "\" r=\"5\" fill=\"" + (int(x) % 16 > 7 ? "#c8733c" : "#f6ecd8") + "\" stroke=\"" + ink + "\" stroke-width=\".6\"/>" + line({x, -91, .6}, {x, -91, 3}, ink, .7);
}
house(5, 66, -122, 100, -96, 7, box(66, -122, 100, -96, 0, 7, "#f6f0e2", look), terrace);
house(5, 66, -122, 100, -96, rz, box(66, -122, 100, -96, 0, rz, "#f6f0e2", look), terrace);
}
{
const auto stall = [&](size_t index, double x, double y) {
+17 -3
View File
@@ -185,15 +185,28 @@ std::string App::render_stadium() {
for(int i=0;i<level&&i<4;++i)reach+=(i?", ":"")+std::string(links[size_t(i)]);
body=stadium_kv("Ausbaustufe",level<=0?"noch nicht gebaut":most>1?std::to_string(level)+" von "+std::to_string(most):"gebaut")+(index==0&&!reach.empty()?stadium_kv("Anbindung",reach):std::string())+"<div class=\"pg-row\" style=\"justify-content:flex-end;\">"+pg_dots(level,most)+"</div>";
full=row.at("level").get<int>()>=most;
// a building Modern extends in stages: built is all the original says about it
if(engine_mode_&&row.contains("expansion")&&row.value("stage",0)>0)body=stadium_kv("Gebäude","gebaut");
}
std::string job;
if(busy) {
const auto &work=row.at("job");
job="<span class=\"pg-tag accent\" style=\"align-self:flex-start;\">Im Bau"+(stadium_focus_.starts_with("block:")?" auf "+number(work.at("places").get<int64_t>())+" Plätze":std::string())+" · noch "+std::to_string(work.at("weeks").get<int>())+(stadium_focus_.starts_with("periphery:")&&engine_mode_?" Tage":" Wochen")+"</span>";
}
out+="<aside class=\"pg-panel pg-col sd-card\" id=\"stadium-card\"><div>"+pg_kicker(kind)+"<h3 class=\"pg-h\" style=\"font-size:"+pg(22)+";line-height:"+pg(27)+";\">"+esc(name_of(stadium_focus_))+"</h3></div>"+body+job+
"<span class=\"pg-mut\" style=\"display:block;font-size:"+pg(12.5)+";\">"+std::string(busy?"Hier wird gebaut.":full?"Hier ist alles ausgebaut.":"Preis und Bauzeit nennt das Angebot der Baufirma.")+"</span><div class=\"pg-row\" style=\"justify-content:flex-end;"+pg_css("gap:8px;")+"\">"+
pg_button("stadium-focus","Zurück","","id=\"stadium-card-back\" data-id=\"\"")+pg_button(action,verb,"primary","id=\"stadium-card-build\" data-id=\""+std::to_string(index)+"\" "+(busy||full?"disabled=\"disabled\"":""))+"</div></aside>";
// Modern's further stages of the lounge and four buildings of the periphery
std::string stages;
if(engine_mode_&&row.contains("expansion")&&row.value("stage",0)>0) {
const auto &x=row.at("expansion");const int stage=row.value("stage",0),all=row.value("stages",1),left=x.value("months_left",0);
stages="<div class=\"sd-steps\">"+stadium_kv("Ausbaustufe",std::to_string(stage)+" von "+std::to_string(all))+"<div class=\"pg-row\" style=\"justify-content:flex-end;\">"+pg_dots(stage,all)+"</div>"+
(x.value("income",int64_t(0))>0?stadium_kv("Bringt im Monat",esc(money(x.at("income").get<int64_t>(),{{"code","EUR"},{"minor_units",2}}))):std::string())+
(left>0?"<span class=\"pg-tag accent\" style=\"align-self:flex-start;\">Stufe "+std::to_string(stage+1)+" im Bau · noch "+std::to_string(left)+(left==1?" Monat":" Monate")+"</span>"
:x.at("price").is_null()?std::string("<span class=\"pg-mut\" style=\"display:block;\">Alle Stufen sind gebaut.</span>")
:stadium_kv("Nächste Stufe",esc(money(x.at("price").get<int64_t>(),{{"code","EUR"},{"minor_units",2}}))+" · "+std::to_string(x.value("months",0))+" Monate")+"<div class=\"pg-row\" style=\"justify-content:flex-end;\">"+
pg_button("expansion-start","Stufe ausbauen","","id=\"stadium-card-expand\" data-id=\""+esc(x.value("id",std::string()))+"\" "+(x.value("available",false)?"":"disabled=\"disabled\""))+"</div>")+"</div>";
}
out+="<aside class=\"pg-panel pg-col sd-card\" id=\"stadium-card\"><div>"+pg_kicker(kind)+"<h3 class=\"pg-h\" style=\"font-size:"+pg(22)+";line-height:"+pg(27)+";\">"+esc(name_of(stadium_focus_))+"</h3></div>"+body+job+stages+
"<span class=\"pg-mut\" style=\"display:block;font-size:"+pg(12.5)+";\">"+std::string(busy?"Hier wird gebaut.":!stages.empty()?"":full?"Hier ist alles ausgebaut.":"Preis und Bauzeit nennt das Angebot der Baufirma.")+"</span><div class=\"pg-row\" style=\"justify-content:flex-end;"+pg_css("gap:8px;")+"\">"+
pg_button("stadium-focus","Zurück","","id=\"stadium-card-back\" data-id=\"\"")+(!stages.empty()&&full?std::string():pg_button(action,verb,"primary","id=\"stadium-card-build\" data-id=\""+std::to_string(index)+"\" "+(busy||full?"disabled=\"disabled\"":"")))+"</div></aside>";
}
stadium_tip_=tip.empty()?std::string():stadium_tip_;
out+="<div class=\"sd-tip\" id=\"stadium-tip\""+(tip.empty()?std::string():" style=\"display:block;left:"+pg(stadium_tip_at_[0])+";top:"+pg(stadium_tip_at_[1])+";\"")+">"+tip+"</div></div><nav class=\"pg-foot\" aria-label=\"Ansicht des Stadions\">";
@@ -205,6 +218,7 @@ std::string App::render_stadium() {
out+=btn("stadium-future","<span>"+std::string(i?"Zukunft":"Aktuell")+"</span>",std::string(i?"":"first ")+(on?"on":""),on?std::string("style=\"pointer-events:none;\" aria-pressed=\"true\""):std::string("id=\"stadium-future\" aria-pressed=\"false\""));
}
out+="</div>"+pg_button("stadium-data","Stadion-Daten","","id=\"stadium-data\"");
if(engine_mode_)out+=pg_button("stadium-expansions","Ausbaustufen","","id=\"stadium-expansions\"");
// the name is the manager's to choose until he sells it to a sponsor
if(engine_mode_)out+=pg_button("stadium-rename","Stadion umbenennen","","id=\"stadium-rename\" "+std::string(overview.value("name_editable",false)?"":"disabled=\"disabled\" title=\"Der Name ist an einen Sponsor verkauft\""));
}
+2 -2
View File
@@ -119,7 +119,7 @@ std::string App::render_tactics() {
for (size_t i = 0; i < 11; ++i) {
const auto &[x, y, side] = players[i];
lines += "<circle cx=\"" + scalar(x) + "\" cy=\"" + scalar(y) + "\" r=\"17\" fill=\"" + paper + "\" fill-opacity=\".85\" stroke=\"" + ink + "\" stroke-width=\"2.6\"/>";
over += "<span class=\"tk-text tk-number\" style=\"" + at(x - 25, y - 14, 50, 28) + "font-size:" + scalar(23 * tactics_unit) + "dp;line-height:" + scalar(28 * tactics_unit) + "dp;color:" + ink + ";\">" + std::to_string(i + 1) + "</span>";
over += "<span class=\"tk-text tk-number\" style=\"" + at(x - 25, y - 14, 50, 28) + "font-size:" + scalar(23 * tactics_unit) + "dp;line-height:" + scalar(28 * tactics_unit) + "dp;color:" + ink + ";\">" + engine_shirt_at(i) + "</span>";
if (side != 0) over += "<div class=\"tk-drag\" data-tactic-drag=\"wings\" data-side=\"" + std::to_string(int(side)) + "\" title=\"Nach außen oder innen ziehen\" style=\"" + at(x - 25, y - 25, 50, 50) + "\"></div>";
}
// the three knobs: head of the pass, its arc, head of the goal kick
@@ -136,7 +136,7 @@ std::string App::render_tactics() {
// --- the page ---
std::string out = "<div class=\"pg-page\"><div class=\"pg-body\"><div class=\"tk-sketch\" id=\"tactics-sketch\" role=\"group\" aria-label=\"Taktikskizze\" style=\"width:" + scalar(sketch_w) + "dp;height:" + scalar(sketch_h) + "dp;margin-top:" +
scalar((1620 - sketch_h) / 2) + "dp;\">" + picture(renderer_.diagram("tactics-sketch-" + theme_, svg, 2088), sketch_w, sketch_h) + over + "</div><div class=\"pg-col pg-grow\"><strong class=\"tk-title\">Meine Taktik</strong><div class=\"pg-col pg-grow\" style=\"gap:0dp;\">";
scalar((1620 - sketch_h) / 2 - 62) + "dp;\">" + picture(renderer_.diagram("tactics-sketch-" + theme_, svg, 2088), sketch_w, sketch_h) + over + "</div><div class=\"pg-col pg-grow\"><strong class=\"tk-title\">Meine Taktik</strong><div class=\"pg-col pg-grow\" style=\"gap:0dp;\">";
for (size_t i = 0; i < 7; ++i) {
const bool toggle = i >= 5, on = values[i] > minima[i];
out += btn("tactic-cycle", pg_kicker(names[i], "width:122px;font-size:10px;") + "<span class=\"tk-value" + std::string(toggle && !on ? " off" : "") + "\">" + esc(toggle ? (on ? "an" : "aus") : text_of(i)) + "</span>", "tk-row",
+72
View File
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: GPL-3.0-only
// The four further properties of the bank (docs/new_engine/immobilien.md) on a synthetic
// manager: buying and selling at the day's price, the limit, the monthly price move and the rent.
#include <cstdio>
#include "modern/game/estates.hpp"
using namespace bmh;
using namespace bmh::modern;
namespace {
int failures = 0;
void check(bool ok, const char* what) {
if (!ok) {
std::fprintf(stderr, "FAIL: %s\n", what);
++failures;
}
}
int32_t cash(const ModernState& g) {
return int32_t(uint32_t(g.manager_records[0x314]) | uint32_t(g.manager_records[0x315]) << 8 | uint32_t(g.manager_records[0x316]) << 16 |
uint32_t(g.manager_records[0x317]) << 24);
}
ModernState world(int32_t euros) {
ModernState g;
g.career_id = "career:test";
g.level = 2;
g.manager_teams = {0};
g.manager_records.assign(5 * 0xb0c, 0);
for (int i = 0; i < 4; ++i) g.manager_records[0x314 + size_t(i)] = uint8_t(uint32_t(euros) >> (8 * i));
return g;
}
} // namespace
int main() {
{
ModernState g = world(3000000);
check(estate_price(g, 0) == 450000 && estate_price(g, 1) == 1200000 && estate_price(g, 2) == 280000 && estate_price(g, 3) == 650000 && estate_price(g, 4) == 0,
"the starting prices");
check(estate_rent(g, 1) == 4800, "the rent is four per mille of the price a month");
check(buy_estate(g, 0, 1, 2) && estates_held(g, 0, 1) == 2 && cash(g) == 600000 && estates_value(g, 0) == 2400000, "two penthouses are bought");
check(!buy_estate(g, 0, 1, 1) && !buy_estate(g, 0, 0, 0) && !buy_estate(g, 0, 4, 1) && !buy_estate(g, 1, 0, 1) && cash(g) == 600000,
"no purchase beyond the account, of nothing, of an unknown property or without a manager");
check(!sell_estate(g, 0, 1, 3) && !sell_estate(g, 0, 0, 1), "nothing is sold that is not held");
const int32_t before = cash(g);
estates_month(g);
bool moved_in_range = true;
for (int k = 0; k < kEstates; ++k) {
const int64_t base = kEstateBasePrice[size_t(k)], now = estate_price(g, k);
moved_in_range = moved_in_range && now >= base * 97 / 100 && now <= base * 103 / 100 + 1000 && now % 1000 == 0;
}
check(moved_in_range, "a month moves every price by minus two to plus three percent, in whole thousands");
check(cash(g) == before + 2 * estate_rent(g, 1), "the rent of what he holds is paid at the new price");
const int32_t price = estate_price(g, 1), held_cash = cash(g);
check(sell_estate(g, 0, 1, 1) && estates_held(g, 0, 1) == 1 && cash(g) == held_cash + price, "one is sold at the day's price");
}
// the limit of twenty pieces, and prices that stay within half and three times the start
{
ModernState g = world(100000000);
check(buy_estate(g, 0, 2, kEstateLimit) && !buy_estate(g, 0, 2, 1), "twenty pieces of a property at most");
bool bounded = true;
for (uint32_t month = 0; month < 600; ++month) {
g.date = month * 30;
estates_month(g);
for (int k = 0; k < kEstates; ++k)
bounded = bounded && estate_price(g, k) >= kEstateBasePrice[size_t(k)] / 2 && estate_price(g, k) <= kEstateBasePrice[size_t(k)] * 3;
}
check(bounded, "over fifty years the prices stay between half and three times their start");
}
if (failures) return 1;
std::puts("modern_estates_tests: ok");
return 0;
}
+77
View File
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: GPL-3.0-only
// Further stages of lounge and periphery (docs/new_engine/ausbaustufen.md) on a synthetic
// manager: what can be extended, prices and building times, the months of building, the income.
#include <cstdio>
#include "modern/game/expansions.hpp"
using namespace bmh;
using namespace bmh::modern;
namespace {
int failures = 0;
void check(bool ok, const char* what) {
if (!ok) {
std::fprintf(stderr, "FAIL: %s\n", what);
++failures;
}
}
int32_t cash(const ModernState& g) {
return int32_t(uint32_t(g.manager_records[0x314]) | uint32_t(g.manager_records[0x315]) << 8 | uint32_t(g.manager_records[0x316]) << 16 |
uint32_t(g.manager_records[0x317]) << 24);
}
// Manager 0 runs club `team`; the lounge (facility 3) and the restaurant (object 5) stand.
ModernState world(int team, int32_t euros) {
ModernState g;
g.level = 2;
g.manager_teams = {int16_t(team)};
g.manager_records.assign(5 * 0xb0c, 0);
g.manager_records[0x3c + 3] = 2;
g.manager_records[5] = 0x40;
for (int i = 0; i < 4; ++i) g.manager_records[0x314 + size_t(i)] = uint8_t(uint32_t(euros) >> (8 * i));
return g;
}
} // namespace
int main() {
{
ModernState g = world(0, 10000000);
check(expansion_stage(g, 0, Expansion::lounge) == 1 && expansion_stage(g, 0, Expansion::restaurant) == 1 && expansion_stage(g, 0, Expansion::mall) == 0,
"what the original built is stage one, the rest is not built");
check(expansion_price(g, 0, Expansion::lounge) == 1200000 && expansion_build_months(g, 0, Expansion::lounge) == 3, "the second stage of the lounge");
check(!start_expansion(g, 0, Expansion::mall) && cash(g) == 10000000, "a building that does not stand cannot be extended");
check(start_expansion(g, 0, Expansion::lounge) && cash(g) == 8800000 && expansion_months_left(g, 0, Expansion::lounge) == 3, "the stage is paid and under construction");
check(!start_expansion(g, 0, Expansion::lounge), "no second stage while one is built");
expansions_month(g), expansions_month(g);
check(expansion_stage(g, 0, Expansion::lounge) == 1 && cash(g) == 8800000, "two months: still building, no income");
expansions_month(g);
check(expansion_stage(g, 0, Expansion::lounge) == 2 && cash(g) == 8800000 + 45000, "the third month finishes the stage and it pays at once");
check(expansion_price(g, 0, Expansion::lounge) == 2400000 && expansion_build_months(g, 0, Expansion::lounge) == 4, "the third stage costs twice as much and takes longer");
// up to the last stage
while (expansion_price(g, 0, Expansion::lounge) != 0) {
check(start_expansion(g, 0, Expansion::lounge), "next stage started");
while (expansion_months_left(g, 0, Expansion::lounge) != 0) expansions_month(g);
}
check(expansion_stage(g, 0, Expansion::lounge) == 4 && !start_expansion(g, 0, Expansion::lounge) && expansion_income(g, 0, Expansion::lounge) == 3 * 45000,
"four stages at most; three further stages pay three times");
// the restaurant has two stages
check(start_expansion(g, 0, Expansion::restaurant), "the restaurant is extended");
while (expansion_months_left(g, 0, Expansion::restaurant) != 0) expansions_month(g);
check(expansion_stage(g, 0, Expansion::restaurant) == 2 && expansion_price(g, 0, Expansion::restaurant) == 0, "the restaurant ends at stage two");
// a building that is gone pays nothing
g.manager_records[5] = 0;
check(expansion_stage(g, 0, Expansion::restaurant) == 0 && expansion_income(g, 0, Expansion::restaurant) == 0, "no building, no income");
}
{
ModernState low = world(60, 100000);
check(!start_expansion(low, 0, Expansion::lounge) && cash(low) == 100000, "an account that cannot bear the price refuses");
low.expansions.resize(1);
low.expansions[0].stage[0] = 1;
check(expansion_income(low, 0, Expansion::lounge) == 45000 * 25 / 100, "a low league earns a quarter");
low.manager_records[0x2c + 3] = 4;
check(!expansion_base_built(low, 0, Expansion::lounge), "a lounge under construction does not count as standing");
}
if (failures) return 1;
std::puts("modern_expansion_tests: ok");
return 0;
}
+86
View File
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: GPL-3.0-only
// International marketing (docs/new_engine/vermarktung.md) on a synthetic manager: the budget,
// how the reach builds up and falls, what it brings by league, and a month that cannot be paid.
#include <cstdio>
#include "modern/game/marketing.hpp"
using namespace bmh;
using namespace bmh::modern;
namespace {
int failures = 0;
void check(bool ok, const char* what) {
if (!ok) {
std::fprintf(stderr, "FAIL: %s\n", what);
++failures;
}
}
int32_t cash(const ModernState& g) {
return int32_t(uint32_t(g.manager_records[0x314]) | uint32_t(g.manager_records[0x315]) << 8 | uint32_t(g.manager_records[0x316]) << 16 |
uint32_t(g.manager_records[0x317]) << 24);
}
void set_cash(ModernState& g, int32_t euros) {
for (int i = 0; i < 4; ++i) g.manager_records[0x314 + size_t(i)] = uint8_t(uint32_t(euros) >> (8 * i));
}
// Manager 0 runs club `team` with a prestige of 50 and ten million in the account.
ModernState world(int team = 0) {
ModernState g;
g.level = 2;
g.manager_teams = {int16_t(team)};
g.manager_records.assign(5 * 0xb0c, 0);
g.manager_records[0x211] = 50;
set_cash(g, 10000000);
return g;
}
} // namespace
int main() {
check(marketing_target(0) == 0 && marketing_target(100000) == 200 && marketing_target(500000) == 1000 && marketing_target(900000) == 1000,
"a point of reach for every 500 euros, a thousand at most");
{
ModernState g = world();
check(set_marketing_budget(g, 0, 200000) && g.marketing.at(0).budget == 200000, "the budget is set");
check(!set_marketing_budget(g, 0, -1000) && !set_marketing_budget(g, 0, 501000) && !set_marketing_budget(g, 0, 1500) && !set_marketing_budget(g, 1, 1000) &&
g.marketing.at(0).budget == 200000,
"a negative, too high or uneven budget and a missing manager are refused");
// first league, prestige 50: 900 euros a point, the full reach counts as half its points
check(marketing_income(g, 0, 0) == 0 && marketing_income(g, 0, 200) == 180 * 900 && marketing_income(g, 0, 1000) == 500 * 900,
"income by reach: every further point is worth less");
check(marketing_income(world(20), 0, 200) == 180 * 400 && marketing_income(world(60), 0, 200) == 180 * 70, "lower leagues earn much less");
ModernState famous = world();
famous.manager_records[0x211] = 100;
check(marketing_income(famous, 0, 200) == 180 * 900 * 140 / 100, "prestige raises the income");
const int32_t before = cash(g);
marketing_month(g);
// target 400: the first month brings a sixth of the way (66 points)
check(g.marketing[0].reach == 66 && cash(g) == before - 200000 + marketing_income(g, 0, 66), "the first month: budget paid, a sixth of the way, first income");
int months = 1;
while (g.marketing[0].reach < 400 && months < 60) marketing_month(g), ++months;
check(g.marketing[0].reach == 400 && months > 10 && months < 40, "the reach arrives at what the budget holds after a year or two");
const int32_t steady = cash(g);
marketing_month(g);
check(cash(g) - steady == marketing_income(g, 0, 400) - 200000 && cash(g) > steady, "at the target the marketing pays more than it costs in the first league");
check(set_marketing_budget(g, 0, 0), "the budget is cut");
marketing_month(g);
check(g.marketing[0].reach == 300, "without budget the reach falls by a quarter");
while (g.marketing[0].reach > 0) marketing_month(g);
const int32_t empty = cash(g);
marketing_month(g);
check(cash(g) == empty, "no budget, no reach: nothing is booked");
}
// a month the account cannot bear counts as one without budget
{
ModernState g = world();
set_marketing_budget(g, 0, 300000);
g.marketing[0].reach = 400;
set_cash(g, 1000);
marketing_month(g);
check(g.marketing[0].reach == 300 && cash(g) == 1000 + marketing_income(g, 0, 300), "unpaid month: the reach falls, the account is not charged");
}
if (failures) return 1;
std::puts("modern_marketing_tests: ok");
return 0;
}
+74
View File
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: GPL-3.0-only
// Shirt numbers (docs/new_engine/rueckennummern.md) on a synthetic squad: the lowest free
// numbers, kept numbers, the swap, and that numbers stay with players when rows change.
#include <cstdio>
#include <set>
#include "modern/game/shirt_numbers.hpp"
using namespace bmh;
using namespace bmh::modern;
namespace {
int failures = 0;
void check(bool ok, const char* what) {
if (!ok) {
std::fprintf(stderr, "FAIL: %s\n", what);
++failures;
}
}
// Manager 0 runs club 0 with players 0-19 in its first twenty rows.
ModernState squad() {
ModernState g;
g.manager_teams = {0};
g.manager_records.assign(5 * 0xb0c, 0);
g.squad_slots.assign(3150, kEmptySlot);
for (int i = 0; i < 20; ++i) {
g.players.push_back(Player{});
g.squad_slots[size_t(i)] = uint16_t(i);
}
return g;
}
} // namespace
int main() {
{
ModernState g = squad();
const auto numbers = squad_shirt_numbers(g, 0);
bool in_order = numbers.size() >= 20;
for (int i = 0; in_order && i < 20; ++i) in_order = numbers[size_t(i)] == i + 1;
check(in_order && numbers[20] == 0, "without kept numbers the squad wears 1 to 20 in row order, empty rows none");
check(set_shirt_number(g, 0, 5, 33) && squad_shirt_numbers(g, 0)[5] == 33, "a free number is given");
check(set_shirt_number(g, 0, 0, 10), "a worn number is given");
const auto swapped = squad_shirt_numbers(g, 0);
check(swapped[0] == 10 && swapped[9] == 1, "the two players swap their numbers");
std::set<int> worn;
bool unique = true;
for (int i = 0; i < 20; ++i) unique = unique && worn.insert(swapped[size_t(i)]).second;
check(unique, "every number is worn once");
check(!set_shirt_number(g, 0, 5, 0) && !set_shirt_number(g, 0, 5, 100) && !set_shirt_number(g, 0, 30, 7) && !set_shirt_number(g, 1, 5, 7) &&
squad_shirt_numbers(g, 0)[5] == 33,
"a number out of range, a player outside the squad and a missing manager are refused");
// rows change (a new line-up): the numbers go with the players
std::swap(g.squad_slots[0], g.squad_slots[15]);
const auto moved = squad_shirt_numbers(g, 0);
check(moved[15] == 10 && moved[0] == 16, "numbers stay with the players when rows change");
}
// a newcomer whose number is taken gets the lowest free one
{
ModernState g = squad();
fix_shirt_numbers(g, 0);
g.players.push_back(Player{});
g.shirt_numbers.resize(g.players.size(), 0);
g.shirt_numbers[20] = 7;
g.squad_slots[20] = 20;
check(squad_shirt_numbers(g, 0)[20] == 21 && squad_shirt_numbers(g, 0)[6] == 7, "a taken number: the newcomer gets the lowest free one");
g.squad_slots[6] = kEmptySlot;
check(squad_shirt_numbers(g, 0)[20] == 7, "once the number is free he wears his own");
}
if (failures) return 1;
std::puts("modern_shirt_number_tests: ok");
return 0;
}