From 85285f9b8efb2444a4eba494b17fcff537eda739 Mon Sep 17 00:00:00 2001 From: Jonathan Berglin Date: Thu, 1 Jul 2021 15:59:05 +0000 Subject: [PATCH] Tygyh/bot main refactor --- client/src/bin/bot/main.rs | 44 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/client/src/bin/bot/main.rs b/client/src/bin/bot/main.rs index 162de7658f..3a9cf6630c 100644 --- a/client/src/bin/bot/main.rs +++ b/client/src/bin/bot/main.rs @@ -12,6 +12,7 @@ use veloren_client::{addr::ConnectionArgs, Client}; mod settings; mod tui; +use common::comp::body::humanoid::Body; use settings::Settings; use tui::Cmd; @@ -51,13 +52,13 @@ pub struct BotClient { } pub fn make_client(runtime: &Arc, server: &str) -> Client { - let runtime2 = Arc::clone(&runtime); + let runtime_clone = Arc::clone(&runtime); let addr = ConnectionArgs::Tcp { prefer_ipv6: false, hostname: server.to_owned(), }; runtime - .block_on(Client::new(addr, runtime2, &mut None)) + .block_on(Client::new(addr, runtime_clone, &mut None)) .expect("Failed to connect to server") } @@ -78,16 +79,9 @@ impl BotClient { pub fn tick(&mut self) { self.clock.tick(); for (username, client) in self.bot_clients.iter_mut() { - //trace!("cl {:?}: {:?}", username, client.character_list()); trace!(?username, "tick"); let _msgs: Result, veloren_client::Error> = client.tick(comp::ControllerInputs::default(), self.clock.dt(), |_| {}); - /*trace!( - "msgs {:?}: {:?} {:?}", - username, - msgs, - client.character_list() - );*/ } } @@ -176,33 +170,31 @@ impl BotClient { )) { warn!("error logging in {:?}: {:?}", cred.username, e); } - /*let body = comp::body::biped_large::Body { - species: comp::body::biped_large::Species::Dullahan, - body_type: comp::body::biped_large::BodyType::Male, - };*/ - let body = comp::body::humanoid::Body { - species: comp::body::humanoid::Species::Human, - body_type: comp::body::humanoid::BodyType::Male, - hair_style: 0, - beard: 0, - eyes: 0, - accessory: 0, - hair_color: 0, - skin: 0, - eye_color: 0, - }; + let body = BotClient::create_default_body(); client.create_character( cred.username.clone(), Some("common.items.weapons.sword.starter".to_string()), body.into(), ); client.load_character_list(); - //client.create_character(cred.username.clone(), - // Some("common.items.debug.admin_stick".to_string()), body.into()); } info!("login done"); } + fn create_default_body() -> Body { + comp::body::humanoid::Body { + species: comp::body::humanoid::Species::Human, + body_type: comp::body::humanoid::BodyType::Male, + hair_style: 0, + beard: 0, + eyes: 0, + accessory: 0, + hair_color: 0, + skin: 0, + eye_color: 0, + } + } + pub fn handle_ingame_join(&mut self, prefix: &str) { let creds: Vec<_> = self .settings