Example #1
0
        public void SetPlayerSymbol(Position position, PlayerSymbol value)
        {
            EnsurePositionIsCorrect(position);

            if (_busyCells.ContainsKey(position))
            {
                throw new InvalidOperationException($"Position {position} is already busy");
            }

            _busyCells[position] = value;
        }
Example #2
0
        public PlayerSymbol? GetPlayerSymbol(Position position)
        {
            EnsurePositionIsCorrect(position);

            PlayerSymbol result;
            if (_busyCells.TryGetValue(position, out result))
            {
                return result;
            }

            return null;
        }
Example #3
0
 private void EnsurePositionIsCorrect(Position position)
 {
     if (!Size.HasValue) return;
     Ensure.That(position.X, () => position.X).IsInRange(0, Size.Value.Width - 1);
     Ensure.That(position.Y, () => position.Y).IsInRange(0, Size.Value.Height - 1);
 }