diff --git a/config/config.toml b/config/config.toml index fab865f..59839f4 100644 --- a/config/config.toml +++ b/config/config.toml @@ -28,7 +28,7 @@ announcement = "Buying cheese and selling stuff" # Crafting "crafting_ing.alkahest" = 6_000 "crafting_ing.brinestone" = 2_000 -"crafting_ing.coral_brach" = 1_000 +"crafting_ing.coral_branch" = 1_000 "crafting_ing.hide.dragon_scale" = 5_000 "crafting_ing.dwarven_battery" = 40_000 "log.eldwood" = 3_000 @@ -42,6 +42,7 @@ announcement = "Buying cheese and selling stuff" "glider.skullgrin" = 20_000 # Recipes +"recipes.armor.brinestone" = 8_000 "recipes.equipment.advanced" = 8_000 "recipes.unique.mindflayer_spellbag" = 10_000 "recipes.unique.abyssal_gorget" = 6_000 diff --git a/src/bot.rs b/src/bot.rs index f2bacba..7a056b4 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -1,5 +1,5 @@ use std::{ - collections::BTreeMap, + collections::HashMap, sync::Arc, time::{Duration, Instant}, }; @@ -33,8 +33,8 @@ pub struct Bot { client: Client, clock: Clock, - buy_prices: BTreeMap, - sell_prices: BTreeMap, + buy_prices: HashMap, + sell_prices: HashMap, trade_mode: TradeMode, last_trade_action: Instant, @@ -46,13 +46,14 @@ pub struct Bot { impl Bot { /// Connect to the official veloren server, select the specified character /// and return a Bot instance ready to run. + #[allow(clippy::too_many_arguments)] pub fn new( username: String, password: &str, character: &str, admins: Vec, - buy_prices: BTreeMap, - sell_prices: BTreeMap, + buy_prices: HashMap, + sell_prices: HashMap, position: [f32; 3], orientation: f32, announcement: String, @@ -78,10 +79,10 @@ impl Bot { .characters .iter() .find(|character_item| character_item.character.alias == character) - .expect(&format!("No character named {character}")) + .ok_or_else(|| format!("No character named {character}"))? .character .id - .expect("Failed to get character ID"); + .ok_or("Failed to get character ID")?; client.request_character( character_id, diff --git a/src/main.rs b/src/main.rs index 86594cf..2e0f758 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,6 @@ fn main() { toml::from_str::(&file_content).expect("Failed to parse secrets") }; - let config = { let config_path = var("CONFIG").expect("Provide a CONFIG variable specifying the config file"); @@ -42,7 +41,6 @@ fn main() { toml::from_str::(&file_content).expect("Failed to parse config") }; - let buy_prices_with_full_id = config .buy_prices .into_iter() @@ -61,7 +59,6 @@ fn main() { (item_id, price) }) .collect(); - let mut bot = Bot::new( secrets.username, &secrets.password,