summaryrefslogtreecommitdiff
path: root/server/bot/src/algos/simple.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-12-23 15:37:11 +0100
committermetamuffin <metamuffin@disroot.org>2024-12-23 15:37:11 +0100
commit1a9f7e9a20bff0fbc854454f131d4bc546e73e72 (patch)
tree7be16db47cd819177ae73d42af7b59c37593060a /server/bot/src/algos/simple.rs
parentbd71cd120fa4d8caf4987fd9c76838ccbeec19f7 (diff)
downloadhurrycurry-1a9f7e9a20bff0fbc854454f131d4bc546e73e72.tar
hurrycurry-1a9f7e9a20bff0fbc854454f131d4bc546e73e72.tar.bz2
hurrycurry-1a9f7e9a20bff0fbc854454f131d4bc546e73e72.tar.zst
two-handed server
Diffstat (limited to 'server/bot/src/algos/simple.rs')
-rw-r--r--server/bot/src/algos/simple.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs
index 14eb38c4..5a7e61a0 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, ItemIndex, Message, PlayerID, Recipe, RecipeIndex, TileIndex,
+ glam::IVec2, Hand, ItemIndex, Message, PlayerID, Recipe, RecipeIndex, TileIndex,
};
use log::{debug, warn};
@@ -106,16 +106,17 @@ 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.item.as_ref().is_some_and(|i| i.kind == item))
+ self.game.players.get(&self.me).is_some_and(|p| {
+ p.items[Hand::Left.index()]
+ .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.item.is_some())
+ .map(|p| p.items[Hand::Left.index()].is_some())
.unwrap_or(false)
}
pub fn find_demand(&self) -> Option<(ItemIndex, IVec2)> {