Improve computer shot tracking/selection

This commit is contained in:
drewjcooper
2023-05-16 17:45:48 +10:00
parent 6e01ee5b6a
commit 30360f2784
6 changed files with 11 additions and 50 deletions

View File

@@ -14,5 +14,4 @@ internal sealed class Battleship : Ship
internal override int Shots => 3;
internal override int Size => 5;
internal override float Value => 3;
}

View File

@@ -14,5 +14,4 @@ internal sealed class Cruiser : Ship
internal override int Shots => 2;
internal override int Size => 3;
internal override float Value => 2;
}

View File

@@ -14,5 +14,4 @@ internal sealed class Destroyer : Ship
internal override int Shots => 1;
internal override int Size => 2;
internal override float Value => Name.EndsWith("<A>") ? 1 : 0.5F;
}

View File

@@ -24,8 +24,7 @@ internal abstract class Ship
internal string Name { get; }
internal abstract int Shots { get; }
internal abstract int Size { get; }
internal abstract float Value { get; }
internal IEnumerable<Position> Positions => _positions;
internal bool IsDamaged => _positions.Count > 0 && _positions.Count < Size;
internal bool IsDestroyed => _positions.Count == 0;
internal bool IsHit(Position position) => _positions.Remove(position);