Expose full gameplay rules, difficulty, HUD, and control options

This commit is contained in:
Luxferre committed 2026-11-30 23:57:29 +02:00
1 parent 6c24f715a0
commit cd63921ea4
15 files changed
+564 -164

No files matched your search

+62
View File
@@ -136,5 +136,67 @@ int main() {
std::filesystem::remove_all(tmp_dir);
std::cout << "[PASS] Championship save/load, Highscores & Clone disk round-trip validated\n";
// 5. Gameplay Rule Toggles (fuel, weapons, damage, pickups, track morphing)
{
sim::RaceSetup r1;
r1.mode = sim::GameMode::SingleRace;
r1.track_number = 1;
r1.num_ai = 1;
r1.fuel_enabled = false;
r1.weapons_enabled = false;
r1.pickups_enabled = false;
r1.track_morphing_enabled = false;
sim::RaceSim ts1;
CHECK(ts1.start_race(lvl1, r1));
CHECK(ts1.pickups().empty());
float start_fuel = ts1.crafts()[0].fuel;
// Skip countdown
for (int t = 0; t < 200; ++t) ts1.step(CraftInput{}, CraftInput{}, dt);
CraftInput drive;
drive.throttle = 1.0f;
drive.boost = true;
drive.fire_minigun = true;
drive.fire_missile = true;
for (int t = 0; t < 120; ++t) {
ts1.step(drive, CraftInput{}, dt);
CHECK(ts1.projectiles().empty());
}
CHECK(ts1.crafts()[0].fuel == start_fuel);
if (!lvl1.triggers.empty()) {
const auto& tr = lvl1.triggers[0];
ts1.crafts_mut()[0].curr_pose.pos = Vec3(
tr.tile_x() + 0.5f, lvl1.sample_height_world(tr.tile_x() + 0.5f, tr.tile_z() + 0.5f),
tr.tile_z() + 0.5f);
ts1.step(CraftInput{}, CraftInput{}, dt);
int x0, z0, x1, z1;
CHECK(!ts1.consume_terrain_dirty(x0, z0, x1, z1));
}
// damage_enabled = false keeps target shields intact on direct hits
sim::RaceSetup r2;
r2.mode = sim::GameMode::DeathMatch;
r2.track_number = 1;
r2.num_ai = 1;
r2.damage_enabled = false;
sim::RaceSim ts2;
CHECK(ts2.start_race(lvl1, r2));
for (int t = 0; t < 200; ++t) ts2.step(CraftInput{}, CraftInput{}, dt);
auto& p1 = ts2.crafts_mut()[0];
auto& tgt = ts2.crafts_mut()[1];
Vec3 fwd = p1.forward_dir();
tgt.curr_pose.pos = p1.curr_pose.pos + fwd * 3.0f;
tgt.prev_pose = tgt.curr_pose;
float init_sh = tgt.shield;
for (int t = 0; t < 60; ++t) {
CraftInput fire;
fire.fire_minigun = true;
ts2.step(fire, CraftInput{}, dt);
}
CHECK(tgt.shield == init_sh);
CHECK(p1.kills == 0);
}
std::cout << "[PASS] Gameplay rule toggles (fuel, weapons, damage, pickups, morphing) validated\n";
return 0;
}