aboutsummaryrefslogtreecommitdiff
path: root/server/bot/src/algos/simple.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-10 17:16:03 +0100
committertpart <tpart120@proton.me>2026-02-26 20:48:35 +0100
commitb634bad931f530ee0a207e1461ffc5e52ebb83e3 (patch)
tree90a45e8c67e6a7c66e49c7409f0c37881eade96e /server/bot/src/algos/simple.rs
parent0ed9e8387a66b3af78412feea62fdc8b9804f793 (diff)
downloadhurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar
hurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar.bz2
hurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar.zst
compiles with tile stacks
Diffstat (limited to 'server/bot/src/algos/simple.rs')
-rw-r--r--server/bot/src/algos/simple.rs33
1 files changed, 13 insertions, 20 deletions
diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs
index ba617707..5d19ed58 100644
--- a/server/bot/src/algos/simple.rs
+++ b/server/bot/src/algos/simple.rs
@@ -99,13 +99,10 @@ impl<S> Context<'_, S> {
[IVec2::X, IVec2::Y, -IVec2::X, -IVec2::Y]
.into_iter()
.find(|off| {
- self.game.tiles.get(&(pos + *off)).is_some_and(|t| {
- self.game
- .data
- .tile_placeable_items
- .get(&t.kind)
- .is_none_or(|placable| placable.contains(item))
- })
+ self.game
+ .tiles
+ .get(&(pos + *off))
+ .is_some_and(|t| self.game.data.can_place_item(&t.parts, *item))
})
.map(|off| pos + off)
.map(|pos| (*item, pos, timeout.remaining))
@@ -134,7 +131,7 @@ impl<S> Context<'_, S> {
self.game
.tiles
.iter()
- .find(|(_, t)| t.kind == tile)
+ .find(|(_, t)| t.parts.contains(&tile)) // TODO opt use tile index
.map(|(p, _)| *p)
}
pub fn find_occupied_table_or_floor(&self) -> Option<IVec2> {
@@ -143,10 +140,9 @@ impl<S> Context<'_, S> {
.iter()
.find(|(_, t)| {
t.item.is_some()
- && matches!(
- self.game.data.tile_names[t.kind.0].as_str(),
- "table" | "floor"
- )
+ && t.parts.iter().any(|p| {
+ matches!(self.game.data.tile_names[p.0].as_str(), "table" | "floor")
+ })
})
.map(|(p, _)| *p)
}
@@ -155,9 +151,10 @@ impl<S> Context<'_, S> {
.tiles
.iter()
.find(|(_, t)| {
- !self.game.data.tile_placeable_items.contains_key(&t.kind)
- && t.item.is_none()
- && self.game.data.tile_names[t.kind.0] == name
+ t.item.is_none()
+ && t.parts
+ .iter()
+ .any(|i| self.game.data.tile_names[i.0] == name) // TODO use index
})
.map(|(p, _)| *p)
}
@@ -178,11 +175,7 @@ impl<S: State> Context<'_, S> {
}
}
warn!("all counters filled up");
- self.game
- .tiles
- .iter()
- .find(|(_, t)| !self.game.data.tile_placeable_items.contains_key(&t.kind)) // TODO filter by placable item
- .map(|(p, _)| *p)
+ None
}
pub fn clear_tile(&mut self, pos: IVec2) -> LogicRes {
debug!("clear tile {pos}");