aboutsummaryrefslogtreecommitdiff
path: root/server/src/entity/customers
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/entity/customers')
-rw-r--r--server/src/entity/customers/demands.rs8
-rw-r--r--server/src/entity/customers/mod.rs4
-rw-r--r--server/src/entity/customers/pathfinding.rs6
3 files changed, 6 insertions, 12 deletions
diff --git a/server/src/entity/customers/demands.rs b/server/src/entity/customers/demands.rs
index fa7e0dbf..4f15f86f 100644
--- a/server/src/entity/customers/demands.rs
+++ b/server/src/entity/customers/demands.rs
@@ -41,7 +41,7 @@ pub fn generate_demands(
let prod_count = producable.len();
for r in &recipes {
- let output_count = r.outputs().iter().filter(|o| !items.contains(&o)).count();
+ let output_count = r.outputs().iter().filter(|o| !items.contains(o)).count();
let Some(ingred_cost) = r
.inputs()
.iter()
@@ -79,16 +79,12 @@ pub fn generate_demands(
raw_demands
.iter()
.filter_map(|(i, o, d)| {
- if let Some(cost) = producable.get(i) {
- Some(Demand {
+ producable.get(i).map(|cost| Demand {
from: *i,
to: *o,
duration: *d,
points: *cost as i64,
})
- } else {
- None
- }
})
.collect()
}
diff --git a/server/src/entity/customers/mod.rs b/server/src/entity/customers/mod.rs
index 7f0b0c22..806a25f9 100644
--- a/server/src/entity/customers/mod.rs
+++ b/server/src/entity/customers/mod.rs
@@ -150,7 +150,7 @@ impl EntityT for Customers {
game.data.customer_spawn.as_ivec2(),
)
.expect("no path to exit");
- *self.chairs.get_mut(&chair).unwrap() = true;
+ *self.chairs.get_mut(chair).unwrap() = true;
game.demands_failed += 1;
game.points -= 1;
game.score_changed = true;
@@ -231,7 +231,7 @@ impl EntityT for Customers {
game.data.customer_spawn.as_ivec2(),
)
.ok_or(anyhow!("no path to exit"))?;
- *self.chairs.get_mut(&chair).unwrap() = true;
+ *self.chairs.get_mut(chair).unwrap() = true;
game.demands_completed += 1;
game.points += demand.points;
game.score_changed = true;
diff --git a/server/src/entity/customers/pathfinding.rs b/server/src/entity/customers/pathfinding.rs
index 97bd8328..87ccf391 100644
--- a/server/src/entity/customers/pathfinding.rs
+++ b/server/src/entity/customers/pathfinding.rs
@@ -47,7 +47,7 @@ pub fn find_path(walkable: &HashSet<IVec2>, from: IVec2, to: IVec2) -> Option<Pa
struct Open(i32, IVec2, IVec2, i32);
impl PartialOrd for Open {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
- self.0.partial_cmp(&other.0)
+ Some(self.0.cmp(&other.0))
}
}
impl Ord for Open {
@@ -61,9 +61,7 @@ pub fn find_path(walkable: &HashSet<IVec2>, from: IVec2, to: IVec2) -> Option<Pa
open.push(Open(1, from, from, 0));
loop {
- let Some(Open(_, pos, f, distance)) = open.pop() else {
- return None;
- };
+ let Open(_, pos, f, distance) = open.pop()?;
if visited.contains_key(&pos) {
continue;
}