add distance moved score

This commit is contained in:
Vinzenz Schroeter 2024-04-29 14:13:04 +02:00
parent 259d63d683
commit 4e605d556c
5 changed files with 15 additions and 0 deletions

View file

@ -54,6 +54,7 @@ internal sealed class MoveTanks(
if (HitsTank(tank, newPosition))
return false;
tank.Owner.Scores.DistanceMoved += newPosition.Distance(tank.Position);
tank.Position = newPosition;
return true;
}

View file

@ -1,3 +1,5 @@
using System.Text.Json.Serialization;
namespace TanksServer.Models;
internal sealed record class Scores
@ -24,10 +26,15 @@ internal sealed record class Scores
public int PowerUpsCollected { get; set; }
[JsonIgnore] public double DistanceMoved { get; set; }
public int PixelsMoved => (int)DistanceMoved;
public int OverallScore => Math.Max(0,
10000 * Kills
- 1000 * Deaths
+ 100 * PowerUpsCollected
+ 10 * (ShotsFired + WallsDestroyed)
+ PixelsMoved
);
}