Files
Dreierpack-Manager/tests/modern_expansion_tests.cpp
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

78 lines
4.3 KiB
C++

// 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;
}