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

@@ -57,18 +57,6 @@ internal class Grid
}
}
public float this[Position position]
{
get => _shots.TryGetValue(position, out var value)
? value + 10
: _ships.FirstOrDefault(s => s.Positions.Contains(position))?.Value ?? 0;
set
{
_ = _ships.FirstOrDefault(s => s.IsHit(position));
_shots[position] = (int)value - 10;
}
}
internal int UntriedSquareCount => 100 - _shots.Count;
internal IEnumerable<Ship> Ships => _ships.AsEnumerable();