diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-06-29 16:10:07 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-29 16:10:07 +0200 | 
| commit | 58f4ab0b26948bec13ba853c90298271e472169f (patch) | |
| tree | 9fa6e4443addf067310ff9ba868ec72b9e237637 /server/src/customer | |
| parent | b0042dce860406431f2e486112b14987c665f6a8 (diff) | |
| download | hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar.bz2 hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar.zst | |
implement points
Diffstat (limited to 'server/src/customer')
| -rw-r--r-- | server/src/customer/mod.rs | 16 | 
1 files changed, 8 insertions, 8 deletions
| diff --git a/server/src/customer/mod.rs b/server/src/customer/mod.rs index 9e474b8f..d1f49655 100644 --- a/server/src/customer/mod.rs +++ b/server/src/customer/mod.rs @@ -104,6 +104,7 @@ impl DemandState {          tiles: &mut HashMap<IVec2, Tile>,          data: &Gamedata,          dt: f32, +        points: &mut i64,      ) -> Result<()> {          if self.customers.len() < 5 {              self.customer_id_counter.0 -= 1; @@ -165,6 +166,7 @@ impl DemandState {                          .expect("no path to exit");                          *self.chairs.get_mut(&chair).unwrap() = true;                          self.failed += 1; +                        *points -= 1;                          self.score_changed = true;                          p.state = CustomerState::Exiting { path }                      } else { @@ -212,14 +214,11 @@ impl DemandState {                      let demand = data.demand(*demand);                      *progress += dt / demand.duration;                      if *progress >= 1. { -                        packets_out.push(( -                            id, -                            PacketS::ReplaceHand { -                                item: Some(demand.to), -                            }, -                        )); -                        for edge in [true, false] { -                            packets_out.push((id, PacketS::Interact { pos: *target, edge })) +                        packets_out.push((id, PacketS::ReplaceHand { item: demand.to })); +                        if demand.to.is_some() { +                            for edge in [true, false] { +                                packets_out.push((id, PacketS::Interact { pos: *target, edge })) +                            }                          }                          let path = find_path(                              &self.walkable, @@ -229,6 +228,7 @@ impl DemandState {                          .ok_or(anyhow!("no path to exit"))?;                          *self.chairs.get_mut(&chair).unwrap() = true;                          self.completed += 1; +                        *points += demand.points;                          self.score_changed = true;                          p.state = CustomerState::Exiting { path }                      } | 
