Example #1
0
 public ArrayList chuPai(ArrayList listPai)
 {
     Jiepai jiepai = new Jiepai();
     ArrayList list = jiepai.basic(2, listPai);
     ArrayList list1 = new ArrayList();
     int leave = listPai.Count;
     int[] a = jiepai.mArrayToArgs((ArrayList)list[0]);
     int[] b = jiepai.mArrayToArgs((ArrayList)list[1]);
     int[] c = jiepai.mArrayToArgs((ArrayList)list[2]);
     int[] d = jiepai.mArrayToArgs((ArrayList)list[3]);
     if (list != null)
     {
         #region 判断是否有炸弹
         if (d != null)
         {
             if (leave == 4)  return listPai;
             if (leave > 4 && (a != null || b != null || c != null))
             {
                 if (d[d.Length - 1] != 15 || d[d.Length - 1] != 14)//判断炸弹是否为4条2或4条1,如果是就先出别的
                 {
                     list[0] = jiepai.removeBigPai(2, (ArrayList)list[0]);
                     list[1] = jiepai.removeBigPai(2, (ArrayList)list[1]);
                     int[] d1 = jiepai.mArrayToArgs((ArrayList)list[0]);
                     int[] d2 = jiepai.mArrayToArgs((ArrayList)list[1]);
                     if (d2 != null && d2.Length >= 2)
                     {
                         for (int i = 0; i < 4; i++)
                         {
                             list1.Add(d[0]);
                         }
                         list1.Add(d2[0]); list1.Add(d2[0]);
                         list1.Add(d2[1]); list1.Add(d2[1]);
                         return list1;
                     }
                     else if (d1 != null && d1.Length >= 2)
                     {
                         for (int i = 0; i < 4; i++)
                         {
                             list1.Add(d[0]);
                         }
                         list1.Add(d1[0]); list1.Add(d1[1]);
                         return list1;
                     }
                 }
             }
             #region 判断是否只剩下炸弹
             else if (a == null && b == null && c == null)
             {
                 for (int i = 0; i < 4; i++)
                 {
                     list1.Add(d[0]);
                 }
                 return list1;
             }
             #endregion
         }
         #endregion
         #region 判断是否有三张
         if (c != null)
         {
             if (leave == 3 || leave == 4) return listPai;
             if (leave == 5)
             {
                 if (b != null)  return listPai;
                 else if(d == null)
                 {
                     for (int i = 0; i < 3; i++)
                     {
                         list1.Add(c[0]);
                     }
                     list1.Add(a[0]);
                     return list1;
                 }
             }
             else if (leave > 5 && (a != null || b != null))
             {
                 list[1] = jiepai.removeBigPai(2, (ArrayList)list[1]);
                 int[] c1 = jiepai.mArrayToArgs((ArrayList)list[0]);
                 int[] c2 = jiepai.mArrayToArgs((ArrayList)list[1]);
                 if (c2 != null)
                 {
                     for (int i = 0; i < 3; i++)
                     {
                         list1.Add(c[0]);
                     }
                     list1.Add(c2[0]); list1.Add(c2[0]);
                     return list1;
                 }
                 else if (c1 != null)
                 {
                     for (int i = 0; i < 3; i++)
                     {
                         list1.Add(c[0]);
                     }
                     list1.Add(c1[0]);
                     return list1;
                 }
                 else
                 {
                     for (int i = 0; i < 3; i++)
                     {
                         list1.Add(c[0]);
                     }
                     return list1;
                 }
             }
             else
             {
                 for (int i = 0; i < 3; i++)
                 {
                     list1.Add(c[0]);
                 }
                 return list1;
             }
         }
         #endregion
         #region 判断是否有对子
         if (b != null)
         {
             if (leave == 2)  return listPai;
             Random rd = new Random();
             int num = rd.Next(2)+2;
             if (a == null || a != null && a.Length < num)
             {
                 list1.Add(b[0]); list1.Add(b[0]);
                 return list1;
             }
         }
         #endregion
         #region 判断是否有单张
         if (a != null)
         {
             list1.Add(a[0]);
             return list1;
         }
         #endregion
     }
     return null;
 }
Example #2
0
        public ArrayList chuPai(ArrayList listPai)
        {
            Jiepai    jiepai = new Jiepai();
            ArrayList list   = jiepai.basic(2, listPai);
            ArrayList list1  = new ArrayList();
            int       leave  = listPai.Count;

            int[] a = jiepai.mArrayToArgs((ArrayList)list[0]);
            int[] b = jiepai.mArrayToArgs((ArrayList)list[1]);
            int[] c = jiepai.mArrayToArgs((ArrayList)list[2]);
            int[] d = jiepai.mArrayToArgs((ArrayList)list[3]);
            if (list != null)
            {
                #region 判断是否有炸弹
                if (d != null)
                {
                    if (leave == 4)
                    {
                        return(listPai);
                    }
                    if (leave > 4 && (a != null || b != null || c != null))
                    {
                        if (d[d.Length - 1] != 15 || d[d.Length - 1] != 14)//判断炸弹是否为4条2或4条1,如果是就先出别的
                        {
                            list[0] = jiepai.removeBigPai(2, (ArrayList)list[0]);
                            list[1] = jiepai.removeBigPai(2, (ArrayList)list[1]);
                            int[] d1 = jiepai.mArrayToArgs((ArrayList)list[0]);
                            int[] d2 = jiepai.mArrayToArgs((ArrayList)list[1]);
                            if (d2 != null && d2.Length >= 2)
                            {
                                for (int i = 0; i < 4; i++)
                                {
                                    list1.Add(d[0]);
                                }
                                list1.Add(d2[0]); list1.Add(d2[0]);
                                list1.Add(d2[1]); list1.Add(d2[1]);
                                return(list1);
                            }
                            else if (d1 != null && d1.Length >= 2)
                            {
                                for (int i = 0; i < 4; i++)
                                {
                                    list1.Add(d[0]);
                                }
                                list1.Add(d1[0]); list1.Add(d1[1]);
                                return(list1);
                            }
                        }
                    }
                    #region 判断是否只剩下炸弹
                    else if (a == null && b == null && c == null)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            list1.Add(d[0]);
                        }
                        return(list1);
                    }
                    #endregion
                }
                #endregion
                #region 判断是否有三张
                if (c != null)
                {
                    if (leave == 3 || leave == 4)
                    {
                        return(listPai);
                    }
                    if (leave == 5)
                    {
                        if (b != null)
                        {
                            return(listPai);
                        }
                        else if (d == null)
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                list1.Add(c[0]);
                            }
                            list1.Add(a[0]);
                            return(list1);
                        }
                    }
                    else if (leave > 5 && (a != null || b != null))
                    {
                        list[1] = jiepai.removeBigPai(2, (ArrayList)list[1]);
                        int[] c1 = jiepai.mArrayToArgs((ArrayList)list[0]);
                        int[] c2 = jiepai.mArrayToArgs((ArrayList)list[1]);
                        if (c2 != null)
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                list1.Add(c[0]);
                            }
                            list1.Add(c2[0]); list1.Add(c2[0]);
                            return(list1);
                        }
                        else if (c1 != null)
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                list1.Add(c[0]);
                            }
                            list1.Add(c1[0]);
                            return(list1);
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                list1.Add(c[0]);
                            }
                            return(list1);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            list1.Add(c[0]);
                        }
                        return(list1);
                    }
                }
                #endregion
                #region 判断是否有对子
                if (b != null)
                {
                    if (leave == 2)
                    {
                        return(listPai);
                    }
                    Random rd  = new Random();
                    int    num = rd.Next(2) + 2;
                    if (a == null || a != null && a.Length < num)
                    {
                        list1.Add(b[0]); list1.Add(b[0]);
                        return(list1);
                    }
                }
                #endregion
                #region 判断是否有单张
                if (a != null)
                {
                    list1.Add(a[0]);
                    return(list1);
                }
                #endregion
            }
            return(null);
        }
Example #3
0
 private void load()
 {
     SoundStart = new SoundPlayer(global::斗地主.Properties.Resources.start);
     SoundClick = new SoundPlayer(global::斗地主.Properties.Resources.click);
     SoundGive = new SoundPlayer(global::斗地主.Properties.Resources.give);
     SoundLoss = new SoundPlayer(global::斗地主.Properties.Resources.loss);
     SoundWin = new SoundPlayer(global::斗地主.Properties.Resources.win);
     kaiju.GameNum++;
     this.lbl_jushu.Text = "第" + kaiju.GameNum + "局";
     this.lbl_beishu.Text = "倍数:   ×1";
     this.lbl_difen.Text = "底分:   ×1";
     this.lbl_leftJiFen.Text = player3 + "";
     this.lbl_rightJiFen.Text = player1 + "";
     this.lbl_DownJiFen.Text = player2 + "";
     weituo1 = new Myweituo1(zhiXiangTu);
     weituo2 = new Myweituo2(btnJiaoFen);
     weituo3 = new Myweituo2(btnChuPai_3);
     weituo4 = new Myweituo2(btnChuPai_1);
     weituo5 = new Myweituo1(zhiXiangTu);
     pai = new Puke[54];
     paiImage = new PictureBox[54];
     chupai = new Chupai();
     jiepai = new Jiepai();
     Cchupai = new ComputerChuPai();
     saveList = new ArrayList();
     th_daPai = new Thread(new ThreadStart(daPai));
     th_faPai = new Thread(new ThreadStart(fapai));
     newPlayer("长夜漫漫", "寂寞出租", "涛声依旧");
     newPai();
     suiji1();
     newPaiImage();
     pai_paixu(juese1);
     pai_paixu(juese2);
     pai_paixu(juese3);
     addJuesePai(juese1);
     addJuesePai(juese2);
     addJuesePai(juese3);
 }