fix(simulation): correct CONTAMINATION_DELAY_TICKS from 1800 to 300

The constant was supposed to represent 30 game-minutes but the formula
was wrong (30 × 10 tps × 60s = 1800). Correct derivation: 30 minutes ×
TICKS_PER_GAME_MINUTE (10) = 300. Now uses the canonical constant
directly. Also fixes stale assertion message in integration test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 23:24:47 +01:00
co-authored by Claude Opus 4.6
parent d867cf1e3b
commit 70de959ac3
2 changed files with 13 additions and 12 deletions
+6 -6
View File
@@ -7,8 +7,8 @@
//!
//! ## Contamination (#254)
//!
//! After `CONTAMINATION_DELAY_TICKS` (default 1800 = 30 game-minutes at
//! 10 tps), the storyteller:
//! After `CONTAMINATION_DELAY_TICKS` (default 300 = 30 game-minutes at
//! 10 ticks/game-minute per D-031), the storyteller:
//! 1. Sets `ContaminationActive` resource to true (one-shot)
//! 2. Applies a tension delta to all `ActiveFork` triangles
//! 3. Emits a `ContaminationEvent` for downstream systems (monologue, etc.)
@@ -18,14 +18,14 @@ use bevy_ecs::prelude::*;
use crate::content::template::{TriangleClassification, TriangleState};
use crate::simulation::tier::ActiveSim;
use crate::simulation::time::SimulationTime;
use crate::simulation::time::{SimulationTime, TICKS_PER_GAME_MINUTE};
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
/// Tick at which contamination activates (30 game-minutes × 10 tps × 60s = 1800).
pub const CONTAMINATION_DELAY_TICKS: u64 = 1800;
/// Tick at which contamination activates (30 game-minutes × 10 ticks/minute = 300).
pub const CONTAMINATION_DELAY_TICKS: u64 = 30 * TICKS_PER_GAME_MINUTE;
/// Tension delta applied to ActiveFork triangles when contamination fires.
pub const CONTAMINATION_PRESSURE_DELTA: u8 = 10;
@@ -41,7 +41,7 @@ pub const CONFRONTATION_THRESHOLD: u8 = 75;
/// Whether contamination has been activated by the storyteller.
///
/// Once set to `true`, it stays true for the remainder of the session.
/// Persisted via save state (future — currently session-scoped).
/// Persisted in `SaveStateV1` to prevent double-firing on save/load.
#[derive(Resource, Debug, Clone, Default)]
pub struct ContaminationActive(pub bool);
+7 -6
View File
@@ -42,10 +42,10 @@ fn make_triangle(
}
}
/// Acceptance test: run 1801 ticks, assert ContaminationActive is set and
/// all ActiveFork TriangleState entities have tension > 0.
/// Acceptance test: run past CONTAMINATION_DELAY_TICKS, assert ContaminationActive
/// is set and all ActiveFork TriangleState entities have tension > 0.
#[test]
fn contamination_activates_after_1801_ticks() {
fn contamination_activates_after_delay() {
let mut world = World::new();
world.init_resource::<SimulationTime>();
world.init_resource::<ContaminationActive>();
@@ -102,8 +102,8 @@ fn contamination_activates_after_1801_ticks() {
let mut schedule = Schedule::default();
schedule.add_systems(tick_contamination_activation);
// Simulate 1801 ticks
for tick in 0..=1800 {
// Simulate past the delay threshold (CONTAMINATION_DELAY_TICKS = 300)
for tick in 0..=CONTAMINATION_DELAY_TICKS {
world.resource_mut::<SimulationTime>().tick = tick;
schedule.run(&mut world);
}
@@ -111,7 +111,8 @@ fn contamination_activates_after_1801_ticks() {
// Assert ContaminationActive is set
assert!(
world.resource::<ContaminationActive>().0,
"ContaminationActive must be true after 1801 ticks"
"ContaminationActive must be true after CONTAMINATION_DELAY_TICKS ({}) ticks",
CONTAMINATION_DELAY_TICKS
);
// Assert all ActiveFork triangles have tension > 0