Ejemplo n.º 1
0
        private void SignupBtn_Click(object sender, RoutedEventArgs e)
        {
            string username = userNameTB.Text;
            string password = passwordBox.Password;

            if (username == "" || password == "")
            {
                MessageBox.Show("An unhandled exception just occurred: Please enter credentials correctly", "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                var serverResponse = client.SignUp(username, password);
                if (serverResponse.ErrorMsg == null)
                {
                    if (InitWallet())
                    {
                        MessageBox.Show("Signup successful", "Update", MessageBoxButton.OK, MessageBoxImage.Information);
                        TableMenuPage p = new TableMenuPage(username, Wallet);
                        this.NavigationService.Navigate(p, UriKind.Relative);
                    }
                }
                else
                {
                    MessageBox.Show("An unhandled exception just occurred: " + serverResponse.ErrorMsg, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 2
0
        private void LeaveTable_Btn_Click(object sender, RoutedEventArgs e)
        {
            var serverResponse = MainWindow.client.LeaveTable();

            if (serverResponse.ErrorMsg == null)
            {
                MessageBox.Show("Leave table request successful", "Update", MessageBoxButton.OK, MessageBoxImage.Information);
                TableMenuPage p = new TableMenuPage(Username, Wallet);
                this.NavigationService.Navigate(p, UriKind.Relative);
                myTimer.Stop();
            }
            else
            {
                MessageBox.Show("An unhandled exception just occurred: " + serverResponse.ErrorMsg, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 3
0
        private void CancelBtn_Click(object sender, RoutedEventArgs e)
        {
            TableMenuPage t = new TableMenuPage(Username, Wallet);

            this.NavigationService.Navigate(t, UriKind.Relative);
        }
Ejemplo n.º 4
0
        public void UpdateTable(Object sender, EventArgs e)
        {
            bool        HasWon = false;
            TableStatus tableStatus;

            try
            {
                var serverResponse = MainWindow.client.GetTableStatus();
                if (serverResponse.ErrorMsg == null)
                {
                    tableStatus = serverResponse.Result;
                    if (!tableStatus.HasGameFinished)
                    {
                        UpdateLastMove(tableStatus.LastMove);
                        UpdateTableCards(tableStatus.TableCards.ToList());
                        if (tableStatus.IsMyTurn)
                        {
                            if (!IsReplay)
                            {
                                if (tableStatus.LastMove.BidAmount == FirstPlayer.BetAmount)
                                {
                                    All_In_Btn.IsEnabled   = true;
                                    Raise_Btn.IsEnabled    = true;
                                    Check_Btn.IsEnabled    = true;
                                    Raise_Slider.IsEnabled = true;
                                }
                                else
                                {
                                    Call_Btn.IsEnabled     = true;
                                    Raise_Btn.IsEnabled    = true;
                                    Fold_Btn.IsEnabled     = true;
                                    Raise_Slider.IsEnabled = true;
                                }
                            }
                        }
                        else
                        {
                            DisableAllButtons();
                        }
                    }
                    else
                    {
                        myTimer.Stop();
                        if (!IsReplay)
                        {
                            foreach (int id in tableStatus.WinnerIds.ToList())
                            {
                                if (id == myId)
                                {
                                    HasWon = true;
                                }
                            }
                            if (HasWon)
                            {
                                MessageBox.Show("Congratulations, You won and your winnings will be transferred to your account", "Update", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                            else
                            {
                                MessageBox.Show("You lost, Better luck next time!", "Update", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                        }
                        else
                        {
                            UpdateTableCards(tableStatus.TableCards.ToList());
                            MessageBox.Show("Game Ended!", "Update", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        var serverResponse2 = MainWindow.client.LeaveTable();
                        if (serverResponse2.ErrorMsg == null)
                        {
                            var serverResponse3 = MainWindow.client.GetWallet();
                            if (serverResponse3.ErrorMsg == null)
                            {
                                MessageBox.Show("Leave table request successful", "Update", MessageBoxButton.OK, MessageBoxImage.Information);
                                TableMenuPage p = new TableMenuPage(myPlayer.PlayerName, serverResponse3.Result);
                                this.NavigationService.Navigate(p, UriKind.Relative);
                            }
                            else
                            {
                                MessageBox.Show("An unhandled exception just occurred: " + serverResponse.ErrorMsg, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("An unhandled exception just occurred: " + serverResponse.ErrorMsg, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("An unhandled exception just occurred: " + serverResponse.ErrorMsg, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch
            {
            }
        }