diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-17 21:21:51 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-17 21:21:51 +0200 |
commit | 666adbf669afc06d87aa28f1a8ca120c5612d3a4 (patch) | |
tree | ef2b168a272649f000957a081ce4119bfd7909ec /server | |
parent | 7cacd111e2b443bac291244b168c20e2c8bf69ec (diff) | |
download | hurrycurry-666adbf669afc06d87aa28f1a8ca120c5612d3a4.tar hurrycurry-666adbf669afc06d87aa28f1a8ca120c5612d3a4.tar.bz2 hurrycurry-666adbf669afc06d87aa28f1a8ca120c5612d3a4.tar.zst |
localized messages
Diffstat (limited to 'server')
-rw-r--r-- | server/protocol/src/lib.rs | 1 | ||||
-rw-r--r-- | server/src/commands.rs | 23 |
2 files changed, 23 insertions, 1 deletions
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs index 706747f4..1bfb280e 100644 --- a/server/protocol/src/lib.rs +++ b/server/protocol/src/lib.rs @@ -139,6 +139,7 @@ pub enum PacketS { #[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, PartialEq, Eq)] #[serde(rename_all = "snake_case")] pub enum Message { + Translation { id: String, params: Vec<Message> }, Text(String), Item(ItemIndex), Effect(String), diff --git a/server/src/commands.rs b/server/src/commands.rs index 904305bf..d6ca8b25 100644 --- a/server/src/commands.rs +++ b/server/src/commands.rs @@ -22,7 +22,7 @@ use crate::{ use anyhow::{anyhow, bail, Result}; use clap::{Parser, ValueEnum}; use hurrycurry_bot::algos::ALGO_CONSTRUCTORS; -use hurrycurry_protocol::{Menu, Message, PacketC, PlayerID}; +use hurrycurry_protocol::{Menu, Message, MessageTimeout, PacketC, PlayerID}; use std::{fmt::Write, time::Duration}; #[derive(Parser)] @@ -83,6 +83,11 @@ enum Command { StartTutorial { item: String, }, + #[clap(alias = "tr")] + TranslateMessage { + message_id: String, + arguments: Vec<String>, + }, } #[derive(ValueEnum, Clone)] @@ -239,6 +244,22 @@ impl Server { // TODO prevent too many (> 1) tutorials for this player self.entities.push(Box::new(Tutorial::new(player, item))); } + Command::TranslateMessage { + message_id, + arguments, + } => { + self.packet_out.push_back(PacketC::Communicate { + player, + message: Some(Message::Translation { + id: message_id, + params: arguments.into_iter().map(|c| Message::Text(c)).collect(), + }), + timeout: Some(MessageTimeout { + initial: 5., + remaining: 5., + }), + }); + } } Ok(()) } |