예제 #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();
        }
예제 #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
 void printplayer(BrandPlayer[] player)
 {
     for (int i = 0; i < player.Length; i++)
     {
         int y = i + 1;
         printplayer(player[i], y.ToString());
     }
 }
예제 #4
0
 private void add_to_player_iterator(Iterator iterator,BrandPlayer player)
 {
     while (iterator.hasNext())
     {
         Brand brand = (Brand)iterator.next();
         player.add(brand);
     }
 }
예제 #5
0
파일: AiTest.cs 프로젝트: billteng/mahjong
 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);
     }
 }
예제 #6
0
파일: Deal.cs 프로젝트: billteng/mahjong
 /// <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();
 }
예제 #7
0
파일: AiTest.cs 프로젝트: billteng/mahjong
        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());
        }
예제 #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);
            }
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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));
             }
         }
     }
 }
예제 #14
0
파일: Level 1.cs 프로젝트: billteng/mahjong
        //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();
        }
예제 #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");
        }
예제 #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));
     }
 }
예제 #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();
 }
예제 #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);
 }
예제 #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;
        }
예제 #20
0
 void printplayer(BrandPlayer player,string val)
 {
     Console.WriteLine("\n=== Player {0}===",val);
         Iterator temp = player.creatIterator();
         print(temp);
 }
예제 #21
0
파일: Tally.cs 프로젝트: billteng/mahjong
 public void setPlayer(BrandPlayer player)
 {
     x = player;
 }
예제 #22
0
파일: Table.cs 프로젝트: Superbil/mahjong
 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();
 }
예제 #23
0
 public void setPlayer(Brand brand, BrandPlayer player)
 {
     this.brandplayer = player;
 }
예제 #24
0
 public SimpleAI(BrandPlayer player)
 {
     this.brandplayer = player;
 }
예제 #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;
        }
예제 #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;
 }
예제 #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;
 }
예제 #28
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;
        }
예제 #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;
 }
예제 #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));
     }
 }
예제 #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);
 }
예제 #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;
        }
예제 #33
0
 public ChowBrandCheck(BrandPlayer[] player)
 {
     InitializeComponent();
     this.player = player;
 }