diff options
-rw-r--r-- | data/maps/junior.yaml | 1 | ||||
-rw-r--r-- | server/src/data.rs | 4 | ||||
-rw-r--r-- | server/src/game.rs | 8 | ||||
-rw-r--r-- | test-client/protocol.ts | 1 |
4 files changed, 14 insertions, 0 deletions
diff --git a/data/maps/junior.yaml b/data/maps/junior.yaml index 5807eb70..9acd4dd1 100644 --- a/data/maps/junior.yaml +++ b/data/maps/junior.yaml @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # +score_baseline: 200 map: - "*''''*'''*'''''*''*'''*''" - "'''*''''*'*'**'''''**'''*" 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 { diff --git a/test-client/protocol.ts b/test-client/protocol.ts index 376ebd58..c63e820f 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -75,6 +75,7 @@ export interface Score { active_recipes: number, passive_recipes: number, instant_recipes: number, + stars: number, } export type Message = |