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); }
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(); } }
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); }
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))); }
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); } }
public bool IsLegalSourceCell(Board.Cell i_SourceCell) { Coin coinSource = r_Board.GetCoin(i_SourceCell); return(coinSource != null && coinSource.Owner.Equals(m_CurrentTurn)); }
public bool IsLegalOption(Board.Cell i_SourceCell, Board.Cell i_TargetCell) { return(m_HasSwitchedTurn ? isLegalMove(i_SourceCell, i_TargetCell) : isLegalContinuousMove(i_SourceCell, i_TargetCell)); }
private bool isRelevantCell(Board.Cell i_PotentialCell, Board.Cell i_CompareToCell) { return(!i_PotentialCell.Equals(i_CompareToCell)); }