This commit is contained in:
Jeff 2024-07-12 23:54:44 -04:00
parent 3582917005
commit 637ead2914
3 changed files with 10 additions and 11 deletions

View File

@ -28,7 +28,7 @@ announcement = "Buying cheese and selling stuff"
# Crafting # Crafting
"crafting_ing.alkahest" = 6_000 "crafting_ing.alkahest" = 6_000
"crafting_ing.brinestone" = 2_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.hide.dragon_scale" = 5_000
"crafting_ing.dwarven_battery" = 40_000 "crafting_ing.dwarven_battery" = 40_000
"log.eldwood" = 3_000 "log.eldwood" = 3_000
@ -42,6 +42,7 @@ announcement = "Buying cheese and selling stuff"
"glider.skullgrin" = 20_000 "glider.skullgrin" = 20_000
# Recipes # Recipes
"recipes.armor.brinestone" = 8_000
"recipes.equipment.advanced" = 8_000 "recipes.equipment.advanced" = 8_000
"recipes.unique.mindflayer_spellbag" = 10_000 "recipes.unique.mindflayer_spellbag" = 10_000
"recipes.unique.abyssal_gorget" = 6_000 "recipes.unique.abyssal_gorget" = 6_000

View File

@ -1,5 +1,5 @@
use std::{ use std::{
collections::BTreeMap, collections::HashMap,
sync::Arc, sync::Arc,
time::{Duration, Instant}, time::{Duration, Instant},
}; };
@ -33,8 +33,8 @@ pub struct Bot {
client: Client, client: Client,
clock: Clock, clock: Clock,
buy_prices: BTreeMap<String, u32>, buy_prices: HashMap<String, u32>,
sell_prices: BTreeMap<String, u32>, sell_prices: HashMap<String, u32>,
trade_mode: TradeMode, trade_mode: TradeMode,
last_trade_action: Instant, last_trade_action: Instant,
@ -46,13 +46,14 @@ pub struct Bot {
impl Bot { impl Bot {
/// Connect to the official veloren server, select the specified character /// Connect to the official veloren server, select the specified character
/// and return a Bot instance ready to run. /// and return a Bot instance ready to run.
#[allow(clippy::too_many_arguments)]
pub fn new( pub fn new(
username: String, username: String,
password: &str, password: &str,
character: &str, character: &str,
admins: Vec<String>, admins: Vec<String>,
buy_prices: BTreeMap<String, u32>, buy_prices: HashMap<String, u32>,
sell_prices: BTreeMap<String, u32>, sell_prices: HashMap<String, u32>,
position: [f32; 3], position: [f32; 3],
orientation: f32, orientation: f32,
announcement: String, announcement: String,
@ -78,10 +79,10 @@ impl Bot {
.characters .characters
.iter() .iter()
.find(|character_item| character_item.character.alias == character) .find(|character_item| character_item.character.alias == character)
.expect(&format!("No character named {character}")) .ok_or_else(|| format!("No character named {character}"))?
.character .character
.id .id
.expect("Failed to get character ID"); .ok_or("Failed to get character ID")?;
client.request_character( client.request_character(
character_id, character_id,

View File

@ -34,7 +34,6 @@ fn main() {
toml::from_str::<Secrets>(&file_content).expect("Failed to parse secrets") toml::from_str::<Secrets>(&file_content).expect("Failed to parse secrets")
}; };
let config = { let config = {
let config_path = let config_path =
var("CONFIG").expect("Provide a CONFIG variable specifying the config file"); var("CONFIG").expect("Provide a CONFIG variable specifying the config file");
@ -42,7 +41,6 @@ fn main() {
toml::from_str::<Config>(&file_content).expect("Failed to parse config") toml::from_str::<Config>(&file_content).expect("Failed to parse config")
}; };
let buy_prices_with_full_id = config let buy_prices_with_full_id = config
.buy_prices .buy_prices
.into_iter() .into_iter()
@ -61,7 +59,6 @@ fn main() {
(item_id, price) (item_id, price)
}) })
.collect(); .collect();
let mut bot = Bot::new( let mut bot = Bot::new(
secrets.username, secrets.username,
&secrets.password, &secrets.password,