From 07dd1b1dab03fb46e548e6a0e9d0311ac2111a36 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 20 Sep 2024 16:23:31 +0200 Subject: /end-tutorial --- server/src/commands.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'server/src/commands.rs') 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| ::downcast_mut::(e.as_mut())) + { + tutorial.ended = true; + } else { + bail!("No tutorial running") + } + } Command::TranslateMessage { message_id, arguments, -- cgit v1.2.3-70-g09d2