refactor(server): apply rustfmt and clippy suggestions

Formatting pass across simulation, perception, knowledge, NPC, and
test modules. Includes two clippy fixes in monologue.rs (.values()
instead of for (_, v) pattern).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 00:40:43 +01:00
co-authored by Claude Opus 4.6
parent 8ec875385a
commit d0663c4193
21 changed files with 600 additions and 274 deletions
+36 -10
View File
@@ -36,9 +36,18 @@ pub(crate) const ANOMALY_DELAY_TICKS: u64 = 90;
/// Hardcoded v0.1 sprint anomaly "double-take" lines.
/// Future: move to content pools with trigger="sprint_anomaly".
const ANOMALY_LINES: &[(&str, &str)] = &[
("sprint_anomaly_01", "Wait \u{2014} something wasn't right back there."),
("sprint_anomaly_02", "Hold on. That face... why were they there?"),
("sprint_anomaly_03", "Something's off. That wasn't where they should be."),
(
"sprint_anomaly_01",
"Wait \u{2014} something wasn't right back there.",
),
(
"sprint_anomaly_02",
"Hold on. That face... why were they there?",
),
(
"sprint_anomaly_03",
"Something's off. That wasn't where they should be.",
),
];
/// Tracks monologue state for cooldown and trigger detection.
@@ -148,7 +157,11 @@ pub fn process_sprint_anomaly_monologue(
time: Res<SimulationTime>,
mut rng: ResMut<SimRng>,
mut query: Query<
(&mut SprintAnomalyQueue, &mut MonologueBuffer, &mut MonologueState),
(
&mut SprintAnomalyQueue,
&mut MonologueBuffer,
&mut MonologueState,
),
With<PlayerCharacter>,
>,
) {
@@ -236,7 +249,7 @@ pub fn trigger_monologue(
let character = state.character.as_str();
let mut candidates: Vec<(&str, &str)> = Vec::new(); // (id, text)
for (_district_id, district) in &content.0.districts {
for district in content.0.districts.values() {
for pool in &district.monologue_pools {
if pool.character != character {
continue;
@@ -255,7 +268,7 @@ pub fn trigger_monologue(
if candidates.is_empty() {
// All lines for this trigger have been shown; allow repeats
for (_district_id, district) in &content.0.districts {
for district in content.0.districts.values() {
for pool in &district.monologue_pools {
if pool.character != character {
continue;
@@ -688,7 +701,11 @@ mod tests {
// All hardcoded v0.1 lines should have id prefix and non-empty text
assert!(!ANOMALY_LINES.is_empty());
for (id, text) in ANOMALY_LINES {
assert!(id.starts_with("sprint_anomaly_"), "id={} should start with sprint_anomaly_", id);
assert!(
id.starts_with("sprint_anomaly_"),
"id={} should start with sprint_anomaly_",
id
);
assert!(!text.is_empty(), "text for {} should be non-empty", id);
}
}
@@ -716,10 +733,16 @@ mod tests {
schedule.run(&mut world);
let mut buf_query = world.query::<&MonologueBuffer>();
assert!(buf_query.single(&world).unwrap().event.is_none(), "should not fire before delay");
assert!(
buf_query.single(&world).unwrap().event.is_none(),
"should not fire before delay"
);
let mut q_query = world.query::<&SprintAnomalyQueue>();
assert!(q_query.single(&world).unwrap().has_pending(), "still pending before delay");
assert!(
q_query.single(&world).unwrap().has_pending(),
"still pending before delay"
);
// Tick 90: delay elapsed — should fire
world.resource_mut::<SimulationTime>().tick = ANOMALY_DELAY_TICKS;
@@ -734,7 +757,10 @@ mod tests {
// Queue should be cleared
let mut q_query = world.query::<&SprintAnomalyQueue>();
assert!(!q_query.single(&world).unwrap().has_pending(), "queue cleared after fire");
assert!(
!q_query.single(&world).unwrap().has_pending(),
"queue cleared after fire"
);
// last_fired_tick should be updated
let mut state_query = world.query::<&MonologueState>();