/// <summary> /// A callback for a player action button click /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void ActionButtonClicked(object sender, RoutedEventArgs args) { // must have a valid player as the data context to handle the current action GuiMainPlayer thePlayer = DataContext as GuiMainPlayer; if (thePlayer == null) { return; } // the action is also the button tag Button clickedButton = (Button)sender; GuiActions action = (GuiActions)clickedButton.Tag; // send the player the action played thePlayer.HandleAction(action); }
/// <summary> /// Changes the <see cref="GuiMainPlayer.CurrentBet"/> according to the button clicked /// </summary> /// <param name="sender">The sending button which was clicked</param> /// <param name="betMultiplier">A multiplier in which the bet value is multiplied. 1 to increase, -1 to decrease</param> private void changePlayerBet(object sender, int betMultiplier) { // must have a valid player as the data context to change the current bet value GuiMainPlayer thePlayer = DataContext as GuiMainPlayer; if (thePlayer == null) { return; } // the bet value is also the button tag Button clickedButton = (Button)sender; int betValue = (int)clickedButton.Tag; // change the current bet by the given value thePlayer.CurrentBet += (betValue * betMultiplier); }
/// <summary> /// A callback for a player card click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CardButtonClicked(object sender, RoutedEventArgs e) { // must have a valid player as the data context to handle the current draw action GuiMainPlayer thePlayer = DataContext as GuiMainPlayer; if (thePlayer == null) { return; } // the card is also the button data context Button clickedCard = (Button)e.OriginalSource; CardWrapper wrapper = clickedCard.DataContext as CardWrapper; // send the player the button which was clicked. if (wrapper != null) { thePlayer.HandleCardDraw(wrapper); } }
public PokerGameBoard() { ThePlayer = new GuiMainPlayer(new Player("Unnamed Player")); }