diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-17 22:19:06 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-17 22:19:06 +0200 |
commit | cc96993499c435ea706fa21a6d8089604bc44e51 (patch) | |
tree | a55f9595ca3064a1afb9494f1b9a5632616863cf /server/src/entity/tutorial.rs | |
parent | 4a7480a90bc54eccd2a00ded45624783fcd1179c (diff) | |
download | hurrycurry-cc96993499c435ea706fa21a6d8089604bc44e51.tar hurrycurry-cc96993499c435ea706fa21a6d8089604bc44e51.tar.bz2 hurrycurry-cc96993499c435ea706fa21a6d8089604bc44e51.tar.zst |
translate tutorial and add tile message
Diffstat (limited to 'server/src/entity/tutorial.rs')
-rw-r--r-- | server/src/entity/tutorial.rs | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/server/src/entity/tutorial.rs b/server/src/entity/tutorial.rs index 24c83550..fba43fd0 100644 --- a/server/src/entity/tutorial.rs +++ b/server/src/entity/tutorial.rs @@ -1,3 +1,5 @@ +use crate::trm; + use super::{Entity, EntityContext}; use anyhow::Result; use hurrycurry_protocol::{ @@ -41,7 +43,7 @@ impl Entity for Tutorial { if self.delete_timer <= 0. { hint = None } else { - hint = Some((None, Message::Text("Tutorial finished.".to_string()))); + hint = Some((None, trm!("s.tutorial.finished"))); } } @@ -122,23 +124,20 @@ impl<'a> StepContext<'a> { return Ok(pos); } self.aquire_item(item)?; - Err((None, Message::Text("put down this item".to_string()))) + Err((None, trm!("s.tutorial.put_away"))) } fn aquire_item(&mut self, item: ItemIndex) -> Result<(), (Option<IVec2>, Message)> { debug!("aquire item {:?}", self.ent.game.data.item_names[item.0]); self.recursion_abort += 1; if self.recursion_abort > 32 { warn!("too much recursion"); - return Err(( - None, - Message::Text("server cant handle the recipe, too much recursion".to_string()), - )); + return Err((None, trm!("s.tutorial.error"))); } if self.is_hand_item(item) { return Ok(()); } if let Some(pos) = self.find_item_on_map(item) { - return Err((Some(pos), Message::Text("pickup".to_string()))); + return Err((Some(pos), trm!("s.tutorial.pickup"))); } if let Some(recipe) = self.find_recipe_with_output(item) { let r = &self.ent.game.data.recipes[recipe.0]; @@ -149,7 +148,7 @@ impl<'a> StepContext<'a> { .. } => { if let Some(pos) = self.find_tile(*tile) { - return Err((Some(pos), Message::Text("take from crate".to_string()))); + return Err((Some(pos), trm!("s.tutorial.take", i = item))); } } Recipe::Instant { @@ -159,7 +158,7 @@ impl<'a> StepContext<'a> { } => { let apos = self.aquire_placed_item(*a)?; self.aquire_item(*b)?; - return Err((Some(apos), Message::Text("interact here".to_string()))); + return Err((Some(apos), trm!("s.tutorial.interact"))); } Recipe::Instant { tile: None, @@ -167,7 +166,7 @@ impl<'a> StepContext<'a> { .. } => { self.aquire_item(*input)?; - return Err((None, Message::Text("interact with empty tile".to_string()))); + return Err((None, trm!("s.tutorial.interact_empty"))); } Recipe::Active { tile: Some(tile), @@ -178,18 +177,13 @@ impl<'a> StepContext<'a> { if let Some(pos) = self.find_tile(*tile) { if let Some(item) = &self.ent.game.tiles.get(&pos).unwrap().item { if item.kind == *input { - return Err(( - Some(pos), - Message::Text(format!("hold interact here")), - )); - } else { - return Err((Some(pos), Message::Text(format!("clear tile")))); + return Err((Some(pos), trm!("s.tutorial.hold_interact"))); } } self.aquire_item(*input)?; return Err(( Some(pos), - Message::Text(format!("active here for {:.01}s", 1. / speed)), + trm!("s.tutorial.active", s = format!("{:.01}", 1. / speed)), )); } } @@ -201,26 +195,18 @@ impl<'a> StepContext<'a> { if let Some(pos) = self.find_tile(*tile) { if let Some(item) = &self.ent.game.tiles.get(&pos).unwrap().item { if item.kind == *input { - return Err((Some(pos), Message::Text(format!("wait for finish")))); - } else { - return Err((Some(pos), Message::Text(format!("clear tile")))); + return Err((Some(pos), trm!("s.tutorial.wait_finish"))); } } self.aquire_item(*input)?; - return Err(( - Some(pos), - Message::Text(format!( - "put on {}", - self.ent.game.data.tile_name(*tile) - )), - )); + return Err((Some(pos), trm!("s.tutorial.put_on", t = *tile))); } } Recipe::Passive { tile: None, input, .. } => { self.aquire_item(*input)?; - return Err((None, Message::Text(format!("wait for finish")))); + return Err((None, trm!("s.tutorial.wait_finish"))); } _ => warn!("recipe too hard {r:?}"), } @@ -229,6 +215,6 @@ impl<'a> StepContext<'a> { "stuck at making item {:?}", self.ent.game.data.item_names[item.0] ); - Err((None, Message::Text(format!("stuck")))) + Err((None, trm!("s.tutorial.error"))) } } |