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:
+56
-25
@@ -184,11 +184,11 @@ fn spawn_npc(world: &mut World, profile: &types::NpcProfile, result: &mut SpawnR
|
||||
|
||||
// Register in EntityRegistry for StableId mapping
|
||||
let stable_id = world.resource_mut::<EntityRegistry>().register(entity);
|
||||
world
|
||||
.entity_mut(entity)
|
||||
.insert(StableEntityId(stable_id));
|
||||
world.entity_mut(entity).insert(StableEntityId(stable_id));
|
||||
|
||||
result.npc_ids.insert(profile.canonical_id.clone(), stable_id);
|
||||
result
|
||||
.npc_ids
|
||||
.insert(profile.canonical_id.clone(), stable_id);
|
||||
result.npcs_spawned += 1;
|
||||
|
||||
tracing::debug!(
|
||||
@@ -418,10 +418,7 @@ fn resolve_routines(
|
||||
|
||||
for schedule in &routine_file.schedules {
|
||||
let Some(&stable_id) = npc_ids.get(&schedule.npc) else {
|
||||
tracing::debug!(
|
||||
"Skipping routine for {}: not in npc_ids map",
|
||||
schedule.npc
|
||||
);
|
||||
tracing::debug!("Skipping routine for {}: not in npc_ids map", schedule.npc);
|
||||
continue;
|
||||
};
|
||||
let Some(entity) = world.resource::<EntityRegistry>().to_entity(&stable_id) else {
|
||||
@@ -523,7 +520,10 @@ fn parse_relationship_kind(s: &str) -> npc::RelationshipKind {
|
||||
"superior" => npc::RelationshipKind::Superior,
|
||||
"subordinate" => npc::RelationshipKind::Subordinate,
|
||||
other => {
|
||||
tracing::warn!("Unknown relationship kind '{}', defaulting to Colleague", other);
|
||||
tracing::warn!(
|
||||
"Unknown relationship kind '{}', defaulting to Colleague",
|
||||
other
|
||||
);
|
||||
npc::RelationshipKind::Colleague
|
||||
}
|
||||
}
|
||||
@@ -594,10 +594,7 @@ fn parse_secret_severity(description: &str) -> npc::SecretSeverity {
|
||||
}
|
||||
|
||||
// Minor: social embarrassment, mild secrets, ambiguous situations
|
||||
if lower.contains("ambiguous")
|
||||
|| lower.contains("embarrassment")
|
||||
|| lower.contains("gossip")
|
||||
{
|
||||
if lower.contains("ambiguous") || lower.contains("embarrassment") || lower.contains("gossip") {
|
||||
return npc::SecretSeverity::Minor;
|
||||
}
|
||||
|
||||
@@ -715,7 +712,10 @@ mod tests {
|
||||
|
||||
let tells = world.get::<npc::TellSystem>(entity).unwrap();
|
||||
assert_eq!(tells.tells.len(), 1);
|
||||
assert_eq!(tells.tells[0].trigger, npc::TellTrigger::StressAboveThreshold);
|
||||
assert_eq!(
|
||||
tells.tells[0].trigger,
|
||||
npc::TellTrigger::StressAboveThreshold
|
||||
);
|
||||
|
||||
let skills = world.get::<npc::SkillSet>(entity).unwrap();
|
||||
assert_eq!(skills.skills.len(), 2);
|
||||
@@ -771,7 +771,10 @@ mod tests {
|
||||
assert_eq!(parse_want_kind("Wealth"), Some(npc::WantKind::Wealth));
|
||||
assert_eq!(parse_want_kind("safety"), Some(npc::WantKind::Safety));
|
||||
assert_eq!(parse_want_kind("KNOWLEDGE"), Some(npc::WantKind::Knowledge));
|
||||
assert_eq!(parse_want_kind("Connection"), Some(npc::WantKind::Connection));
|
||||
assert_eq!(
|
||||
parse_want_kind("Connection"),
|
||||
Some(npc::WantKind::Connection)
|
||||
);
|
||||
assert_eq!(parse_want_kind("Power"), Some(npc::WantKind::Power));
|
||||
assert_eq!(parse_want_kind("Freedom"), Some(npc::WantKind::Freedom));
|
||||
assert_eq!(parse_want_kind("Justice"), Some(npc::WantKind::Justice));
|
||||
@@ -851,7 +854,9 @@ mod tests {
|
||||
.to_entity(&stable_id)
|
||||
.unwrap();
|
||||
|
||||
let kg = world.get::<KnowledgeGraph>(entity).expect("KnowledgeGraph should be attached");
|
||||
let kg = world
|
||||
.get::<KnowledgeGraph>(entity)
|
||||
.expect("KnowledgeGraph should be attached");
|
||||
assert!(kg.knows_fact(&FactId("contraband.ring_exists".to_string())));
|
||||
assert!(kg.knows_fact(&FactId("relationship.kael_trust".to_string())));
|
||||
assert!(kg.fact_at_least(
|
||||
@@ -886,7 +891,9 @@ mod tests {
|
||||
.to_entity(&stable_id)
|
||||
.unwrap();
|
||||
|
||||
let kg = world.get::<KnowledgeGraph>(entity).expect("Phase 2 should attach KnowledgeGraph");
|
||||
let kg = world
|
||||
.get::<KnowledgeGraph>(entity)
|
||||
.expect("Phase 2 should attach KnowledgeGraph");
|
||||
assert!(kg.knows_fact(&FactId("investigation.inspection_lapses".to_string())));
|
||||
}
|
||||
|
||||
@@ -939,15 +946,39 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_relationship_kinds() {
|
||||
assert_eq!(parse_relationship_kind("friend"), npc::RelationshipKind::Friend);
|
||||
assert_eq!(parse_relationship_kind("colleague"), npc::RelationshipKind::Colleague);
|
||||
assert_eq!(parse_relationship_kind("family"), npc::RelationshipKind::Family);
|
||||
assert_eq!(parse_relationship_kind("romantic"), npc::RelationshipKind::Romantic);
|
||||
assert_eq!(parse_relationship_kind("superior"), npc::RelationshipKind::Superior);
|
||||
assert_eq!(parse_relationship_kind("subordinate"), npc::RelationshipKind::Subordinate);
|
||||
assert_eq!(parse_relationship_kind("rival"), npc::RelationshipKind::Rival);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("friend"),
|
||||
npc::RelationshipKind::Friend
|
||||
);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("colleague"),
|
||||
npc::RelationshipKind::Colleague
|
||||
);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("family"),
|
||||
npc::RelationshipKind::Family
|
||||
);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("romantic"),
|
||||
npc::RelationshipKind::Romantic
|
||||
);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("superior"),
|
||||
npc::RelationshipKind::Superior
|
||||
);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("subordinate"),
|
||||
npc::RelationshipKind::Subordinate
|
||||
);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("rival"),
|
||||
npc::RelationshipKind::Rival
|
||||
);
|
||||
// Unknown defaults to Colleague
|
||||
assert_eq!(parse_relationship_kind("acquaintance"), npc::RelationshipKind::Colleague);
|
||||
assert_eq!(
|
||||
parse_relationship_kind("acquaintance"),
|
||||
npc::RelationshipKind::Colleague
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user