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_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

View File

@ -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<String, u32>,
sell_prices: BTreeMap<String, u32>,
buy_prices: HashMap<String, u32>,
sell_prices: HashMap<String, u32>,
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<String>,
buy_prices: BTreeMap<String, u32>,
sell_prices: BTreeMap<String, u32>,
buy_prices: HashMap<String, u32>,
sell_prices: HashMap<String, u32>,
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,

View File

@ -34,7 +34,6 @@ fn main() {
toml::from_str::<Secrets>(&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::<Config>(&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,