diff options
Diffstat (limited to 'server')
| -rw-r--r-- | server/src/data.rs | 4 | ||||
| -rw-r--r-- | server/src/game.rs | 8 | 
2 files changed, 12 insertions, 0 deletions
| diff --git a/server/src/data.rs b/server/src/data.rs index 7f5ed9a6..408ea736 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -80,6 +80,8 @@ pub struct InitialMap {      entities: Vec<EntityDecl>,      #[serde(default)]      tile_entities: HashMap<char, EntityDecl>, +    #[serde(default)] +    score_baseline: i64,  }  #[derive(Debug, Clone, Serialize, Deserialize)] @@ -112,6 +114,7 @@ pub struct Gamedata {      pub initial_map: HashMap<IVec2, (TileIndex, Option<ItemIndex>)>,      pub chef_spawn: Vec2,      pub customer_spawn: Vec2, +    pub score_baseline: i64,      pub entities: Vec<Entity>,  } @@ -322,6 +325,7 @@ impl Gamedata {              map_name,              tile_interact,              recipes, +            score_baseline: map_in.score_baseline,              map: HashMap::new(),              initial_map,              item_names, diff --git a/server/src/game.rs b/server/src/game.rs index 21bb5f33..89ea7dfc 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -301,6 +301,7 @@ impl Game {                          name: name.clone(),                      },                  ); +                self.score.players = self.score.players.max(self.players.len());                  packet_out.push_back(PacketC::AddPlayer {                      id: player,                      name, @@ -586,6 +587,13 @@ impl Game {          if let Some(end) = self.end {              self.score.time_remaining = (end - Instant::now()).as_secs_f64();              if end < Instant::now() { +                let relative_score = (self.score.points * 100) / self.data.score_baseline.max(1); +                self.score.stars = match relative_score { +                    100.. => 3, +                    70.. => 2, +                    40.. => 1, +                    _ => 0, +                };                  packet_out.push_back(PacketC::Menu(Menu::Score(self.score.clone())));                  true              } else { | 
