Exemplo n.º 1
0
        public override bool Equals(object other)
        {
            CellCoordinates otherCell = other as CellCoordinates;

            if (null == otherCell)
            {
                return(false);
            }

            bool rowEqual = (this.Row == otherCell.Row);
            bool colEqual = (this.Column == otherCell.Column);

            return(rowEqual && colEqual);
        }
        private IEnumerable <ICellCoordinates> FlippedCellsForDirectionOfTurnOnBoard(
            ICellCoordinates direction,
            ICellCoordinates turnCandidate,
            IBoardState board)
        {
            var result = new List <ICellCoordinates>();

            int rowIncrement    = direction.Row - turnCandidate.Row;
            int columnIncrement = direction.Column - turnCandidate.Column;

            #if NO_UNITY
            Check.If(Math.Abs(rowIncrement)).IsBetween(0, 1);
            Check.If(Math.Abs(columnIncrement)).IsBetween(0, 1);
            #endif


            CellCoordinates current         = new CellCoordinates(direction.Row, direction.Column);
            bool            isMyColourFound = false;
            while (current.Row >= 0 && current.Row < MatrixBoard.BOARD_SIZE &&
                   current.Column >= 0 && current.Column < MatrixBoard.BOARD_SIZE)
            {
                if (board.IsCellTakenByInactivePlayer(current))
                {
                    var currentClone = current.Clone() as CellCoordinates;
                    result.Add(currentClone);
                }
                else if (board.IsCellTakenByCurrentPlayer(current))
                {
                    isMyColourFound = true;
                    break;
                }
                else // empty cell
                {
                    break;
                }

                current.Row    += rowIncrement;
                current.Column += columnIncrement;
            }

            if (!isMyColourFound)
            {
                return(null);
            }

            return(result);
        }
Exemplo n.º 3
0
        public object Clone()
        {
            CellCoordinates result = new CellCoordinates(this.Row, this.Column);

            return(result);
        }