From 9cf43048452513e07799344b43a811a9ba8e4ae3 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 19 Apr 2024 13:34:56 +0200 Subject: [PATCH] add walls destroyed stat --- TanksServer/GameLogic/CollideBullets.cs | 4 ++++ TanksServer/Models/Scores.cs | 2 ++ tank-frontend/src/Scoreboard.tsx | 5 +++++ tank-frontend/src/serverCalls.tsx | 1 + 4 files changed, 12 insertions(+) diff --git a/TanksServer/GameLogic/CollideBullets.cs b/TanksServer/GameLogic/CollideBullets.cs index 1504506..b045bb6 100644 --- a/TanksServer/GameLogic/CollideBullets.cs +++ b/TanksServer/GameLogic/CollideBullets.cs @@ -77,7 +77,11 @@ internal sealed class CollideBullets( { var offsetPixel = new PixelPosition(x, y); if (options.Value.DestructibleWalls) + { map.Current.DestroyWallAt(offsetPixel); + owner.Scores.WallsDestroyed++; + } + TryHitTankAt(offsetPixel.ToFloatPosition(), owner); } } diff --git a/TanksServer/Models/Scores.cs b/TanksServer/Models/Scores.cs index dc2c98c..9c651f3 100644 --- a/TanksServer/Models/Scores.cs +++ b/TanksServer/Models/Scores.cs @@ -17,4 +17,6 @@ internal sealed record class Scores(int Kills = 0, int Deaths = 0) return Kills / (double)Deaths; } } + + public int WallsDestroyed { get; set; } } diff --git a/tank-frontend/src/Scoreboard.tsx b/tank-frontend/src/Scoreboard.tsx index f9cb4aa..2b0cc29 100644 --- a/tank-frontend/src/Scoreboard.tsx +++ b/tank-frontend/src/Scoreboard.tsx @@ -42,6 +42,11 @@ export default function Scoreboard({}: {}) { field: 'ratio', visualize: p => p.scores.ratio.toString(), sorter: (a, b) => numberSorter(a.scores.ratio, b.scores.ratio) + }, + { + field: 'walls', + visualize: p => p.scores.wallsDestroyed.toString(), + sorter: (a, b) => numberSorter(a.scores.wallsDestroyed, b.scores.wallsDestroyed) } ]}/> } diff --git a/tank-frontend/src/serverCalls.tsx b/tank-frontend/src/serverCalls.tsx index 15832c4..8a0dd16 100644 --- a/tank-frontend/src/serverCalls.tsx +++ b/tank-frontend/src/serverCalls.tsx @@ -14,6 +14,7 @@ export type Player = { readonly scores: { readonly kills: number; readonly deaths: number; + readonly wallsDestroyed: number; }; };