From 7cacd111e2b443bac291244b168c20e2c8bf69ec Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 17 Sep 2024 16:57:23 +0200 Subject: add hint-based tutorial for item crafting --- server/src/commands.rs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'server/src/commands.rs') diff --git a/server/src/commands.rs b/server/src/commands.rs index 96d9ab75..904305bf 100644 --- a/server/src/commands.rs +++ b/server/src/commands.rs @@ -15,7 +15,10 @@ along with this program. If not, see . */ -use crate::{entity::bot::BotDriver, server::Server}; +use crate::{ + entity::{bot::BotDriver, tutorial::Tutorial}, + server::Server, +}; use anyhow::{anyhow, bail, Result}; use clap::{Parser, ValueEnum}; use hurrycurry_bot::algos::ALGO_CONSTRUCTORS; @@ -58,18 +61,28 @@ enum Command { /// List all recipes and maps List, /// Send an effect - Effect { name: String }, + Effect { + name: String, + }, /// Send an item - Item { name: String }, + Item { + name: String, + }, /// Reload the resource index ReloadIndex, #[clap(alias = "summon-bot", alias = "spawn-bot")] - CreateBot { algo: String, name: Option }, + CreateBot { + algo: String, + name: Option, + }, /// Reload the current map #[clap(alias = "r")] Reload, /// Shows the recipe book Book, + StartTutorial { + item: String, + }, } #[derive(ValueEnum, Clone)] @@ -217,6 +230,15 @@ impl Server { info.players ) } + Command::StartTutorial { item } => { + let item = self + .game + .data + .get_item_by_name(&item) + .ok_or(anyhow!("unknown item"))?; + // TODO prevent too many (> 1) tutorials for this player + self.entities.push(Box::new(Tutorial::new(player, item))); + } } Ok(()) } -- cgit v1.2.3-70-g09d2