diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-27 00:13:19 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-27 00:13:23 +0200 |
commit | 6d8369a49d098a17e76ba7e855dd99aa5e19cf8a (patch) | |
tree | a1b43b09dd219bfc5fb1e622662c60b8dbe6f0d8 /server/bot/src/algos/simple.rs | |
parent | 1634c6d1d4acf07176f7fdd931a7834634ba2751 (diff) | |
download | hurrycurry-6d8369a49d098a17e76ba7e855dd99aa5e19cf8a.tar hurrycurry-6d8369a49d098a17e76ba7e855dd99aa5e19cf8a.tar.bz2 hurrycurry-6d8369a49d098a17e76ba7e855dd99aa5e19cf8a.tar.zst |
update waiter bot for unknown orders
Diffstat (limited to 'server/bot/src/algos/simple.rs')
-rw-r--r-- | server/bot/src/algos/simple.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs index 73099830..dbe8bbfe 100644 --- a/server/bot/src/algos/simple.rs +++ b/server/bot/src/algos/simple.rs @@ -139,6 +139,28 @@ impl<S> Context<'_, S> { _ => None, }) } + pub fn find_demands(&self) -> Vec<(ItemIndex, IVec2)> { + self.game + .players + .iter() + .filter_map(|(_, pl)| match &pl.communicate_persist { + Some((Message::Item(item), _)) => { + let pos = pl.movement.position.as_ivec2(); + [IVec2::X, IVec2::Y, -IVec2::X, -IVec2::Y] + .into_iter() + .find(|off| { + self.game + .tiles + .get(&(pos + *off)) + .map_or(false, |t| self.game.data.tile_interact[t.kind.0]) + }) + .map(|off| pos + off) + .map(|pos| (*item, pos)) + } + _ => None, + }) + .collect() + } pub fn find_recipe_with_output(&self, item: ItemIndex) -> Option<RecipeIndex> { self.game .data |