예제 #1
0
        private void return_button_Click(object sender, RoutedEventArgs e)
        {
            gameCenter GC = new gameCenter(BL, user, null);

            GC.Show();
            this.Close();
        }
예제 #2
0
        private void leave_game_Click(object sender, RoutedEventArgs e)
        {
            BL.leaveGame(Game.GameID, user.ID);
            newThread.Abort();
            gameCenter GC = new gameCenter(BL, user, null);

            GC.Show();
            this.Close();
        }
예제 #3
0
        private void login_Click(object sender, RoutedEventArgs e)
        {
            bool isUserExist;
            User user = null;

            isUserExist = BL.login(id_textBox.Text, pass_textBox.Text);
            if (!isUserExist)
            {
                MessageBox.Show("Logging in Failed, ID or password wrong", "Logging in Failed", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                user = BL.getUser(id_textBox.Text);


                gameCenter GC = new gameCenter(BL, user, null);
                GC.Show();
                this.Close();
            }
        }
        private void create_button_Click(object sender, RoutedEventArgs e)
        {
            String   gameID = "";
            int      limit, buyIN, chipPolicy, minBet, minPlayers, MaxPlayers;
            bool     spectatable = false, leaguable = false;
            GameType type = GameType.POT_LIMIT;

            try
            { limit = int.Parse(limit_textBox.Text); }
            catch { limit = 0; }
            try
            { buyIN = int.Parse(buyIn_textBox.Text); }
            catch { buyIN = 0; }
            try
            { chipPolicy = int.Parse(chipPolicy_textBox.Text); }
            catch { chipPolicy = 0; }
            try
            { minBet = int.Parse(minBet_textBox.Text); }
            catch { minBet = 0; }
            try
            { minPlayers = int.Parse(minPlayers_textBox.Text); }
            catch { minPlayers = 2; }
            try
            { MaxPlayers = int.Parse(maxPlayers_textBox.Text); }
            catch { MaxPlayers = 8; }
            if (spectatable_comboBox.SelectedIndex == 0)
            {
                spectatable = true;
            }
            if (leaguable_comboBox.SelectedIndex == 0)
            {
                leaguable = true;
            }
            if (comboBox.SelectedIndex == 0)
            {
                type = GameType.LIMIT;
            }
            if (comboBox.SelectedIndex == 1)
            {
                type = GameType.NO_LIMIT;
            }

            if (isCreate)
            {
                gameID = BL.createGame(user.ID, type, limit, buyIN, chipPolicy, minBet, minPlayers, MaxPlayers, spectatable, leaguable, this.user.league);
                if (gameID == null)
                {
                    MessageBox.Show("error \n one or more of the parameters is invalid");
                }

                BL.game game = BL.getGameByID(gameID);
                game    g    = new game(BL, game, user);
                g.Show();
                this.Close();
            }
            else
            {
                LinkedList <string> prefsGames;
                prefsGames = BL.searchGameByPrefs(type, limit, buyIN, chipPolicy, minBet, minPlayers, MaxPlayers, spectatable, leaguable, this.user.league);
                if (prefsGames == null)
                {
                    prefsGames = new LinkedList <string>();
                    prefsGames.AddLast("none");
                }
                gameCenter GC = new gameCenter(BL, user, prefsGames);
                GC.Show();
                this.Close();
            }
        }