Esempio n. 1
0
 private bool check_win(Brand brand)
 {
     // 有沒有人要胡
     for (int i = 0; i < 3; i++)
     {
         all.next();
         CheckBrands w = new CheckBrands(brand, all.NowPlayer);
         Ai.setPlayer(brand, all.NowPlayer);
         if (w.Win())
         {
             // 如果是玩家
             if (NowPlayer_is_Real_Player)
             {
                 CheckUser check = new Control.CheckUser(false, false, false, false, true, true, brand);
                 toUser(check);
                 // 如果玩家按下過水 就跳過
                 if (Player_Pass_Brand)
                 {
                     Player_Pass_Brand = false;
                 }
                 // 若不是按下過水就傳回 失敗
                 else
                 {
                     return(true);
                 }
             }
             else if (Ai.Win)
             {
                 // 更新資訊盒
                 setInforamtion();
                 if (PlayerSound)
                 {
                     soundplayer.Stream = Resources.win;
                     soundplayer.Play();
                 }
                 if (showMessageBox)
                 {
                     ShowMessage(Mahjong.Properties.Settings.Default.Win);
                 }
                 win_game(brand);
                 return(true);
             }
         }
     }
     all.next();
     return(false);
 }
Esempio n. 2
0
        /// <summary>
        /// 摸牌
        /// </summary>
        internal void touchBrand()
        {
            table.updateNowPlayer();
            // 摸牌給現在的玩家
            Brand nextbrand = all.nextBrand();

            // 補花並加上一張牌
            if (all.Player_setFlower(nextbrand))
            {
                touchBrand();
            }
            else
            {
                // 是否胡牌或槓牌(手牌加摸到的牌)
                CheckBrands win = new CheckBrands(nextbrand, all.NowPlayer);
                // 除去顯示牌看是否有暗槓(移除牌組的牌加摸到的牌)
                CheckBrands kong = new CheckBrands(nextbrand, NowPlayer_removeTeam);
                // 除去顯示或打出的牌看是否有暗槓
                CheckBrands darkkong = new CheckBrands(NowPlayer_removeTeam);
                // 只有牌組和摸進來的牌做比較
                CheckBrands teamKong = new CheckBrands(nextbrand, NowPlayer_OnlyTeam);
                if (win.Win())
                {
                    // 更新資訊盒
                    setInforamtion();
                    if (showMessageBox)
                    {
                        ShowMessage(Settings.Default.TouchWin);
                    }
                    win_game(nextbrand);
                }
                // 手牌暗槓(摸到有暗槓和手牌中就有暗槓)
                else if (darkkong.DarkKong() || kong.Kong())
                {
                    // 如果是玩家
                    if (NowPlayer_is_Real_Player)
                    {
                        Brand br = null;
                        if (darkkong.DarkKong())
                        {
                            br = darkkong.SuccessPlayer.getBrand(0);
                        }
                        else if (kong.Kong())
                        {
                            br = kong.SuccessPlayer.getBrand(0);
                        }

                        toUser(br, false, false, false, kong.Kong() || darkkong.DarkKong(), false);
                        // 如果玩家按下過水 就跳過
                        if (Player_Pass_Brand)
                        {
                            Player_Pass_Brand = false;
                        }
                        else
                        {
                            touchBrand();
                        }
                    }
                    // 如果不是玩家
                    else
                    {
                        if (showMessageBox)
                        {
                            ShowMessage(Mahjong.Properties.Settings.Default.DarkKong);
                        }
                        if (kong.Kong())
                        {
                            if (PlayerSound)
                            {
                                soundplayer.Stream = Resources.kong;
                                soundplayer.Play();
                            }
                            all.DarkKong(nextbrand, kong.SuccessPlayer);
                        }
                        else if (darkkong.DarkKong())
                        {
                            if (PlayerSound)
                            {
                                soundplayer.Stream = Resources.kong;
                                soundplayer.Play();
                            }
                            all.DarkKong(nextbrand, darkkong.SuccessPlayer);
                        }
                        touchBrand();
                    }
                }
                // 明碰之後再槓
                else if (teamKong.Kong())
                {
                    if (NowPlayer_is_Real_Player)
                    {
                        toUser(nextbrand, false, false, teamKong.Kong(), false, false);
                        if (Player_Pass_Brand)
                        {
                            Player_Pass_Brand = false;
                        }
                        else
                        {
                            touchBrand();
                        }
                    }
                    else
                    {
                        if (PlayerSound)
                        {
                            soundplayer.Stream = Resources.kong;
                            soundplayer.Play();
                        }
                        if (showMessageBox)
                        {
                            ShowMessage(Mahjong.Properties.Settings.Default.Kong);
                        }
                        all.kong(nextbrand, darkkong.SuccessPlayer);
                        touchBrand();
                    }
                }
                else
                {
                    // 把牌加入玩家
                    all.NowPlayer.add(nextbrand);
                    table.updateNowPlayer();
                }
            }
        }
Esempio n. 3
0
        private bool check_pong_kong(Brand brand)
        {
            // 測試是否被 槓 碰
            for (int i = 0; i < 3; i++)
            {
                all.next();
                CheckBrands c = new CheckBrands(brand, NowPlayer_removeTeam);
                CheckBrands w = new CheckBrands(brand, all.NowPlayer);
                Ai.setPlayer(brand, all.NowPlayer);
                // 如果是玩家
                if (NowPlayer_is_Real_Player)
                {
                    if (c.Pong() || c.Kong())
                    {
                        toUser(brand, (c.Chow() && i == 0), c.Pong(), c.Kong(), false, w.Win());
                        if (Player_Pass_Brand)
                        {
                            Player_Pass_Brand = false;
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    // 槓
                    if (c.Kong() && Ai.Kong)
                    {
                        setInforamtion();
                        if (PlayerSound)
                        {
                            soundplayer.Stream = Resources.kong;
                            soundplayer.Play();
                        }
                        if (showMessageBox)
                        {
                            ShowMessage(Mahjong.Properties.Settings.Default.Kong);
                        }
                        all.kong(brand, c.SuccessPlayer);
                        Chow_Pong_Brand = false;
                        updatePlayer_Table();
                        return(true);
                    }
                    // 碰
                    else if (c.Pong() && Ai.Pong)
                    {
                        setInforamtion();
                        if (PlayerSound)
                        {
                            soundplayer.Stream = Resources.pon;
                            soundplayer.Play();
                        }
                        if (showMessageBox)
                        {
                            ShowMessage(Mahjong.Properties.Settings.Default.Pong);
                        }
                        all.chow_pong(brand, c.SuccessPlayer);
                        updatePlayer_Table();
                        Chow_Pong_Brand = true;

                        return(true);
                    }
                }
            }
            all.next();
            return(false);
        }
Esempio n. 4
0
 private bool check_win(Brand brand)
 {
     // ���S���H�n�J
     for (int i = 0; i < 3; i++)
     {
         all.next();
         CheckBrands w = new CheckBrands(brand, all.NowPlayer);
         Ai.setPlayer(brand, all.NowPlayer);
         if (w.Win())
         {
             // �p�G�O���a
             if (NowPlayer_is_Real_Player)
             {
                 toUser(brand, false, false, false, false, true);
                 // �p�G���a���U�L�� �N���L
                 if (Player_Pass_Brand)
                     Player_Pass_Brand = false;
                 // �Y���O���U�L��N�Ǧ^ ����
                 else
                     return true;
             }
             else if (Ai.Win)
             {
                 // ��s��T��
                 setInforamtion();
                 if (PlayerSound)
                 {
                     soundplayer.Stream = Resources.win;
                     soundplayer.Play();
                 }
                 if (showMessageBox)
                     ShowMessage(Mahjong.Properties.Settings.Default.Win);
                 win_game(brand);
                 return true;
             }
         }
     }
     all.next();
     return false;
 }
Esempio n. 5
0
        private bool check_pong_kong(Brand brand)
        {
            // ���լO�_�Q �b �I
            for (int i = 0; i < 3; i++)
            {
                all.next();
                CheckBrands c = new CheckBrands(brand, NowPlayer_removeTeam);
                CheckBrands w = new CheckBrands(brand, all.NowPlayer);
                Ai.setPlayer(brand, all.NowPlayer);
                // �p�G�O���a
                if (NowPlayer_is_Real_Player)
                {
                    if (c.Pong() || c.Kong())
                    {
                        toUser(brand, (c.Chow() && i == 0), c.Pong(), c.Kong(), false, w.Win());
                        if (Player_Pass_Brand)
                            Player_Pass_Brand = false;
                        else
                            return true;
                    }
                }
                else
                {
                    // �b
                    if (c.Kong() && Ai.Kong)
                    {
                        setInforamtion();
                        if (PlayerSound)
                        {
                            soundplayer.Stream = Resources.kong;
                            soundplayer.Play();
                        }
                        if (showMessageBox)
                            ShowMessage(Mahjong.Properties.Settings.Default.Kong);
                        all.kong(brand, c.SuccessPlayer);
                        Chow_Pong_Brand = false;
                        updatePlayer_Table();
                        return true;
                    }
                    // �I
                    else if (c.Pong() && Ai.Pong)
                    {
                        setInforamtion();
                        if (PlayerSound)
                        {
                            soundplayer.Stream = Resources.pon;
                            soundplayer.Play();
                        }
                        if (showMessageBox)
                            ShowMessage(Mahjong.Properties.Settings.Default.Pong);
                        all.chow_pong(brand, c.SuccessPlayer);
                        updatePlayer_Table();
                        Chow_Pong_Brand = true;

                        return true;
                    }
                }
            }
            all.next();
            return false;
        }
Esempio n. 6
0
        private bool check_chow(Brand brand)
        {
            // ���S���H�n�Y
            for (int i = 0; i < 3; i++)
            {
                all.next();
                CheckBrands c = new CheckBrands(brand, NowPlayer_removeTeam);
                CheckBrands w = new CheckBrands(brand, all.NowPlayer);
                Ai.setPlayer(brand, all.NowPlayer);
                // �u���U�a��Y
                if (c.Chow() && i == 0)
                {
                    // �p�G�O�u�ꪱ�a
                    if (NowPlayer_is_Real_Player)
                    {
                        toUser(brand, (c.Chow() && i == 0), c.Pong(), c.Kong(), false, w.Win());
                        if (Player_Pass_Brand)
                            Player_Pass_Brand = false;
                        else
                            return true;
                    }
                    else if (Ai.Chow)
                    {
                        setInforamtion();
                        if (PlayerSound)
                        {
                            soundplayer.Stream = Resources.chow;
                            soundplayer.Play();
                        }
                        if (showMessageBox)
                            ShowMessage(Mahjong.Properties.Settings.Default.Chow);
                        all.chow_pong(brand, c.SuccessPlayer);
                        updatePlayer_Table();
                        Chow_Pong_Brand = true;
                        return true;
                    }
                }

            }
            all.next();
            return false;
        }
Esempio n. 7
0
        /// <summary>
        /// �N�P
        /// </summary>
        internal void touchBrand()
        {
            table.updateNowPlayer();
            // �N�P���{�b�����a
            Brand nextbrand = all.nextBrand();
            // �ɪ�å[�W�@�i�P
            if (all.Player_setFlower(nextbrand))
            {
                touchBrand();
            }
            else
            {
                // �O�_�J�P�κb�P(��P�[�N�쪺�P)
                CheckBrands win = new CheckBrands(nextbrand, all.NowPlayer);
                // ���h��ܵP�ݬO�_���t�b(�����P�ժ��P�[�N�쪺�P)
                CheckBrands kong = new CheckBrands(nextbrand, NowPlayer_removeTeam);
                // ���h��ܩΥ��X���P�ݬO�_���t�b
                CheckBrands darkkong = new CheckBrands(NowPlayer_removeTeam);
                // �u���P�թM�N�i�Ӫ��P�����
                CheckBrands teamKong = new CheckBrands(nextbrand, NowPlayer_OnlyTeam);
                if (win.Win())
                {
                    // ��s��T��
                    setInforamtion();
                    if (showMessageBox)
                        ShowMessage(Settings.Default.TouchWin);
                    win_game(nextbrand);
                }
                // ��P�t�b(�N�즳�t�b�M��P���N���t�b)
                else if (darkkong.DarkKong() || kong.Kong())
                {
                    // �p�G�O���a
                    if (NowPlayer_is_Real_Player)
                    {
                        Brand br = null;
                        if (darkkong.DarkKong())
                        {
                            br = darkkong.SuccessPlayer.getBrand(0);
                        }
                        else if (kong.Kong())
                        {
                            br = kong.SuccessPlayer.getBrand(0);
                        }

                        toUser(br, false, false, false, kong.Kong() || darkkong.DarkKong(), false);
                        // �p�G���a���U�L�� �N���L
                        if (Player_Pass_Brand)
                            Player_Pass_Brand = false;
                        else
                        {
                            touchBrand();
                        }
                    }
                    // �p�G���O���a
                    else
                    {
                        if (showMessageBox)
                            ShowMessage(Mahjong.Properties.Settings.Default.DarkKong);
                        if (kong.Kong())
                        {
                            if (PlayerSound)
                            {
                                soundplayer.Stream = Resources.kong;
                                soundplayer.Play();
                            }
                            all.DarkKong(nextbrand, kong.SuccessPlayer);
                        }
                        else if (darkkong.DarkKong())
                        {
                            if (PlayerSound)
                            {
                                soundplayer.Stream = Resources.kong;
                                soundplayer.Play();
                            }
                            all.DarkKong(nextbrand, darkkong.SuccessPlayer);
                        }
                        touchBrand();
                    }
                }
                // ���I����A�b
                else if (teamKong.Kong())
                {
                    if (NowPlayer_is_Real_Player)
                    {
                        toUser(nextbrand, false, false, teamKong.Kong(), false, false);
                        if (Player_Pass_Brand)
                            Player_Pass_Brand = false;
                        else
                        {
                            touchBrand();
                        }
                    }
                    else
                    {
                        if (PlayerSound)
                        {
                            soundplayer.Stream = Resources.kong;
                            soundplayer.Play();
                        }
                        if (showMessageBox)
                            ShowMessage(Mahjong.Properties.Settings.Default.Kong);
                        all.kong(nextbrand, darkkong.SuccessPlayer);
                        touchBrand();
                    }
                }
                else
                {
                    // ��P�[�J���a
                    all.NowPlayer.add(nextbrand);
                    table.updateNowPlayer();
                }
            }
        }
Esempio n. 8
0
 private bool check_chow(Brand brand)
 {
     // 有沒有人要吃
     for (int i = 0; i < 3; i++)
     {
         all.next();
         CheckBrands c = new CheckBrands(brand, NowPlayer_removeTeam);
         CheckBrands w = new CheckBrands(brand, all.NowPlayer);
         Ai.setPlayer(brand, all.NowPlayer);
         // 只有下家能吃
         if (c.Chow() && i == 0)
         {
             // 如果是真實玩家
             if (NowPlayer_is_Real_Player)
             {
                 CheckUser check = new Control.CheckUser((c.Chow() && i == 0), c.Pong(), c.Kong(), false, w.Win(), true, brand);
                 toUser(check);
                 if (Player_Pass_Brand)
                 {
                     Player_Pass_Brand = false;
                 }
                 else
                 {
                     return(true);
                 }
             }
             else if (Ai.Chow)
             {
                 setInforamtion();
                 if (PlayerSound)
                 {
                     soundplayer.Stream = Resources.chow;
                     soundplayer.Play();
                 }
                 if (showMessageBox)
                 {
                     ShowMessage(Mahjong.Properties.Settings.Default.Chow);
                 }
                 all.chow_pong(brand, c.SuccessPlayer);
                 updatePlayer_Table();
                 Chow_Pong_Brand = true;
                 return(true);
             }
         }
     }
     all.next();
     return(false);
 }