diff options
author | metamuffin <metamuffin@disroot.org> | 2024-12-25 19:37:20 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-12-25 20:01:43 +0100 |
commit | 4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf (patch) | |
tree | 5ec12de003c38f0891c215721593c7ea49ff2c16 /server/bot | |
parent | 15be00667282a253fb438fec9d6347f5af89d9a0 (diff) | |
download | hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar.bz2 hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar.zst |
variable hand count
Diffstat (limited to 'server/bot')
-rw-r--r-- | server/bot/src/algos/customer.rs | 13 | ||||
-rw-r--r-- | server/bot/src/algos/simple.rs | 13 | ||||
-rw-r--r-- | server/bot/src/main.rs | 2 |
3 files changed, 14 insertions, 14 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 826ab534..b0ece9dd 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -313,7 +313,7 @@ impl CustomerState { PacketS::Interact { pos: Some(pos), player: me, - hand: Hand::Left, + hand: Hand(0), }, PacketS::ApplyScore(Score { demands_completed: 1, @@ -323,7 +323,7 @@ impl CustomerState { PacketS::Interact { pos: None, player: me, - hand: Hand::Left, + hand: Hand(0), }, ], ..Default::default() @@ -356,7 +356,7 @@ impl CustomerState { extra: vec![PacketS::ReplaceHand { player: me, item: demand.output, - hand: Hand::Left, + hand: Hand(0), }], ..Default::default() }; @@ -375,7 +375,8 @@ impl CustomerState { if game .players .get(&me) - .is_some_and(|pl| pl.items[Hand::Left.index()].is_none()) + .is_some_and(|pl| pl.items[0].is_none()) + // TODO index out of bounds? { if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), *origin) { *self = CustomerState::Exiting { path }; @@ -390,12 +391,12 @@ impl CustomerState { PacketS::Interact { player: me, pos: Some(*table), - hand: Hand::Left, + hand: Hand(0), }, PacketS::Interact { player: me, pos: None, - hand: Hand::Left, + hand: Hand(0), }, ], direction, diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs index 5a7e61a0..452f59d3 100644 --- a/server/bot/src/algos/simple.rs +++ b/server/bot/src/algos/simple.rs @@ -21,7 +21,7 @@ use crate::{ }; use hurrycurry_client_lib::Game; use hurrycurry_protocol::{ - glam::IVec2, Hand, ItemIndex, Message, PlayerID, Recipe, RecipeIndex, TileIndex, + glam::IVec2, ItemIndex, Message, PlayerID, Recipe, RecipeIndex, TileIndex, }; use log::{debug, warn}; @@ -106,17 +106,16 @@ impl State for Simple { impl<S> Context<'_, S> { pub fn is_hand_item(&self, item: ItemIndex) -> bool { - self.game.players.get(&self.me).is_some_and(|p| { - p.items[Hand::Left.index()] - .as_ref() - .is_some_and(|i| i.kind == item) - }) + self.game + .players + .get(&self.me) + .is_some_and(|p| p.items[0].as_ref().is_some_and(|i| i.kind == item)) } pub fn is_hand_occupied(&self) -> bool { self.game .players .get(&self.me) - .map(|p| p.items[Hand::Left.index()].is_some()) + .map(|p| p.items[0].is_some()) .unwrap_or(false) } pub fn find_demand(&self) -> Option<(ItemIndex, IVec2)> { diff --git a/server/bot/src/main.rs b/server/bot/src/main.rs index 0ffbf4b6..918be7e1 100644 --- a/server/bot/src/main.rs +++ b/server/bot/src/main.rs @@ -109,7 +109,7 @@ fn main() -> Result<()> { network.queue_out.push_back(PacketS::Interact { player: b.id, pos: interact, - hand: Hand::Left, + hand: Hand(0), }) } network.queue_out.push_back(PacketS::Movement { |