diff options
Diffstat (limited to 'server/src/commands.rs')
-rw-r--r-- | server/src/commands.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/server/src/commands.rs b/server/src/commands.rs index 8e6f32c7..f5792a22 100644 --- a/server/src/commands.rs +++ b/server/src/commands.rs @@ -239,7 +239,18 @@ impl Server { .data .get_item_by_name(&item) .ok_or(anyhow!("unknown item"))?; - // TODO prevent too many (> 1) tutorials for this player + #[cfg(not(test))] // TODO rust-analyser does not undestand trait upcasting + if self + .entities + .iter() + .find(|e| { + <dyn std::any::Any>::downcast_ref::<Tutorial>(e.as_ref()) + .map_or(false, |t| t.player == player) + }) + .is_some() + { + bail!("Tutorial already running") + } self.entities.push(Box::new(Tutorial::new(player, item))); } Command::TranslateMessage { |