Esempio n. 1
0
        void addscore(BrandPlayer brandclass, int score, int compare)
        {
            BrandPlayer[] temp = new BrandPlayer[9];
            for (int j = 0; j < temp.Length; j++)
            {
                temp[j] = new BrandPlayer();
            }
            //將brands陣列每個數的值,丟到use_Dots分類
            for (int i = 0; i < brandclass.getCount(); i++)
            {
                for (int j = 1; j <= temp.Length; j++)
                {
                    if (brandclass.getBrand(i).getNumber() == j)
                    {
                        temp[j - 1].add(brandclass.getBrand(i));
                    }
                }
            }

            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].getCount() >= compare)
                {
                    for (int j = 0; j < temp[i].getCount(); j++)
                    {
                        temp[i].getBrand(j).Source += score;
                    }
                }
            }
        }
Esempio n. 2
0
        void samecolor(BrandPlayer q)
        {
            int num = 0;

            //bool index = false;
            for (int i = 0; i < q.getCount(); i++)
            {
                if (q.getBrand(i).getClass() == "字")
                {
                    num++;
                }
            }
            if (num == q.getCount())
            {
                textBox1.Text += "字一色\r\n";
                tally         += 8;
            }
            num = 0;

            for (int i = 0; i < q.getCount() - 1; i++)
            {
                if (q.getBrand(i).getClass() == q.getBrand(i + 1).getClass() && q.getBrand(i).getClass() != "字")
                {
                    num++;
                }
            }
            if (num == q.getCount() - 1)
            {
                textBox1.Text += "清一色\r\n";
                tally         += 8;
            }
            num = 0;

            for (int i = 0; i < q.getCount(); i++)
            {
                if (q.getBrand(i).getClass() == "字")
                {
                    index = true;
                    q.remove(q.getBrand(i));
                    i -= 1;
                }
            }
            if (index == true)
            {
                for (int i = 0; i < q.getCount() - 1; i++)
                {
                    if (q.getBrand(i).getClass() == q.getBrand(i + 1).getClass() && q.getBrand(i).getClass() != "字")
                    {
                        num++;
                    }
                }
                if (num == q.getCount() - 1)
                {
                    textBox1.Text += "混一色\r\n";
                    tally         += 4;
                }
                num = 0;
            }
            index = false;
        }
Esempio n. 3
0
 /// <summary>
 /// 牌的狀態檢查 暗槓
 /// </summary>
 /// <param name="player">牌玩家</param>
 public CheckBrands(BrandPlayer player)
 {
     for (int i = 0; i < player.getCount(); i++)
     {
         if (player.getBrand(i).getClass() != Mahjong.Properties.Settings.Default.Flower)
         {
             x.add(player.getBrand(i));
         }
     }
     for (int i = 0; i < chow_player.Length; i++)
     {
         chow_player[i] = new BrandPlayer();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 設定群組號碼
 /// </summary>
 /// <param name="player">玩家</param>
 private void set_Team(BrandPlayer player, bool isCanSee)
 {
     teamCount[state]++;
     // 把牌從現在玩家手上移出
     for (int i = 0; i < player.getCount(); i++)
     {
         NowPlayer.remove(player.getBrand(i));
     }
     // 把牌設為可視並且加上組別號碼後加回現在玩家
     for (int i = 0; i < player.getCount(); i++)
     {
         player.getBrand(i).IsCanSee = isCanSee;
         player.getBrand(i).Team     = teamCount[state];
         NowPlayer.add(player.getBrand(i));
     }
 }
Esempio n. 5
0
        void addimage_to_FlowLayout(FlowLayoutPanel flow, BrandPlayer player, EventHandler ev)
        {
            for (int i = 0; i < player.getCount(); i++)
            {
                Bitmap   bitmap = new Bitmap(ResourcesTool.getImage(player.getBrand(i)));
                BrandBox b      = new BrandBox(player.getBrand(i));

                b.SizeMode = PictureBoxSizeMode.AutoSize;

                bitmap   = ResizeBitmap(bitmap, Mahjong.Properties.Settings.Default.ResizePercentage);
                b.Click += ev;

                b.Image = bitmap;
                flow.Controls.Add(b);
            }
        }
Esempio n. 6
0
        Brand nextTableBrand()
        {
            Brand b = table.getBrand(0);

            table.remove(b);
            lastBrand = b;
            return(b);
        }
Esempio n. 7
0
 private void brand_2()
 {
     // 對子的牌組
     for (int i = 0; i < x.getCount() - 1; i++)
     {
         if (x.getBrand(i).getClass() == x.getBrand(i + 1).getClass() && x.getBrand(i).getNumber() == x.getBrand(i + 1).getNumber() && x.getBrand(i).Team == 0 && x.getBrand(i + 1).Team == 0)
         {
             if (b.getCount() == 0)
             {
                 b.add(x.getBrand(i));
                 b.add(x.getBrand(i));
             }
             else if (x.getBrand(i + 1).getClass() != b.getBrand(b.getCount() - 1).getClass() ||
                      x.getBrand(i + 1).getNumber() != b.getBrand(b.getCount() - 1).getNumber())
             {
                 b.add(x.getBrand(i));
                 b.add(x.getBrand(i));
             }
         }
     }
 }
Esempio n. 8
0
        public DealTest()
        {
            BrandPlayer[] player = new BrandPlayer[4];
            BrandPlayer   table  = new BrandPlayer();

            BrandFactory x = new BrandFactory();

            x.createBrands();
            x.randomBrands();

            table = x.getBrands();
            Console.WriteLine("共有: {0}", table.getCount());
            // 印出洗好的牌
            printplayer(table, "亂數牌");

            PlayerSort  bbs        = new PlayerSort(table);
            BrandPlayer sort_table = bbs.getPlayer;

            printplayer(sort_table, "亂數排序回去");

            // 分配牌
            Deal deal = new Deal(16, table);

            deal.DealBrands();
            player = deal.Player;

            // 印出全部的玩家
            printplayer(player);

            BrandPlayer check = new BrandPlayer();

            foreach (BrandPlayer b in player)
            {
                for (int i = 0; i < b.getCount(); i++)
                {
                    check.add(b.getBrand(i));
                }
            }
            for (int i = 0; i < table.getCount(); i++)
            {
                check.add(table.getBrand(i));
            }
            PlayerSort bs = new PlayerSort(check);

            check = bs.getPlayer;
            Console.WriteLine("\n共有: {0}", check.getCount());
            printplayer(check, "重新檢查");
        }
Esempio n. 9
0
        /// <summary>
        /// 分配牌
        /// </summary>
        public void DealBrands()
        {
            BrandPlayer temp = new BrandPlayer();

            // 讀出數量的牌,並移除
            for (int i = 0; i < countplayer * countbrands; i++)
            {
                Brand brand = table.getBrand(i);
                temp.add(brand);
                table.remove(brand);
            }
            // 把牌加入玩家
            for (int i = 0; i < temp.getCount(); i++)
            {
                player[i % countplayer].add(temp.getBrand(i));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 吃 成立
        /// </summary>
        /// <returns>是/否</returns>
        public bool Chow()
        {
            bool chow_bool = false;

            ans_player.clear();
            if (brand != null && brand.getClass() != Mahjong.Properties.Settings.Default.Wordtiles)
            {
                for (int i = 0; i < x.getCount() - 1; i++)
                {
                    for (int j = i + 1; j < x.getCount(); j++)
                    {
                        if ( // 345
                            brand.getClass() == x.getBrand(i).getClass() &&
                            brand.getNumber() + 1 == x.getBrand(i).getNumber() &&
                            brand.getClass() == x.getBrand(j).getClass() &&
                            brand.getNumber() + 2 == x.getBrand(j).getNumber())
                        {
                            if (ans_player.getCount() < 3)
                            {
                                ans_player.add(x.getBrand(i));
                                ans_player.add(brand);
                                ans_player.add(x.getBrand(j));
                            }
                            if (chow_player[0].getCount() < 3)
                            {
                                chow_player[0].add(x.getBrand(i));
                                chow_player[0].add(brand);
                                chow_player[0].add(x.getBrand(j));
                                chow_index++;
                            }
                            chow_bool = true;
                        }
                        if ( // 234
                            brand.getClass() == x.getBrand(i).getClass() &&
                            brand.getNumber() - 1 == x.getBrand(i).getNumber() &&
                            brand.getClass() == x.getBrand(j).getClass() &&
                            brand.getNumber() + 1 == x.getBrand(j).getNumber())
                        {
                            if (ans_player.getCount() < 3)
                            {
                                ans_player.add(x.getBrand(i));
                                ans_player.add(brand);
                                ans_player.add(x.getBrand(j));
                            }
                            if (chow_player[1].getCount() < 3)
                            {
                                chow_player[1].add(x.getBrand(i));
                                chow_player[1].add(brand);
                                chow_player[1].add(x.getBrand(j));
                                chow_index++;
                            }
                            chow_bool = true;
                        }
                        if ( // 123
                            brand.getClass() == x.getBrand(i).getClass() &&
                            brand.getNumber() - 2 == x.getBrand(i).getNumber() &&
                            brand.getClass() == x.getBrand(j).getClass() &&
                            brand.getNumber() - 1 == x.getBrand(j).getNumber())
                        {
                            if (ans_player.getCount() < 3)
                            {
                                ans_player.add(x.getBrand(i));
                                ans_player.add(brand);
                                ans_player.add(x.getBrand(j));
                            }
                            if (chow_player[2].getCount() < 3)
                            {
                                chow_player[2].add(x.getBrand(i));
                                chow_player[2].add(brand);
                                chow_player[2].add(x.getBrand(j));
                                chow_index++;
                            }
                            chow_bool = true;
                        }
                    }
                }
            }
            return(chow_bool);
        }
Esempio n. 11
0
        /// <summary>
        /// 胡牌 成立
        /// </summary>
        /// <returns>是/否</returns>
        public bool Win()
        {
            if (brand != null)
            {
                x.add(brand);
                PlayerSort d = new PlayerSort(x);
                x = d.getPlayer;
            }
            brand_2();
            bradn_4();
            bradn_3();

            // 組合測試
            // a 三支
            // b 兩隻
            // c 組合
            int count = 0;

            for (int i = 0; i < a.getCount(); i += 3)
            {
                for (int j = i + 3; j < a.getCount(); j += 3)
                {
                    for (int k = j + 3; k < a.getCount(); k += 3)
                    {
                        for (int l = k + 3; l < a.getCount(); l += 3)
                        {
                            for (int m = l + 3; m < a.getCount(); m += 3)
                            {
                                for (int n = 0; n < b.getCount(); n += 2)
                                {
                                    c.clear();
                                    c.add(a.getBrand(i));
                                    c.add(a.getBrand(i + 1));
                                    c.add(a.getBrand(i + 2));
                                    c.add(a.getBrand(j));
                                    c.add(a.getBrand(j + 1));
                                    c.add(a.getBrand(j + 2));
                                    c.add(a.getBrand(k));
                                    c.add(a.getBrand(k + 1));
                                    c.add(a.getBrand(k + 2));
                                    c.add(a.getBrand(l));
                                    c.add(a.getBrand(l + 1));
                                    c.add(a.getBrand(l + 2));
                                    c.add(a.getBrand(m));
                                    c.add(a.getBrand(m + 1));
                                    c.add(a.getBrand(m + 2));
                                    c.add(b.getBrand(n));
                                    c.add(b.getBrand(n + 1));

                                    PlayerSort d = new PlayerSort(c);
                                    c = d.getPlayer;
                                    //牌的比對
                                    //完全成立代表胡牌
                                    for (int o = 0; o < x.getCount(); o++)
                                    {
                                        if (c.getBrand(o).getClass() == x.getBrand(o).getClass() &&
                                            c.getBrand(o).getNumber() == x.getBrand(o).getNumber())
                                        {
                                            count = o;
                                            continue;
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    if (count == x.getCount() - 1)
                                    {
                                        if (brand != null)
                                        {
                                            x.remove(brand);
                                        }
                                        return(true); // 成立
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (brand != null)
            {
                x.remove(brand);
            }
            return(false);
        }
Esempio n. 12
0
 private void bradn_3()
 {
     for (int i = 0; i < x.getCount() - 2; i++)
     {
         for (int j = i + 1; j < x.getCount() - 1; j++)
         {
             for (int k = j + 1; k < x.getCount(); k++)
             {
                 if (x.getBrand(k).getClass() != Mahjong.Properties.Settings.Default.Wordtiles && //順子的牌組
                     x.getBrand(i).getClass() == x.getBrand(j).getClass() &&
                     x.getBrand(i).getNumber() == x.getBrand(j).getNumber() - 1 &&
                     x.getBrand(j).getClass() == x.getBrand(k).getClass() &&
                     x.getBrand(j).getNumber() == x.getBrand(k).getNumber() - 1 &&
                     x.getBrand(i).Team == x.getBrand(j).Team&&
                     x.getBrand(j).Team == x.getBrand(k).Team)
                 {
                     if (a.getCount() == 0)
                     {
                         a.add(x.getBrand(i));
                         a.add(x.getBrand(j));
                         a.add(x.getBrand(k));
                     }
                     else if (x.getBrand(i) != a.getBrand(a.getCount() - 3) &&
                              x.getBrand(j) != a.getBrand(a.getCount() - 2) &&
                              x.getBrand(k) != a.getBrand(a.getCount() - 1))
                     {
                         a.add(x.getBrand(i));
                         a.add(x.getBrand(j));
                         a.add(x.getBrand(k));
                     }
                 } // 順子的牌組結束
                 else if (x.getBrand(i).getClass() == x.getBrand(j).getClass() &&
                          x.getBrand(i).getNumber() == x.getBrand(j).getNumber() &&
                          x.getBrand(j).getClass() == x.getBrand(k).getClass() &&
                          x.getBrand(j).getNumber() == x.getBrand(k).getNumber() &&
                          x.getBrand(i).Team == x.getBrand(j).Team&&
                          x.getBrand(j).Team == x.getBrand(k).Team)
                 { // 碰的牌組
                     if (a.getCount() == 0)
                     {
                         a.add(x.getBrand(i));
                         a.add(x.getBrand(j));
                         a.add(x.getBrand(k));
                     }
                     else if (x.getBrand(i) != a.getBrand(a.getCount() - 3) &&
                              x.getBrand(j) != a.getBrand(a.getCount() - 2) &&
                              x.getBrand(k) != a.getBrand(a.getCount() - 1))
                     {
                         a.add(x.getBrand(i));
                         a.add(x.getBrand(j));
                         a.add(x.getBrand(k));
                     }
                 } // 碰的牌組
             }
         }
     }
 }
Esempio n. 13
0
 /// <summary>
 /// 取得準備要出手的牌
 /// </summary>
 /// <returns>牌</returns>
 public Brand getReadyBrand()
 {
     return(brandplayer.getBrand(0));
 }
Esempio n. 14
0
 /// <summary>
 /// 丟牌
 /// </summary>
 /// <returns></returns>
 public Brand getReadyBrand()
 {
     ans = player.getBrand(0);
     for (int i = 1; i < player.getCount(); i++)
     {
         if (player.getBrand(i).Source < ans.Source && player.getBrand(i).getClass() != Mahjong.Properties.Settings.Default.Flower)
         {
             ans = player.getBrand(i);
         }
     }
     //print();
     return(ans);
 }
Esempio n. 15
0
 void addscore_for_step7(BrandPlayer b)
 {
     BrandPlayer[] temp = new BrandPlayer[9];
     for (int j = 0; j < temp.Length; j++)
     {
         temp[j] = new BrandPlayer();
     }
     //將brands陣列每個數的值,丟到step7_characters分類
     for (int i = 0; i < b.getCount(); i++)
     {
         for (int j = 1; j <= temp.Length; j++)
         {
             if (b.getBrand(i).getNumber() == j)
             {
                 temp[j - 1].add(b.getBrand(i));
             }
         }
     }
     //聽二張為順牌+40,並減掉二張牌差異數(*5)
     for (int i = 1; i < temp.Length - 2; i++)
     {
         if (temp[i - 1].getCount() == 0)
         {
             if (temp[i].getCount() >= 1)
             {
                 if (temp[i + 1].getCount() >= 1)
                 {
                     if (temp[i + 2].getCount() == 0)
                     {
                         for (int j = 0; j < temp[i].getCount(); j++)
                         {
                             temp[i].getBrand(j).Source += 40;
                             temp[i].getBrand(j).Source -= 5;
                         }
                         for (int j = 0; j < temp[i + 1].getCount(); j++)
                         {
                             temp[i + 1].getBrand(j).Source += 40;
                             temp[i + 1].getBrand(j).Source -= 5;
                         }
                     }
                 }
             }
         }
     }
     //聽一張為順牌+20,並減掉二張牌差異數(*5)
     for (int i = 0; i < temp.Length - 2; i++)
     {
         if (temp[i].getCount() >= 1)
         {
             if (temp[i + 1].getCount() == 0)
             {
                 if (temp[i + 2].getCount() == 1)
                 {
                     for (int j = 0; j < temp[i].getCount(); j++)
                     {
                         temp[i].getBrand(j).Source += 20;
                         temp[i].getBrand(j).Source -= 10;
                     }
                     for (int j = 0; j < temp[i + 2].getCount(); j++)
                     {
                         temp[i + 2].getBrand(j).Source += 20;
                         temp[i + 2].getBrand(j).Source -= 10;
                     }
                 }
             }
         }
     }
     //聽一張為順牌的例外情況:(1、2)和(8、9)
     for (int i = 0; i < temp.Length - 1; i = i + 7)
     {
         if (i <= 1)
         {
             if (temp[i].getCount() >= 1)
             {
                 if (temp[i + 1].getCount() >= 1)
                 {
                     if (temp[i + 2].getCount() == 0)
                     {
                         for (int j = 0; j < temp[i].getCount(); j++)
                         {
                             temp[i].getBrand(j).Source += 20;
                             temp[i].getBrand(j).Source -= 5;
                         }
                         for (int j = 0; j < temp[i + 1].getCount(); j++)
                         {
                             temp[i + 1].getBrand(j).Source += 20;
                             temp[i + 1].getBrand(j).Source -= 5;
                         }
                     }
                 }
             }
         }
         if (i >= 1)
         {
             if (temp[i - 1].getCount() == 0)
             {
                 if (temp[i].getCount() >= 1)
                 {
                     if (temp[i + 1].getCount() >= 1)
                     {
                         for (int j = 0; j < temp[i].getCount(); j++)
                         {
                             temp[i].getBrand(j).Source += 20;
                             temp[i].getBrand(j).Source -= 5;
                         }
                         for (int j = 0; j < temp[i + 1].getCount(); j++)
                         {
                             temp[i + 1].getBrand(j).Source += 20;
                             temp[i + 1].getBrand(j).Source -= 5;
                         }
                     }
                 }
             }
         }
     }
 }