diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-20 16:23:31 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-20 16:23:31 +0200 |
commit | 07dd1b1dab03fb46e548e6a0e9d0311ac2111a36 (patch) | |
tree | 9197f9e04face3bea0ec8a5fc2109979e7dc2264 /server/src/commands.rs | |
parent | b31d4b9fa1c8e1a17139e9aaf03d18c9c27e0c18 (diff) | |
download | hurrycurry-07dd1b1dab03fb46e548e6a0e9d0311ac2111a36.tar hurrycurry-07dd1b1dab03fb46e548e6a0e9d0311ac2111a36.tar.bz2 hurrycurry-07dd1b1dab03fb46e548e6a0e9d0311ac2111a36.tar.zst |
/end-tutorial
Diffstat (limited to 'server/src/commands.rs')
-rw-r--r-- | server/src/commands.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/server/src/commands.rs b/server/src/commands.rs index dab0e540..c03c8bcd 100644 --- a/server/src/commands.rs +++ b/server/src/commands.rs @@ -81,9 +81,11 @@ enum Command { Reload, /// Shows the recipe book Book, + #[clap(alias = "tutorial")] StartTutorial { item: String, }, + EndTutorial, #[clap(alias = "tr")] TranslateMessage { message_id: String, @@ -270,6 +272,18 @@ impl Server { } self.entities.push(Box::new(Tutorial::new(player, item))); } + Command::EndTutorial => { + #[cfg(not(test))] // TODO rust-analyser does not undestand trait upcasting + if let Some(tutorial) = self + .entities + .iter_mut() + .find_map(|e| <dyn std::any::Any>::downcast_mut::<Tutorial>(e.as_mut())) + { + tutorial.ended = true; + } else { + bail!("No tutorial running") + } + } Command::TranslateMessage { message_id, arguments, |