예제 #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;
        }
예제 #2
0
        public PlayerSymbol? GetPlayerSymbol(Position position)
        {
            EnsurePositionIsCorrect(position);

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

            return null;
        }
예제 #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);
 }