From 3777f835c145c135eba607b665ee6487300880e6 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Sun, 21 Mar 2021 12:46:32 +1100 Subject: [PATCH] Fix phaser energy use --- 84 Super Star Trek/csharp/Objects/Enterprise.cs | 5 +++++ 84 Super Star Trek/csharp/Systems/PhaserControl.cs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/84 Super Star Trek/csharp/Objects/Enterprise.cs b/84 Super Star Trek/csharp/Objects/Enterprise.cs index 004ce893..bb177369 100644 --- a/84 Super Star Trek/csharp/Objects/Enterprise.cs +++ b/84 Super Star Trek/csharp/Objects/Enterprise.cs @@ -87,6 +87,11 @@ namespace SuperStarTrek.Objects public override string ToString() => "<*>"; + internal void UseEnergy(float amountUsed) + { + TotalEnergy -= amountUsed; + } + internal CommandResult TakeHit(Coordinates sector, int hitStrength) { _output.WriteLine($"{hitStrength} unit hit on Enterprise from sector {sector}"); diff --git a/84 Super Star Trek/csharp/Systems/PhaserControl.cs b/84 Super Star Trek/csharp/Systems/PhaserControl.cs index 5aa7cf8b..18566294 100644 --- a/84 Super Star Trek/csharp/Systems/PhaserControl.cs +++ b/84 Super Star Trek/csharp/Systems/PhaserControl.cs @@ -42,6 +42,8 @@ namespace SuperStarTrek.Systems var phaserStrength = GetPhaserStrength(); if (phaserStrength < 0) { return CommandResult.Ok; } + _enterprise.UseEnergy(phaserStrength); + var perEnemyStrength = GetPerTargetPhaserStrength(phaserStrength, quadrant.KlingonCount); foreach (var klingon in quadrant.Klingons.ToList())