aboutsummaryrefslogtreecommitdiff
path: root/server/src/entity/customers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/entity/customers.rs')
-rw-r--r--server/src/entity/customers.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/server/src/entity/customers.rs b/server/src/entity/customers.rs
index c1bfb525..2e2f82af 100644
--- a/server/src/entity/customers.rs
+++ b/server/src/entity/customers.rs
@@ -20,7 +20,7 @@ use crate::random_float;
use anyhow::Result;
use hurrycurry_bot::algos::Customer;
use hurrycurry_locale::TrError;
-use hurrycurry_protocol::{Character, PlayerClass};
+use hurrycurry_protocol::{Character, PlayerClass, TileIndex};
use std::random::random;
pub struct Customers {
@@ -47,10 +47,14 @@ impl Entity for Customers {
fn tick(&mut self, mut c: EntityContext) -> Result<(), TrError> {
let chairs = *self.chair_count.get_or_insert_with(|| {
c.game
- .tiles
- .values()
- .filter(|t| c.game.data.tile_name(t.kind) == "chair")
- .count()
+ .tile_index
+ .get(
+ &c.game
+ .data
+ .get_tile_by_name("chair")
+ .unwrap_or(TileIndex(0)),
+ )
+ .map_or(0, |c| c.len())
});
let max_count = (self.scaling_factor * chairs as f32).max(1.) as usize;