diff options
Diffstat (limited to 'server/bot/src/algos/simple.rs')
| -rw-r--r-- | server/bot/src/algos/simple.rs | 33 |
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}"); |