diff --git a/tanks-backend/TanksServer/GameLogic/CollideBullets.cs b/tanks-backend/TanksServer/GameLogic/CollideBullets.cs index b045bb6..1ec17cf 100644 --- a/tanks-backend/TanksServer/GameLogic/CollideBullets.cs +++ b/tanks-backend/TanksServer/GameLogic/CollideBullets.cs @@ -76,11 +76,8 @@ internal sealed class CollideBullets( for (var y = pixel.Y - i; y <= pixel.Y + i; y++) { var offsetPixel = new PixelPosition(x, y); - if (options.Value.DestructibleWalls) - { - map.Current.DestroyWallAt(offsetPixel); + if (options.Value.DestructibleWalls && map.Current.TryDestroyWallAt(offsetPixel)) owner.Scores.WallsDestroyed++; - } TryHitTankAt(offsetPixel.ToFloatPosition(), owner); } diff --git a/tanks-backend/TanksServer/GameLogic/MapService.cs b/tanks-backend/TanksServer/GameLogic/MapService.cs index ecfb252..82b0344 100644 --- a/tanks-backend/TanksServer/GameLogic/MapService.cs +++ b/tanks-backend/TanksServer/GameLogic/MapService.cs @@ -104,5 +104,11 @@ internal sealed class Map(string name, bool[,] walls) return false; } - public void DestroyWallAt(PixelPosition pixel) => walls[pixel.X, pixel.Y] = false; + public bool TryDestroyWallAt(PixelPosition pixel) + { + var result = walls[pixel.X, pixel.Y]; + if (result) + walls[pixel.X, pixel.Y] = false; + return result; + } }