// this will check to see if both players have played and give the // results of the game. private void CheckWinner() { // if both player 1 and player 2 have played if (player1.Played && player2.Played) { // if player1's handrank is higher than player2's // to understand the handranks and mod1/mod2/mod3 see the player.cs file comments if (player1.HandRank > player2.HandRank) { lbl_winnerResult.Text = player1.Name + " Wins!"; // set the winnerResult label to show that player1 wins } else if (player2.HandRank > player1.HandRank) // else if player2's handrank is greater than player one's { lbl_winnerResult.Text = player2.Name + " Wins!"; // set the winnerResult label to show that player2 wins } else if (player1.HandRank == 8 && player2.HandRank == 8) // else if both handranks equal 8 { // if player1 mod1 is greater than player2's mod1 and 2 if (player1.Mod1 > player2.Mod1 && player1.Mod1 > player2.Mod2) { lbl_winnerResult.Text = player1.Name + " Wins!"; // set the winnerResult label to show that player1 wins } // else if player1's mod2 is greater than player2's mod1 and mod2 else if (player1.Mod2 > player2.Mod1 && player1.Mod2 > player2.Mod2) { lbl_winnerResult.Text = player1.Name + " Wins!"; // set the winnerResult label to show that player1 wins } // else if player1's mod1 and mod2 are equal to player2's mod1 and mod2 // or player1's mod2 is equal to player2's mod1 and player1's mod1 is equal to player2's mod2 else if (player1.Mod1 == player2.Mod1 && player1.Mod2 == player2.Mod2 || player1.Mod2 == player2.Mod1 && player1.Mod1 == player2.Mod2) { // if player1's mod3 is greater than player2's mod3 if (player1.Mod3 > player2.Mod3) { lbl_winnerResult.Text = player1.Name + " Wins!"; // set the winnerResult label to show that player1 wins } // else if player2's mod3 is greater than player1's mod3 else if (player2.Mod3 > player1.Mod3) { lbl_winnerResult.Text = player2.Name + " Wins!"; // set the winnerResult label to show that player2 wins } // else the mod3's for both will be the same so its a tie else { lbl_winnerResult.Text = player1.Name + " Ties " + player2.Name; // set the winnerResult label to show that it is a tie } } } // else if the handranks are the same else if (player1.HandRank == player2.HandRank) { // if player1's mod1 is greater than player2's mod1 if (player1.Mod1 > player2.Mod1) { lbl_winnerResult.Text = player1.Name + " Wins!"; // set the winnerResult label to show that player1 wins } else if (player2.Mod1 > player1.Mod1) // else if player2's mod1 is greater than player1's mod1 { lbl_winnerResult.Text = player2.Name + " Wins!"; // set the winnerResult label to show that player2 wins } else if (player1.Mod1 == player2.Mod1) // else if both player1 and player2 have an equal mod1 { if (player1.Mod2 > player2.Mod2) // if player1's mod2 is greater than player2's mod2 { lbl_winnerResult.Text = player1.Name + " Wins!"; // set the winnerResult label to show that player1 wins } else if (player2.Mod2 > player1.Mod2) // if player2's mod2 is greater than player1's mod2 { lbl_winnerResult.Text = player2.Name + " Wins!"; // set the winnerResult label to show that player2 wins } else if (player1.Mod2 == player2.Mod2) // else if both players have the same mod2 { if (player1.Mod3 > player2.Mod3) // if player1 has a greater mod3 { lbl_winnerResult.Text = player1.Name + " Wins!"; // set the winnerResult label to show that player1 wins } else if (player2.Mod3 > player1.Mod3) // else if player2 has a greater mod3 { lbl_winnerResult.Text = player2.Name + " Wins!"; // set the winnerResult label to show that player2 wins } else if (player1.Mod3 == player2.Mod3) // else if both players have an equal mod3 { lbl_winnerResult.Text = player1.Name + " Ties " + player2.Name; // set the winnerResult label to show that it is a tie } } } } // reset the players so that they can play again player1.ResetPlayer(); player2.ResetPlayer(); } else if (player1.Played && !player2.Played) // else if only player 1 has played { lbl_winnerResult.Text = "Waiting for " + player2.Name + " to roll!"; // set winnerResult label to show that we are waiting on playe2 to roll } else if (player2.Played && !player1.Played) // else if player 2 has played and player 1 has not played { lbl_winnerResult.Text = "Waiting for " + player1.Name + " to roll!"; // set the winnerResult label to show that we are waiting on player1 to roll } }