summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-12-22 19:57:47 +0100
committermetamuffin <metamuffin@disroot.org>2024-12-22 19:57:47 +0100
commit4cbbb0b7deb686789eff439b6c5cc78535a3c431 (patch)
treeac38c5017f4df2a2974d72aa09c9e380d93d8a68 /server
parent105b2be1cbf70abc6c609fc64cbc44cb38219662 (diff)
downloadhurrycurry-4cbbb0b7deb686789eff439b6c5cc78535a3c431.tar
hurrycurry-4cbbb0b7deb686789eff439b6c5cc78535a3c431.tar.bz2
hurrycurry-4cbbb0b7deb686789eff439b6c5cc78535a3c431.tar.zst
translate frank lines, fixes #229
Diffstat (limited to 'server')
-rw-r--r--server/bot/src/algos/frank.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/server/bot/src/algos/frank.rs b/server/bot/src/algos/frank.rs
index 1e02e297..47b8ca7d 100644
--- a/server/bot/src/algos/frank.rs
+++ b/server/bot/src/algos/frank.rs
@@ -21,7 +21,7 @@ use crate::{
};
use hurrycurry_client_lib::Game;
use hurrycurry_protocol::{glam::Vec2, Message, PacketS, PlayerClass, PlayerID};
-use rand::{seq::IndexedRandom, thread_rng};
+use rand::{random, seq::IndexedRandom, thread_rng};
#[derive(Default)]
pub struct Frank {
@@ -33,17 +33,6 @@ pub struct Frank {
path: Option<Path>,
}
-const MESSAGES: &[fn(&str) -> String] = &[
- |_name| format!("Work faster, {_name}!"),
- |_name| "Quick! There is no time for chit-chat!".to_string(),
- |_name| "Look what a mess you've made! Clean this up immediatly!".to_string(),
- |_name| "Don't let the customers starve!".to_string(),
- |_name| format!("You are wasting me money, {_name}!"),
- |_name| "I'm not paying you to stand around!".to_string(),
- |_name| format!("Get back to work, {_name}!"),
- |_name| "You're FIRED!".to_string(),
-];
-
impl BotAlgo for Frank {
fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput {
let Some(player) = game.players.get(&me) else {
@@ -78,11 +67,13 @@ impl BotAlgo for Frank {
if pos.distance(tpos) < 2. {
self.sleep = 8.;
self.idle = 15.;
- let message = MESSAGES.choose(&mut thread_rng()).unwrap()(&player.name);
return BotInput {
extra: vec![PacketS::Communicate {
player: me,
- message: Some(Message::Text(message)),
+ message: Some(Message::Translation {
+ id: format!("s.bot.frank.line.{}", random::<u32>() % 8),
+ params: vec![Message::Text(player.name.clone())],
+ }),
timeout: Some(3.),
pin: Some(false),
}],