diff options
author | metamuffin <metamuffin@disroot.org> | 2024-08-13 17:07:53 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-08-13 17:07:53 +0200 |
commit | 3de710172b186fc4139f70c1756ae6fe9972e7f1 (patch) | |
tree | bb32dc1813a97823d6bcd0844679f028b056784c /server/bot/src/algos | |
parent | 8d4b9b1dd7816de0d75abb4fe52985611a6f6a50 (diff) | |
download | hurrycurry-3de710172b186fc4139f70c1756ae6fe9972e7f1.tar hurrycurry-3de710172b186fc4139f70c1756ae6fe9972e7f1.tar.bz2 hurrycurry-3de710172b186fc4139f70c1756ae6fe9972e7f1.tar.zst |
apply customer points
Diffstat (limited to 'server/bot/src/algos')
-rw-r--r-- | server/bot/src/algos/customer.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index a147db05..0fc7a42b 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -20,7 +20,7 @@ use crate::{ BotAlgo, BotInput, }; use hurrycurry_client_lib::Game; -use hurrycurry_protocol::{glam::IVec2, DemandIndex, Message, PacketS, PlayerID}; +use hurrycurry_protocol::{glam::IVec2, DemandIndex, Message, PacketS, PlayerID, Score}; use log::info; use rand::{random, seq::IndexedRandom, thread_rng}; @@ -123,14 +123,15 @@ impl BotAlgo for Customer { if *timeout <= 0. { let path = find_path(&game.walkable, pos.as_ivec2(), *origin) .expect("no path to exit"); - // *self.chairs.get_mut(chair).unwrap() = true; - // game.score.demands_failed += 1; - // game.score.points -= 1; - // game.score_changed = true; info!("{me:?} -> exiting"); *self = Customer::Exiting { path }; BotInput { extra: vec![ + PacketS::ApplyScore(Score { + points: -1, + demands_failed: 1, + ..Default::default() + }), PacketS::Communicate { message: None, persist: true, @@ -216,11 +217,7 @@ impl BotAlgo for Customer { let demand = &game.data.demands[demand.0]; *progress += dt / demand.duration; if *progress >= 1. { - if let Some(path) = find_path( - &game.walkable, - pos.as_ivec2(), - *origin, - ) { + if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), *origin) { let mut packets = Vec::new(); packets.push(PacketS::ReplaceHand { player: me, @@ -235,10 +232,11 @@ impl BotAlgo for Customer { player: me, pos: None, }); - // *self.chairs.get_mut(chair).unwrap() = true; - // game.score.demands_completed += 1; - // game.score.points += demand.points; - // game.score_changed = true; + packets.push(PacketS::ApplyScore(Score { + demands_completed: 1, + points: demand.points, + ..Default::default() + })); info!("{me:?} -> exiting"); *self = Customer::Exiting { path }; return BotInput { |