Ejemplo n.º 1
0
        public BrandsTest()
        {
            BrandPlayer a = new BrandPlayer();

            BrandFactory x = new BrandFactory();
            x.createBrands();
            x.randomBrands();

            //x.PrintRadomTable(); //�C�X�üƪ�
            a = x.getBrands();

            Iterator ai;
            ai = a.creatIterator(10);
            print(ai);

            ai = a.creatIterator(3);
            a=removefromplayer(ai,a);

            ai = a.creatIterator(10);
            print(ai);

            //Console.WriteLine();
            //Console.Write("{0},{1}\n", sa.getReadyBrand().getClass(),sa.getReadyBrand().getNumber());

            //chackBrands();
            //chackArrayList();

            x.creatImageArray();
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
0
 void printplayer(BrandPlayer[] player)
 {
     for (int i = 0; i < player.Length; i++)
     {
         int y = i + 1;
         printplayer(player[i], y.ToString());
     }
 }
Ejemplo n.º 4
0
 private void add_to_player_iterator(Iterator iterator,BrandPlayer player)
 {
     while (iterator.hasNext())
     {
         Brand brand = (Brand)iterator.next();
         player.add(brand);
     }
 }
Ejemplo n.º 5
0
 void printplayer(BrandPlayer[] player)
 {
     for (int i = 0; i < player.Length; i++)
     {
         Console.WriteLine("\n===Player {0}===", i+1);
         Iterator temp = player[i].creatIterator();
         print(temp);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// �غc�򥻪��a�ƶq�M���t��
 /// </summary>
 /// <param name="countbrands">�C�@�Ӫ��a���t��</param>
 /// <param name="table">�ୱ���a</param>
 public Deal(int countbrands, BrandPlayer table)
 {
     this.countbrands = countbrands;
     this.countplayer = 4;
     this.player = new BrandPlayer[countplayer];
     this.table = table;
     for (int i = 0; i < countplayer; i++)
         this.player[i] = new BrandPlayer();
 }
Ejemplo n.º 7
0
        public AiTest()
        {
            BrandPlayer[] player = new BrandPlayer[4];
            BrandPlayer table = new BrandPlayer();

            BrandFactory x = new BrandFactory();
            x.createBrands();
            x.randomBrands();

            table = x.getBrands();

            Deal deal = new Deal(16,table);
            deal.DealBrands();

            player = deal.Player;

            printplayer(player);

            //SimpleAI sa = new SimpleAI();
            //sa.setPlayer(player[0]);
            //PlayerSort bs = new PlayerSort(player[0]);
            //player[0] = bs.getPlayer();

            //PlayerSort bs = new PlayerSort(player[0]);

            PlayerSort bs = new PlayerSort(player[0],new FlowerBrand(0),new TenThousandBrand(0),new RopeBrand(0),new  TubeBrand(0),new WordBrand(0));
            player[0] = bs.getPlayer;
            Level_1 l = new Level_1();
            l.setPlayer(player[0]);
            l.getReadyBrand();

            //printplayer(player);
            //Level_1 l = new Level_1();
            //BrandPlayer test = new BrandPlayer();
            //test.add(new WordBrand(1));
            //test.add(new WordBrand(1));
            //test.add(new WordBrand(1));
            //test.add(new WordBrand(2));
            //test.add(new WordBrand(3));
            //test.add(new WordBrand(3));
            //test.add(new WordBrand(3));
            //test.add(new WordBrand(5));
            //l.setPlayer(test);

            l.setPlayer(player[0]);

            Brand t = l.getReadyBrand();
            Console.WriteLine("==>{0}{1}", t.getNumber(), t.getClass());
            //printplayer(player);

            //sa.getReadyBrand();
            //Console.WriteLine();
            //Console.WriteLine("Ready Brand is {0},{1}", l.getReadyBrand().getClass(), l.getReadyBrand().getNumber());
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// �ƧǵP���غc�l
        /// </summary>
        /// <param name="player">���a</param>
        /// <param name="b1">�P���O1</param>
        /// <param name="b2">�P���O2</param>
        /// <param name="b3">�P���O3</param>
        /// <param name="b4">�P���O4</param>
        /// <param name="b5">�P���O5</param>
        public PlayerSort(BrandPlayer player,Brand b1,Brand b2,Brand b3,Brand b4,Brand b5)
        {
            this.inputPlayer = player;
            for (int i = 0; i < tempPlayers.Length; i++)
                tempPlayers[i] = new BrandPlayer();
            teamBrands = new BrandPlayer();
            BrandClass[0] = b1;
            BrandClass[1] = b2;
            BrandClass[2] = b3;
            BrandClass[3] = b4;
            BrandClass[4] = b5;

            getBrands(inputPlayer.creatIterator());
            sortPlayer();
            sortTeam();
            compose();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// �ƧǵP���غc�l
        /// </summary>
        /// <param name="player">���a</param>
        public PlayerSort(BrandPlayer player)
        {
            this.inputPlayer = player;
            for (int i = 0; i < tempPlayers.Length; i++)
                tempPlayers[i] = new BrandPlayer();
            teamBrands = new BrandPlayer();
            BrandClass[0] = new FlowerBrand(0);
            BrandClass[1] = new TenThousandBrand(0);
            BrandClass[2] = new RopeBrand(0);
            BrandClass[3] = new TubeBrand(0);
            BrandClass[4] = new WordBrand(0);

            getBrands( inputPlayer.creatIterator() );
            sortPlayer();
            sortTeam();
            compose();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 排序牌的建構子
        /// </summary>
        /// <param name="player">玩家</param>
        /// <param name="b1">牌類別1</param>
        /// <param name="b2">牌類別2</param>
        /// <param name="b3">牌類別3</param>
        /// <param name="b4">牌類別4</param>
        /// <param name="b5">牌類別5</param>
        public PlayerSort(BrandPlayer player, Brand b1, Brand b2, Brand b3, Brand b4, Brand b5)
        {
            this.inputPlayer = player;
            for (int i = 0; i < tempPlayers.Length; i++)
            {
                tempPlayers[i] = new BrandPlayer();
            }
            teamBrands    = new BrandPlayer();
            BrandClass[0] = b1;
            BrandClass[1] = b2;
            BrandClass[2] = b3;
            BrandClass[3] = b4;
            BrandClass[4] = b5;

            getBrands(inputPlayer.creatIterator());
            sortPlayer();
            sortTeam();
            compose();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 排序牌的建構子
        /// </summary>
        /// <param name="player">玩家</param>
        public PlayerSort(BrandPlayer player)
        {
            this.inputPlayer = player;
            for (int i = 0; i < tempPlayers.Length; i++)
            {
                tempPlayers[i] = new BrandPlayer();
            }
            teamBrands    = new BrandPlayer();
            BrandClass[0] = new FlowerBrand(0);
            BrandClass[1] = new TenThousandBrand(0);
            BrandClass[2] = new RopeBrand(0);
            BrandClass[3] = new TubeBrand(0);
            BrandClass[4] = new WordBrand(0);

            getBrands(inputPlayer.creatIterator());
            sortPlayer();
            sortTeam();
            compose();
        }
Ejemplo n.º 13
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.º 14
0
        //bool firsttime = true;
        /// <summary>
        /// �]�w�P��
        /// </summary>
        /// <param name="player"></param>
        public void setPlayer(BrandPlayer player)
        {
            PlayerSort ps = new PlayerSort(player,
                new FlowerBrand(0),
                new TenThousandBrand(0),
                new TubeBrand(0),
                new RopeBrand(0),
                new WordBrand(0));
            this.player = ps.getPlayer;

            for (int j = 0; j < brands.Length; j++)
                brands[j] = new BrandPlayer();

            step0();
            step1();
            step2();
            step3();
            step4();
            step5();
            step6();
            step7();
        }
Ejemplo n.º 15
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.º 16
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));
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// �U�@��
 /// </summary>
 /// <param name="flow">�O�_�y��</param>
 public void nextWiner(bool flow)
 {
     // �p�G�y���β��aĹ
     if (flow || this.lo.Winer == this.State)
     {
         this.win_Times++;
     }
     else
     {
         this.lo.next();
         this.win_Times = 1;
     }
     //�]�w�s���}�P��m
     this.lo.setPosition();
     //�s���ୱ
     this.table = new BrandPlayer();
     //��s���a
     this.state = (uint)lo.Winer;
     //�]�w�P��
     for (int i = 0; i < countplayers; i++)
         teamCount[i] = 1;
     //���P����
     this.brand_count = 0;
     //�M�����X�h���P
     Show_Table.clear();
 }
Ejemplo n.º 18
0
 /// <summary>
 /// �b
 /// </summary>
 /// <param name="brand">�n�b���P</param>
 /// <param name="player">�i�H�b���P��</param>
 public void kong(Brand brand, BrandPlayer player)
 {
     Show_Table.remove(brand);
     set_Team(player, true);
 }
Ejemplo n.º 19
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.º 20
0
 void printplayer(BrandPlayer player,string val)
 {
     Console.WriteLine("\n=== Player {0}===",val);
         Iterator temp = player.creatIterator();
         print(temp);
 }
Ejemplo n.º 21
0
 public void setPlayer(BrandPlayer player)
 {
     x = player;
 }
Ejemplo n.º 22
0
 private void addimage_player(BrandPlayer player, location state, RotateFlipType rotate)
 {
     Iterator temp = player.creatIterator();
     addimage_iterator(temp, state, rotate);
     if (InvokeRequired)
         Invoke(new Update_delegate(Update));
     else
         Update();
 }
Ejemplo n.º 23
0
 public void setPlayer(Brand brand, BrandPlayer player)
 {
     this.brandplayer = player;
 }
Ejemplo n.º 24
0
 public SimpleAI(BrandPlayer player)
 {
     this.brandplayer = player;
 }
Ejemplo n.º 25
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.º 26
0
 public BrandFactory()
 {
     this.player = new BrandPlayer();
     countFlowerBrand = 8;
     pieceFlowerBrand = 1;
     countRopeBrand = 9;
     pieceRopeBrand = 4;
     countTubeBrand = 9;
     pieceTubeBrand = 4;
     countTenThousandBrand = 9;
     pieceTenThousandBrand = 4;
     countWordBrand = 7;
     pieceWordBrand = 4;
     creatImageArray();
     sumBrands = countFlowerBrand * pieceFlowerBrand +
                 countRopeBrand * pieceRopeBrand +
                 countTenThousandBrand * pieceTenThousandBrand +
                 countTubeBrand * pieceTubeBrand +
                 countWordBrand * pieceWordBrand;
 }
Ejemplo n.º 27
0
 BrandPlayer removefromplayer(Iterator iterator,BrandPlayer re)
 {
     while(iterator.hasNext())
     {
         Brand brand = (Brand)iterator.next();
         //re.remove(brand);
         Console.WriteLine(">>{0}",re.remove(brand));
     }
     return re;
 }
Ejemplo n.º 28
0
        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;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// �������a���X
 /// </summary>
 /// <param name="playernumber">�]�w���h�֭Ӫ��a</param>
 /// <param name="deal">�@�Ӫ��a���h�ֱi</param>
 public AllPlayers(int playernumber, int deal)
 {
     this.players = new BrandPlayer[playernumber];
     this.isPlayer = new bool[playernumber];
     this.lo = new Location();
     this.table = new BrandPlayer();
     this.show_table = new BrandPlayer();
     this.dealnumber = deal;
     this.countplayers = playernumber;
     this.state = (uint)lo.Winer;
     this.brand_count = 0;
     this.basic_tai = Mahjong.Properties.Settings.Default.BasicTai;
     this.one_tai = Mahjong.Properties.Settings.Default.One_Tai;
     this.teamCount = new int[playernumber];
     this.names = new string[playernumber];
     this.showMessageBox = true;
     this.place = new Place();
     for (int i = 0; i < playernumber; i++)
         teamCount[i] = 1;
     money = new int[playernumber];
     setBasicMoney(Mahjong.Properties.Settings.Default.Money);
     win_Times = 1;
     names[0] = Mahjong.Properties.Settings.Default.Player_North;
     names[1] = Mahjong.Properties.Settings.Default.Player_East;
     names[2] = Mahjong.Properties.Settings.Default.Player_South;
     names[3] = Mahjong.Properties.Settings.Default.Player_West;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// �ƧǵP��
 /// </summary>
 private void sortTeam()
 {
     if (teamBrands.getCount() > 1)
     {
         // �]�w�̤j��team���X
         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;
         // �]�w�s���}�C�H�̤j��team���X
         BrandPlayer[] b = new BrandPlayer[team_count];
         for (int i = 0; i < b.Length; i++)
             b[i] = new BrandPlayer();
         // ��P�̷�team���X��J
         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]);
         // �M���ª��A�[�J�s��
         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.º 31
0
 /// <summary>
 /// �t�b
 /// </summary>
 /// <param name="brand">�n�b���P</param>
 /// <param name="player">�i�H�b���P��</param>
 public void DarkKong(Brand brand, BrandPlayer player)
 {
     set_Team(player, false);
 }
Ejemplo n.º 32
0
        /// <summary>
        /// �J�P ����
        /// </summary>
        /// <returns>�O/�_</returns>
        public bool Win()
        {
            if (brand != null)
            {
                x.add(brand);
                PlayerSort d = new PlayerSort(x);
                x = d.getPlayer;
            }
            brand_2();
            bradn_4();
            bradn_3();

            // �զX����
            // a �T��
            // b �Ⱖ
            // c �զX
            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;
                                    //�P�����
                                    //�������ߥN��J�P
                                    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;
        }
Ejemplo n.º 33
0
 public ChowBrandCheck(BrandPlayer[] player)
 {
     InitializeComponent();
     this.player = player;
 }