private void StartGameButton_Click(object sender, RoutedEventArgs e) { setScreen(GameScreens.ScreenPlayGame); playerNames.Clear(); for (int i = 0; i < numPlayers; i++) { playerNames.Add(PlayerNameFields[i].Text); } currentPlayer = 0; WoodsyGame = new WoodsyGameData(playerNames); WoodsyGame.beginTurn(playerNames[currentPlayer]); displayGameBoard(WoodsyGame, playerNames[currentPlayer]); Toast("Click on the board where you want your piece to go."); }
public void displayGameBoard(WoodsyGameData W, String currentParticipantId) { //-- Get the player information and find our player. //-- Make a player pointer array to point to the game version's index for the actual order of players, //-- since in the display the active player is always on top. int wNumPlayers = W.getNumberOfParticipants(); List <String> playerIds = W.getParticipantIds(); int currentPlayerIndex = -1; for (int i = 0; i < wNumPlayers; i++) { if (playerIds[i].Equals(currentParticipantId)) { currentPlayerIndex = i; } } int[] playPointer = new int[wNumPlayers]; playPointer[0] = currentPlayerIndex; int j = 1; for (int i = 0; i < wNumPlayers; i++) { if (i == currentPlayerIndex) { continue; } playPointer[j] = i; j++; } if (currentPlayerIndex == -1) { Toast("Unexpected problem locating player"); currentPlayerIndex = 0; currentParticipantId = playerIds[0]; } //-- Set the captions. Set whether the board is read-only or not. for (int i = 0; i < 4; i++) { if (i < wNumPlayers) { BoardCaptions[i].Text = playerIds[playPointer[i]] + "'s Board (Coins: " + W.getScore(playerIds[playPointer[i]]) + ")"; if (i == 0) { // active player BoardViews[i].setReadOnlyMode(false); } else { BoardViews[i].setReadOnlyMode(true); } } } //-- Now set the next piece. NextPiece.setPiece(W.getNextPiece()); int nleft = WoodsyGame.piecesLeftInBag(); PiecesLeftText.Text = ("(Pieces Left: " + nleft + ")"); //-- Next, draw the game boards. for (int i = 0; i < wNumPlayers; i++) { if (i == 0) { BoardViews[i].setBoard(W.getCurrentBoard()); } else { BoardViews[i].setBoard(W.getBoard(playerIds[playPointer[i]])); } } }