Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 private void add_to_player_iterator(Iterator iterator,BrandPlayer player)
 {
     while (iterator.hasNext())
     {
         Brand brand = (Brand)iterator.next();
         player.add(brand);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 排序牌組
 /// </summary>
 private void sortTeam()
 {
     if (teamBrands.getCount() > 1)
     {
         // 設定最大的team號碼
         int team_count = 0;
         for (int i = 0; i < teamBrands.getCount(); i++)
         {
             if (teamBrands.getBrand(i).Team > team_count)
             {
                 team_count = teamBrands.getBrand(i).Team;
             }
         }
         // 設定新的陣列以最大的team號碼
         BrandPlayer[] b = new BrandPlayer[team_count];
         for (int i = 0; i < b.Length; i++)
         {
             b[i] = new BrandPlayer();
         }
         // 把牌依照team號碼放入
         for (int i = 0; i < teamBrands.getCount(); i++)
         {
             b[teamBrands.getBrand(i).Team - 1].add(teamBrands.getBrand(i));
         }
         // 排序
         for (int i = 0; i < b.Length; i++)
         {
             b[i] = ButtleSort(b[i]);
         }
         // 清除舊的,加入新的
         teamBrands.clear();
         for (int i = 0; i < b.Length; i++)
         {
             for (int j = 0; j < b[i].getCount(); j++)
             {
                 teamBrands.add(b[i].getBrand(j));
             }
         }
     }
 }
Ejemplo n.º 4
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");
        }
Ejemplo n.º 5
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));
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// �Q�ζüƧ�P����
        /// </summary>
        public void randomBrands()
        {
            creatRandomTable();

            BrandPlayer tempplayer = new BrandPlayer();
            //�̷Ӷüƪ��v�@��P��J���a��
            for (int i = 0; i < this.player.getCount(); i++)
                tempplayer.add( this.player.getBrand( (int)randomTable[i] ) );
            this.player = tempplayer;
        }
Ejemplo n.º 8
0
        public CheckTest()
        {
            BrandPlayer a = new BrandPlayer();
            //a.add(new TenThousandBrand(5));
            //a.add(new TenThousandBrand(6));
            //a.add(new TenThousandBrand(7));
            //a.add(new TenThousandBrand(6));
            //a.add(new TenThousandBrand(7));
            //a.add(new TenThousandBrand(8));

            //a.add(new RopeBrand(4));
            //a.add(new RopeBrand(5));
            //a.add(new RopeBrand(6));

            a.add(new TubeBrand(2));
            a.add(new TubeBrand(2));
            a.add(new TubeBrand(2));
            //a.add(new TubeBrand(2));
            //a.add(new TubeBrand(5));
            //a.add(new TubeBrand(8));
            //a.add(new TubeBrand(8));

            //FlowerBrand f = new FlowerBrand(1);
            //f.Team = 1;
            //a.add(f);

            //WordBrand r = new WordBrand(9);
            ////r.Team = 2;
            //a.add(r);
            //a.add(r);
            //a.add(r);
            ////a.add(r);

            //TubeBrand t = new TubeBrand(9);
            //t.Team = 3;
            //a.add(t);
            //a.add(t);
            //a.add(t);

            //a.add(new TubeBrand(2));
            //a.add(new TubeBrand(2));
            //a.add(new TubeBrand(3));
            //a.add(new TubeBrand(3));
            //a.add(new TubeBrand(3));
            //a.add(new TubeBrand(3));
            //a.add(new TubeBrand(9));
            //a.add(new TubeBrand(9));
            //WordBrand w = new WordBrand(6);
            //w.Team = 2;
            //a.add(w);
            //a.add(w);
            //a.add(w);
            //a.add(w);

            //Brand b = new TubeBrand(2);
            //CheckUser c = new Check(b,a);
            printplayer(a);
            CheckBrands c = new CheckBrands(new TubeBrand(2), a);
            a.add(new TubeBrand(2));
            CheckBrands d = new CheckBrands(a);
            //if (c.Win())
            //{
            //    Console.WriteLine("有胡!!");
            //    printplayer(c.SuccessPlayer);
            //}
            if (c.Chow())
            {
                Console.WriteLine("===========");
                Console.WriteLine("\n有吃");
                Console.WriteLine(c.ChowLength);
                printplayer(c.SuccessPlayer);
                printplayer(c.ChowPlayer[0]);
                printplayer(c.ChowPlayer[1]);
                printplayer(c.ChowPlayer[2]);
                Console.WriteLine("===========");
            }
            if (c.Pong())
            {
                Console.WriteLine("\n有碰");
                printplayer(c.SuccessPlayer);
            }
            if (c.Kong())
            {
                Console.WriteLine("\n有槓");
                printplayer(c.SuccessPlayer);
            }
            if (d.DarkKong())
            {
                Console.WriteLine("\n有暗槓");
                printplayer(c.SuccessPlayer);
            }

            if (//!c.Win() &&
                !c.Chow() && !c.Pong() && !c.Kong() && !c.DarkKong())
                Console.WriteLine("\n都沒");
            printplayer(a);
        }
Ejemplo n.º 9
0
 /// <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));
 }
Ejemplo n.º 10
0
        public TallyTest()
        {
            BrandPlayer a = new BrandPlayer();
            a.add(new TubeBrand(1));
            a.add(new TubeBrand(1));
            a.add(new TubeBrand(1));
            a.add(new TubeBrand(1));

            a.add(new RopeBrand(1));
            a.add(new RopeBrand(1));
            a.add(new RopeBrand(1));
            a.add(new RopeBrand(1));

            a.add(new TenThousandBrand(1));
            a.add(new TenThousandBrand(1));
            a.add(new TenThousandBrand(1));
            a.add(new TenThousandBrand(1));

            a.add(new TubeBrand(9));
            a.add(new TubeBrand(9));
            a.add(new TubeBrand(9));
            a.add(new TubeBrand(9));

            a.add(new RopeBrand(9));
            a.add(new RopeBrand(9));
            a.add(new RopeBrand(9));
            a.add(new RopeBrand(9));

            //a.add(new WordBrand(4));
            a.add(new WordBrand(4));
            a.add(new WordBrand(4));

            ////a.add(new WordBrand(1));
            //a.add(new WordBrand(1));
            //a.add(new WordBrand(1));
            //a.add(new WordBrand(1));

            ////a.add(new WordBrand(2));
            //a.add(new WordBrand(2));
            //a.add(new WordBrand(2));
            //a.add(new WordBrand(2));

            ////a.add(new WordBrand(3));
            //a.add(new WordBrand(3));
            //a.add(new WordBrand(3));
            //a.add(new WordBrand(3));

            f = new Tally();

            Location l = new Location();
            AllPlayers all = new AllPlayers(4, 16);
            WordBrand w = new WordBrand(9);
            WordBrand v = new WordBrand(9);
            w.WhoPush = location.East;
            //v.WhoPush = location.Table;
            all.Show_Table.add(w);
            //all.NowPlayer.add(v);

            f.setPlayer(all);
            f.setPlayer(a);
            //l.next_Winer();
            f.setLocation(l,0);

            f.ShowDialog();
        }