aboutsummaryrefslogtreecommitdiff
path: root/server/src/commands.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-17 16:57:23 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-17 16:57:34 +0200
commit7cacd111e2b443bac291244b168c20e2c8bf69ec (patch)
tree277ace5a4e8223df4b156e766c2660406101a82b /server/src/commands.rs
parent77a73b415888b0285ba64b27c3f69440216e475c (diff)
downloadhurrycurry-7cacd111e2b443bac291244b168c20e2c8bf69ec.tar
hurrycurry-7cacd111e2b443bac291244b168c20e2c8bf69ec.tar.bz2
hurrycurry-7cacd111e2b443bac291244b168c20e2c8bf69ec.tar.zst
add hint-based tutorial for item crafting
Diffstat (limited to 'server/src/commands.rs')
-rw-r--r--server/src/commands.rs30
1 files changed, 26 insertions, 4 deletions
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 <https://www.gnu.org/licenses/>.
*/
-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<String> },
+ CreateBot {
+ algo: String,
+ name: Option<String>,
+ },
/// 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(())
}