示例#1
0
        /// <summary>
        /// 氣泡排序
        /// </summary>
        /// <param name="player">玩家</param>
        /// <returns>玩家</returns>
        private BrandPlayer ButtleSort(BrandPlayer player)
        {
            Brand[] a = new Brand[player.getCount()];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = player.getBrand(i);
            }

            Brand temp_brand;

            for (int i = (player.getCount() - 1); i >= 0; i--)
            {
                for (int j = 1; j <= i; j++)
                {
                    Brand first  = a[j - 1];
                    Brand second = a[j];
                    if (first.getNumber() > second.getNumber())
                    {
                        temp_brand = a[j - 1];
                        a[j - 1]   = a[j];
                        a[j]       = temp_brand;
                    }
                }
            }
            player.clear();
            for (int i = 0; i < a.Length; i++)
            {
                player.add(a[i]);
            }
            return(player);
        }
示例#2
0
 /// <summary>
 /// �P�����A�ˬd �t�b
 /// </summary>
 /// <param name="player">�P���a</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();
 }
示例#3
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());
            // �L�X�~�n���P
            printplayer(table,"�üƵP");

            PlayerSort bbs = new PlayerSort(table);
            BrandPlayer sort_table = bbs.getPlayer;
            printplayer(sort_table,"�üƱƧǦ^�h");

            // ���t�P
            Deal deal = new Deal(16,table);
            deal.DealBrands();
            player = deal.Player;

            // �L�X���������a
            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,"���s�ˬd");
        }
示例#4
0
 /// <summary>
 /// 結果組合輸出
 /// </summary>
 private void compose()
 {
     //BrandPlayer b = new BrandPlayer();
     // 加入排序好的牌
     for (int i = 0; i < tempPlayers.Length; i++)
     {
         for (int j = 0; j < tempPlayers[i].getCount(); j++)
         {
             ans.add(tempPlayers[i].getBrand(j));
         }
     }
     // 移除有組別重複的牌
     for (int i = 0; i < teamBrands.getCount(); i++)
     {
         ans.remove(teamBrands.getBrand(i));
     }
     // 加入有組別的牌
     for (int i = 0; i < teamBrands.getCount(); i++)
     {
         ans.add(teamBrands.getBrand(i));
     }
     //for (int i = 0; i < b.getCount(); i++)
     //    ans.add(b.getBrand(i));
 }
示例#5
0
        void addimage_to_FlowLayout(FlowLayoutPanel flow,BrandPlayer player,EventHandler ev)
        {
            for (int i = 0; i < player.getCount(); i++)
            {
                Bitmap bitmap = new Bitmap(player.getBrand(i).image);
                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);
            }
        }
示例#6
0
        /// <summary>
        /// ��w�Ƨ�
        /// </summary>
        /// <param name="player">���a</param>
        /// <returns>���a</returns>
        private BrandPlayer ButtleSort(BrandPlayer player)
        {
            Brand[] a= new Brand[player.getCount()];
            for (int i = 0; i < a.Length; i++ )
                a[i] = player.getBrand(i);

            Brand temp_brand;
            for (int i = (player.getCount() - 1); i >= 0; i--)
            {
                for (int j = 1; j <= i; j++)
                {
                    Brand first = a[j - 1];
                    Brand second = a[j];
                    if (first.getNumber() > second.getNumber())
                    {
                        temp_brand = a[j - 1];
                        a[j - 1] = a[j];
                        a[j] = temp_brand;
                    }
                }
            }
            player.clear();
            for (int i = 0; i < a.Length; i++ )
                player.add(a[i]);
            return player;
        }
示例#7
0
 /// <summary>
 /// �]�w�s�ո��X
 /// </summary>
 /// <param name="player">���a</param>
 private void set_Team(BrandPlayer player, bool isCanSee)
 {
     teamCount[state]++;
     // ��P�q�{�b���a��W���X
     for (int i = 0; i < player.getCount(); i++)
         NowPlayer.remove(player.getBrand(i));
     // ��P�]���i���åB�[�W�էO���X��[�^�{�b���a
     for (int i = 0; i < player.getCount(); i++)
     {
         player.getBrand(i).IsCanSee = isCanSee;
         player.getBrand(i).Team = teamCount[state];
         NowPlayer.add(player.getBrand(i));
     }
 }
示例#8
0
文件: Tally.cs 项目: billteng/mahjong
        void samecolor(BrandPlayer q)
        {
            int num = 0;
            //bool index = false;
            for (int i = 0; i < q.getCount(); i++)
            {
                if (q.getBrand(i).getClass() == "�r")
                    num++;
            }
            if (num == q.getCount())
            {
                textBox1.Text += "�r�@��\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() != "�r")
                    num++;
            if (num == q.getCount() - 1)
            {
                textBox1.Text += "�M�@��\r\n";
                tally += 8;
            }
            num = 0;

              for (int i = 0; i < q.getCount(); i++)
              {
                  if (q.getBrand(i).getClass() == "�r")
                  {
                      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() != "�r")
                          num++;
                  }
                      if (num == q.getCount() - 1)
                      {
                          textBox1.Text += "�V�@��\r\n";
                          tally += 4;
                      }
                          num = 0;
              }
              index = false;
        }
示例#9
0
        void addscore_���l(BrandPlayer brandclass, int score)
        {
            BrandPlayer[] temp = new BrandPlayer[9];
            for (int j = 0; j < temp.Length; j++)
                temp[j] = new BrandPlayer();
            //�Nbrands�}�C�C�Ӽƪ��ȡA���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 - 2; i++)
            {
                if (temp[i].getCount() >= 1)
                    if (temp[i + 1].getCount() >= 1)
                        if (temp[i + 2].getCount() >= 1)
                        {
                            for (int j = 0; j < temp[i].getCount(); j++)
                            {
                                temp[i].getBrand(j).Source += score;
                            }
                            for (int j = 0; j < temp[i + 1].getCount(); j++)
                            {
                                temp[i + 1].getBrand(j).Source += score;
                            }
                            for (int j = 0; j < temp[i + 2].getCount(); j++)
                            {
                                temp[i + 2].getBrand(j).Source += score;
                            }
                        }
            }
        }
示例#10
0
 void addscore_for_step7(BrandPlayer b)
 {
     BrandPlayer[] temp = new BrandPlayer[9];
     for (int j = 0; j < temp.Length; j++)
         temp[j] = new BrandPlayer();
     //�Nbrands�}�C�C�Ӽƪ��ȡA���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));
         }
     }
     //ť�G�i�����P+40�A�ô�G�i�P�t����(*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;
                         }
                     }
     }
     //ť�@�i�����P+20�A�ô�G�i�P�t����(*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;
                     }
                 }
     }
     //ť�@�i�����P���ҥ~���p�G(1�B2)�M(8�B9)
     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;
                         }
                     }
         }
     }
 }
示例#11
0
文件: Deal.cs 项目: billteng/mahjong
 /// <summary>
 /// ���t�P
 /// </summary>
 public void DealBrands()
 {
     BrandPlayer temp = new BrandPlayer();
     // Ū�X�ƶq���P�A�ò���
     for (int i = 0; i < countplayer * countbrands; i++)
     {
         Brand brand = table.getBrand(i);
         temp.add(brand);
         table.remove(brand);
     }
     // ��P�[�J���a
     for (int i = 0; i < temp.getCount(); i++)
         player[i % countplayer].add(temp.getBrand(i));
 }