summaryrefslogtreecommitdiff
path: root/server/bot/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-16 18:00:28 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-16 18:00:35 +0200
commit499f4994a6a8507dcca20ed820c851be9a2343c1 (patch)
tree9100c6c924e116e811d94d7188353f87819d02d3 /server/bot/src
parent709fd5ddaaec290165e85b48b237cb82563b9e87 (diff)
downloadhurrycurry-499f4994a6a8507dcca20ed820c851be9a2343c1.tar
hurrycurry-499f4994a6a8507dcca20ed820c851be9a2343c1.tar.bz2
hurrycurry-499f4994a6a8507dcca20ed820c851be9a2343c1.tar.zst
fix all clippy things
Diffstat (limited to 'server/bot/src')
-rw-r--r--server/bot/src/algos/customer.rs7
-rw-r--r--server/bot/src/algos/frank.rs10
-rw-r--r--server/bot/src/algos/mod.rs7
-rw-r--r--server/bot/src/algos/test.rs10
-rw-r--r--server/bot/src/main.rs2
5 files changed, 16 insertions, 20 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index 61a79dbc..1b1315c6 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -25,7 +25,9 @@ use log::info;
use rand::{random, seq::IndexedRandom, thread_rng};
#[derive(Debug, Clone)]
+#[derive(Default)]
pub enum Customer {
+ #[default]
New,
Entering {
path: Path,
@@ -50,11 +52,6 @@ pub enum Customer {
},
}
-impl Default for Customer {
- fn default() -> Self {
- Customer::New
- }
-}
impl BotAlgo for Customer {
fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput {
diff --git a/server/bot/src/algos/frank.rs b/server/bot/src/algos/frank.rs
index 980d8c08..95718d4c 100644
--- a/server/bot/src/algos/frank.rs
+++ b/server/bot/src/algos/frank.rs
@@ -35,13 +35,13 @@ pub struct Frank {
const MESSAGES: &[fn(&str) -> String] = &[
|_name| format!("Work faster, {_name}!"),
- |_name| format!("Quick! There is no time for chit-chat!"),
- |_name| format!("Look what a mess you've made! Clean this up immediatly!"),
- |_name| format!("Don't let the customers starve!"),
+ |_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| format!("I'm not paying you to stand around!"),
+ |_name| "I'm not paying you to stand around!".to_string(),
|_name| format!("Get back to work, {_name}!"),
- |_name| format!("You're FIRED!"),
+ |_name| "You're FIRED!".to_string(),
];
impl BotAlgo for Frank {
diff --git a/server/bot/src/algos/mod.rs b/server/bot/src/algos/mod.rs
index bb1d615b..dea31406 100644
--- a/server/bot/src/algos/mod.rs
+++ b/server/bot/src/algos/mod.rs
@@ -16,18 +16,19 @@
*/
mod customer;
+mod frank;
mod simple;
mod test;
mod waiter;
-pub mod frank;
pub use customer::Customer;
+pub use frank::Frank;
pub use simple::Simple;
pub use test::Test;
pub use waiter::Waiter;
-pub use frank::Frank;
-pub const ALGO_CONSTRUCTORS: &'static [(&'static str, fn() -> crate::DynBotAlgo)] = &[
+#[allow(clippy::type_complexity)]
+pub const ALGO_CONSTRUCTORS: &[(&str, fn() -> crate::DynBotAlgo)] = &[
("test", || Box::new(Test::default())),
("simple", || Box::new(Simple::default())),
("waiter", || Box::new(Waiter::default())),
diff --git a/server/bot/src/algos/test.rs b/server/bot/src/algos/test.rs
index 73368de2..7cfafc29 100644
--- a/server/bot/src/algos/test.rs
+++ b/server/bot/src/algos/test.rs
@@ -43,12 +43,10 @@ impl BotAlgo for Test {
interact: None,
..Default::default()
};
- } else {
- if let Some((item, near)) = find_demand(game) {
- info!("demand {item:?} near {near}");
- if let Some(path) = find_path_to_neighbour(&game.walkable, pos.as_ivec2(), near) {
- self.path = Some(path);
- }
+ } else if let Some((item, near)) = find_demand(game) {
+ info!("demand {item:?} near {near}");
+ if let Some(path) = find_path_to_neighbour(&game.walkable, pos.as_ivec2(), near) {
+ self.path = Some(path);
}
}
BotInput::default()
diff --git a/server/bot/src/main.rs b/server/bot/src/main.rs
index bb30cb68..d4d21d35 100644
--- a/server/bot/src/main.rs
+++ b/server/bot/src/main.rs
@@ -76,7 +76,7 @@ fn main() -> Result<()> {
.iter()
.find(|(n, _)| n == &args.algo)
.map(|(_, c)| c())
- .expect(&format!("unknown algo {:?}", args.algo)),
+ .unwrap_or_else(|| panic!("unknown algo {:?}", args.algo)),
}),
PacketC::Error { message } => {
warn!("server error message: {message}");