diff options
Diffstat (limited to 'server/src/entity/bot.rs')
-rw-r--r-- | server/src/entity/bot.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/server/src/entity/bot.rs b/server/src/entity/bot.rs index cd505c4f..fe4d711f 100644 --- a/server/src/entity/bot.rs +++ b/server/src/entity/bot.rs @@ -18,7 +18,7 @@ use super::{Entity, EntityContext}; use anyhow::Result; use hurrycurry_bot::{BotAlgo, DynBotAlgo}; -use hurrycurry_protocol::{PacketS, PlayerID}; +use hurrycurry_protocol::{PacketS, PlayerClass, PlayerID}; use log::info; use rand::random; use std::any::Any; @@ -27,19 +27,19 @@ pub type DynBotDriver = BotDriver<DynBotAlgo>; pub struct BotDriver<T> { algo: T, - join_data: Option<(String, i32)>, + join_data: Option<(String, i32, PlayerClass)>, id: PlayerID, interacting: bool, left: bool, } impl<T: BotAlgo> BotDriver<T> { - pub fn new(name: String, character: i32, algo: T) -> Self { + pub fn new(name: String, character: i32, class: PlayerClass, algo: T) -> Self { Self { algo, id: PlayerID(0), interacting: false, - join_data: Some((name, character)), + join_data: Some((name, character, class)), left: false, } } @@ -49,13 +49,14 @@ impl<T: BotAlgo + Any> Entity for BotDriver<T> { self.left } fn tick(&mut self, c: EntityContext<'_>) -> Result<()> { - if let Some((name, character)) = self.join_data.take() { + if let Some((name, character, class)) = self.join_data.take() { self.id = PlayerID(random()); // TODO bad code, can collide info!("spawn {:?} ({name:?}, {character})", self.id); c.packet_in.push_back(PacketS::Join { name, character, id: Some(self.id), + class, }) } |