From 91d0f50fd42e214f9cc7d1166bcc354babb5e17a Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 18 Jul 2024 06:03:00 -0400 Subject: [PATCH] Clean up with clippy; Try gitea action --- .gitea/workflows/publish.yaml | 20 ++++++++++++++++++++ config/config.toml | 1 + src/bot.rs | 20 +++++++++----------- 3 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 .gitea/workflows/publish.yaml diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..2d18fad --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,20 @@ +name: Podman Image CI + +on: + push: + branches: ["main"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install Podman + run: | + sudo apt-get update + sudo apt-get install -y podman + - name: Build the image + run: podman build --tag git.jeffa.io/jeff/trade_bot . + - name: Push the image + run: podman push git.jeffa.io/jeff/trade_bot diff --git a/config/config.toml b/config/config.toml index 9b427ee..70e98b7 100644 --- a/config/config.toml +++ b/config/config.toml @@ -6,6 +6,7 @@ orientation = 0 "iron|sword.greatsword|sword.long" = 1_000 [sell_prices] +"food.cheese" = 1_000_000 "consumable.potion_minor" = 150 # Modular Weapons diff --git a/src/bot.rs b/src/bot.rs index 46302ee..d1835bd 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -33,7 +33,6 @@ use crate::config::PriceList; const COINS: ItemDefinitionId = ItemDefinitionId::Simple(Cow::Borrowed("common.items.utility.coins")); - const CLIENT_TPS: Duration = Duration::from_millis(33); const TRADE_ACTION_DELAY: Duration = Duration::from_millis(300); const ACCOUNCEMENT_DELAY: Duration = Duration::from_mins(45); @@ -41,8 +40,6 @@ const OUCH_DELAY: Duration = Duration::from_secs(2); /// An active connection to the Veloren server that will attempt to run every time the `tick` /// function is called. -/// -/// See the [module-level documentation](index.html) for more information. pub struct Bot { username: String, position: Pos, @@ -132,10 +129,7 @@ impl Bot { let position = if let Some(coords) = position { Pos(coords.into()) } else { - client - .position() - .map(|coords| Pos(coords)) - .ok_or("Failed to get position")? + client.position().map(Pos).ok_or("Failed to get position")? }; let orientation = if let Some(orientation) = orientation { Ori::new(Quaternion::rotation_z(orientation.to_radians())) @@ -303,7 +297,7 @@ impl Bot { } "price" => { for item_name in split_content { - self.send_price_info(&sender, &item_name)?; + self.send_price_info(&sender, item_name)?; } None @@ -725,8 +719,10 @@ impl Bot { self.client.perform_trade_action(TradeAction::Accept(phase)); return Ok(()); - // If they are offering more - } else if difference > 0 { + } + + // If they are offering more + if difference > 0 { // If they are offering coins if their_offered_coin_amount > 0 { if let Some(their_coins) = get_their_coins { @@ -764,8 +760,10 @@ impl Bot { ), ], ); + } + // If I am offering more - } else if difference < 0 { + if difference < 0 { // If I am offering coins if my_offered_coin_amount > 0 { if let Some(my_coins) = get_my_coins {