Exemple #1
0
        private bool isLegalContinuousMove(Board.Cell i_SourceCell, Board.Cell i_TargetCell)
        {
            bool isSourceCellLegal = i_SourceCell.Equals(m_TargetCell);
            bool isTargetCellLegal = (r_Board.GetCoin(i_TargetCell) == null) && r_Board.GetCoin(i_SourceCell).ObligatoryMoves.Contains(i_TargetCell);

            return(isSourceCellLegal && isTargetCellLegal);
        }
Exemple #2
0
        public void UpdateMove(Board.Cell i_SourceButtonCell, Board.Cell i_TargetButtonCell)
        {
            Coin coinToMove;
            bool hasBecomeKing;
            bool hasNoFollowingObligatoriesMoves;

            m_SourceCell   = i_SourceButtonCell;
            m_TargetCell   = i_TargetButtonCell;
            coinToMove     = r_Board.GetCoin(m_SourceCell);
            hasBecomeKing  = isSettingToKingNeeded(coinToMove);
            m_IsEatingMove = coinToMove.ObligatoryMoves.Contains(m_TargetCell);
            coinToMove.Owner.LegalMoves.Remove(m_SourceCell);
            coinToMove.Owner.ObligatoryMoves.Remove(m_SourceCell);
            r_Board.MoveCoin(m_SourceCell, m_TargetCell);
            if (hasBecomeKing)
            {
                coinToMove.SetToKing();
            }

            if (m_IsEatingMove)
            {
                handleEatingMove();
            }

            r_Board.UpdateCoinMovesList(m_TargetCell);
            r_Board.UpdatePreviousCellDiagonals(m_SourceCell, m_TargetCell);
            r_Board.UpdateNewCellDiagonals(m_SourceCell, m_TargetCell);
            hasNoFollowingObligatoriesMoves = coinToMove.ObligatoryMoves.Count == 0;
            m_HasSwitchedTurn = hasBecomeKing || !m_IsEatingMove || (m_IsEatingMove && hasNoFollowingObligatoriesMoves);
            if (m_HasSwitchedTurn)
            {
                updateGameStatus();
                m_CurrentTurn = getOpponent();
            }
        }
Exemple #3
0
        private void handleEatingMove()
        {
            Board.Cell eatenCell = GetEatenCell();
            Coin       eatenCoin = r_Board.GetCoin(eatenCell);

            r_Board.BoardMatrix[eatenCell.Row, eatenCell.Column] = null;
            eatenCoin.Owner.LegalMoves.Remove(eatenCell);
            eatenCoin.Owner.ObligatoryMoves.Remove(eatenCell);
            eatenCoin.IsInGame = false;
            r_Board.UpdatePreviousCellDiagonals(eatenCell, m_TargetCell);
        }
Exemple #4
0
        private bool isLegalMove(Board.Cell i_SourceCell, Board.Cell i_TargetCell)
        {
            bool isInObligatoryMoves;
            bool isInLegalMoves;
            bool playerHasObligatoryMoves = HasContinuousMoves();
            Coin coinSource = r_Board.GetCoin(i_SourceCell);
            Coin coinTarget = r_Board.GetCoin(i_TargetCell);

            isInObligatoryMoves = playerHasObligatoryMoves && coinSource.ObligatoryMoves.Contains(i_TargetCell);
            isInLegalMoves      = (coinSource.ObligatoryMoves.Count == 0) && coinSource.LegalMoves.Contains(i_TargetCell);

            return((coinTarget == null) && (isInObligatoryMoves || (!playerHasObligatoryMoves && isInLegalMoves)));
        }
Exemple #5
0
 public void SetComputerRandomMoveCells()
 {
     if (m_CurrentTurn.ObligatoryMoves.Count != 0)
     {
         m_SourceCell = getRandomCell(m_CurrentTurn.ObligatoryMoves);
         m_TargetCell = getRandomCell(r_Board.GetCoin(m_SourceCell).ObligatoryMoves);
     }
     else
     {
         m_SourceCell = getRandomCell(m_CurrentTurn.LegalMoves);
         m_TargetCell = getRandomCell(r_Board.GetCoin(m_SourceCell).LegalMoves);
     }
 }
Exemple #6
0
        public bool IsLegalSourceCell(Board.Cell i_SourceCell)
        {
            Coin coinSource = r_Board.GetCoin(i_SourceCell);

            return(coinSource != null && coinSource.Owner.Equals(m_CurrentTurn));
        }
Exemple #7
0
 public bool IsLegalOption(Board.Cell i_SourceCell, Board.Cell i_TargetCell)
 {
     return(m_HasSwitchedTurn ? isLegalMove(i_SourceCell, i_TargetCell) : isLegalContinuousMove(i_SourceCell, i_TargetCell));
 }
Exemple #8
0
 private bool isRelevantCell(Board.Cell i_PotentialCell, Board.Cell i_CompareToCell)
 {
     return(!i_PotentialCell.Equals(i_CompareToCell));
 }