aboutsummaryrefslogtreecommitdiff
path: root/server/bot/src/algos
diff options
context:
space:
mode:
authormetamuffin <metamuffin@noreply.codeberg.org>2024-12-25 19:05:05 +0000
committermetamuffin <metamuffin@noreply.codeberg.org>2024-12-25 19:05:05 +0000
commitcc6b50debb9d5b740adbe6f803755413c972659a (patch)
treeb34a0a5669707992f1334f88a1959d5b1e120415 /server/bot/src/algos
parent2ceeea0e5fc245602618ec47f6ff1f91a094e130 (diff)
parent53cf167c08986caf346957d1f357cefaee1bd6b5 (diff)
downloadhurrycurry-cc6b50debb9d5b740adbe6f803755413c972659a.tar
hurrycurry-cc6b50debb9d5b740adbe6f803755413c972659a.tar.bz2
hurrycurry-cc6b50debb9d5b740adbe6f803755413c972659a.tar.zst
Merge pull request 'Two-handed players' (#236) from two-handed into master
Reviewed-on: https://codeberg.org/hurrycurry/hurrycurry/pulls/236
Diffstat (limited to 'server/bot/src/algos')
-rw-r--r--server/bot/src/algos/customer.rs14
-rw-r--r--server/bot/src/algos/simple.rs4
2 files changed, 14 insertions, 4 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index b243bd55..b0ece9dd 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -22,7 +22,7 @@ use crate::{
use hurrycurry_client_lib::Game;
use hurrycurry_protocol::{
glam::{IVec2, Vec2},
- DemandIndex, Message, PacketS, PlayerClass, PlayerID, Score,
+ DemandIndex, Hand, Message, PacketS, PlayerClass, PlayerID, Score,
};
use log::info;
use rand::{random, seq::IndexedRandom, thread_rng};
@@ -313,6 +313,7 @@ impl CustomerState {
PacketS::Interact {
pos: Some(pos),
player: me,
+ hand: Hand(0),
},
PacketS::ApplyScore(Score {
demands_completed: 1,
@@ -322,6 +323,7 @@ impl CustomerState {
PacketS::Interact {
pos: None,
player: me,
+ hand: Hand(0),
},
],
..Default::default()
@@ -354,6 +356,7 @@ impl CustomerState {
extra: vec![PacketS::ReplaceHand {
player: me,
item: demand.output,
+ hand: Hand(0),
}],
..Default::default()
};
@@ -369,7 +372,12 @@ impl CustomerState {
cooldown,
} => {
*cooldown -= dt;
- if game.players.get(&me).is_some_and(|pl| pl.item.is_none()) {
+ if game
+ .players
+ .get(&me)
+ .is_some_and(|pl| pl.items[0].is_none())
+ // TODO index out of bounds?
+ {
if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), *origin) {
*self = CustomerState::Exiting { path };
}
@@ -383,10 +391,12 @@ impl CustomerState {
PacketS::Interact {
player: me,
pos: Some(*table),
+ hand: Hand(0),
},
PacketS::Interact {
player: me,
pos: None,
+ hand: Hand(0),
},
],
direction,
diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs
index 14eb38c4..452f59d3 100644
--- a/server/bot/src/algos/simple.rs
+++ b/server/bot/src/algos/simple.rs
@@ -109,13 +109,13 @@ impl<S> Context<'_, S> {
self.game
.players
.get(&self.me)
- .is_some_and(|p| p.item.as_ref().is_some_and(|i| i.kind == item))
+ .is_some_and(|p| p.items[0].as_ref().is_some_and(|i| i.kind == item))
}
pub fn is_hand_occupied(&self) -> bool {
self.game
.players
.get(&self.me)
- .map(|p| p.item.is_some())
+ .map(|p| p.items[0].is_some())
.unwrap_or(false)
}
pub fn find_demand(&self) -> Option<(ItemIndex, IVec2)> {