private void PossibleMoves(string playerColor, char[] playField) { // Check the possible moves of every piece on the board // If a piece is found with the same color as the specified color // check its possible moves char pieceOnLocation; for (int location = 1; location < 99; location++) { pieceOnLocation = playField[location]; if (playerColor == pieceOnLocation.ToString().ToLower()) { MoveData movesOfPiece = new MoveData(location, playField); //If the highestStrike at this location is the same add it to the list if (movesOfPiece.highestStrike == highestStrike) { moveList.AddRange(new List <List <int> >(movesOfPiece.moveList)); AppendEndPlayField(movesOfPiece.endPlayFieldsList); } //If the highestStrike at this location is higher, clear moveData and use moveList of Piece else if (movesOfPiece.highestStrike > highestStrike) { moveList.Clear(); endPlayFieldsList.Clear(); moveList.AddRange(new List <List <int> >(movesOfPiece.moveList)); AppendEndPlayField(movesOfPiece.endPlayFieldsList); highestStrike = movesOfPiece.highestStrike; } movesOfPiece.Clear(); //Else do nothing and continue the loop } } }
public void TrimMoveListToSelect(int selectedLocation) { currentValidMoves.Clear(); currentValidMoves = new MoveData(selectedLocation, playField); }