summaryrefslogtreecommitdiff
path: root/server/bot/src/algos/customer.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-25 15:30:09 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-25 15:55:00 +0200
commit9587d6b4d4389f6108e2be0ff5c0f4a495ff842d (patch)
tree3cc2ea9a93de6dd39acd5396fddfbadafef471cf /server/bot/src/algos/customer.rs
parent64564a25db65d7a578fee537a0cf91db1a7dbc60 (diff)
downloadhurrycurry-9587d6b4d4389f6108e2be0ff5c0f4a495ff842d.tar
hurrycurry-9587d6b4d4389f6108e2be0ff5c0f4a495ff842d.tar.bz2
hurrycurry-9587d6b4d4389f6108e2be0ff5c0f4a495ff842d.tar.zst
player class decoupled from character id
Diffstat (limited to 'server/bot/src/algos/customer.rs')
-rw-r--r--server/bot/src/algos/customer.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index e602addc..6a45e379 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -20,7 +20,9 @@ use crate::{
BotAlgo, BotInput,
};
use hurrycurry_client_lib::Game;
-use hurrycurry_protocol::{glam::IVec2, DemandIndex, Message, PacketS, PlayerID, Score};
+use hurrycurry_protocol::{
+ glam::IVec2, DemandIndex, Message, PacketS, PlayerClass, PlayerID, Score,
+};
use log::info;
use rand::{random, seq::IndexedRandom, thread_rng};
@@ -124,7 +126,7 @@ impl BotAlgo for Customer {
.players
.iter()
.find(|(id, p)| {
- p.character < 0
+ p.class == PlayerClass::Customer
&& **id != me
&& p.movement.position.distance(chair.as_vec2() + 0.5) < 1.
})
@@ -186,7 +188,11 @@ impl BotAlgo for Customer {
if !*pinned {
let mut pin = false;
game.players_spatial_index.query(pos, 3., |pid, _| {
- if game.players.get(&pid).map_or(false, |p| p.character >= 0) {
+ if game
+ .players
+ .get(&pid)
+ .map_or(false, |p| p.class.is_cheflike())
+ {
pin = true
}
});