aboutsummaryrefslogtreecommitdiff
path: root/server/bot/src/algos/customer.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/customer.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/customer.rs')
-rw-r--r--server/bot/src/algos/customer.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index ebc6e64a..0ed1ba9a 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -22,7 +22,7 @@ use crate::{
};
use hurrycurry_game_core::Game;
use hurrycurry_protocol::{
- DemandIndex, Hand, ItemLocation, Message, PacketS, PlayerClass, PlayerID, Score,
+ DemandIndex, Hand, ItemLocation, Message, PacketS, PlayerClass, PlayerID, Score, TileIndex,
glam::{IVec2, Vec2},
};
use log::debug;
@@ -101,12 +101,14 @@ impl CustomerState {
match self {
CustomerState::New => {
if !game.data.demands.is_empty() {
+ let chair_ti = game.data.get_tile_by_name("chair").unwrap_or(TileIndex(0)); // TODO
let chairs = game
- .tiles
- .iter()
- .filter(|(_, t)| game.data.tile_name(t.kind) == "chair")
- .map(|(p, _)| *p)
- .collect::<Vec<_>>();
+ .tile_index
+ .get(&chair_ti)
+ .into_iter()
+ .flatten()
+ .copied()
+ .collect::<Vec<_>>(); //? maybe opt alloc
if let Some(&chair) = chairs.get(random::<usize>(..) % chairs.len().max(1))
&& let Some(path) = find_path(game, pos.as_ivec2(), chair)
{
@@ -135,12 +137,11 @@ impl CustomerState {
let timeout = 90. + random_float() * 60.;
let mut facing = Vec2::ZERO;
for off in [IVec2::NEG_X, IVec2::NEG_Y, IVec2::X, IVec2::Y] {
- if game.tiles.get(&(off + *chair)).is_some_and(|t| {
- game.data
- .tile_placeable_items
- .get(&t.kind)
- .is_none_or(|p| p.contains(&requested_item))
- }) {
+ if game
+ .tiles
+ .get(&(off + *chair))
+ .is_some_and(|t| game.data.can_place_item(&t.parts, requested_item))
+ {
facing = off.as_vec2();
}
}