public int OptionToMove(Coin i_OptionCoin, Player i_Player, BoardGame i_FullBoardGame) { int coinsToFlip = 0; int rowDirection; int columDirection; int distance; bool isEmpty = true; Coin tempCoin = new Coin(); if (!i_FullBoardGame.IsEmptySquare(i_OptionCoin)) { isEmpty = false; } for (rowDirection = -1; rowDirection <= 1 && isEmpty; rowDirection++) { for (columDirection = -1; columDirection <= 1; columDirection++) { if (!(rowDirection == 0 && columDirection == 0)) { distance = 1; tempCoin.Row = i_OptionCoin.Row + rowDirection; tempCoin.Colum = i_OptionCoin.Colum + columDirection; while (IsInBoard(tempCoin) && IsRival(tempCoin, i_Player.CoinType, i_FullBoardGame)) { distance++; tempCoin.Row += rowDirection; tempCoin.Colum += columDirection; } if (distance > 1 && IsInBoard(tempCoin) && !IsRival(tempCoin, i_Player.CoinType, i_FullBoardGame) && !IsEmptySquare(tempCoin)) { coinsToFlip += distance - 1; } } } } return(coinsToFlip); }
public bool IsRival(Coin i_Coin, char i_CurrentPlayer, BoardGame i_FullBoard) { return(i_FullBoard.m_BoardGame[i_Coin.Row, i_Coin.Colum] != i_CurrentPlayer && !i_FullBoard.IsEmptySquare(i_Coin)); }