示例#1
0
 public bool IsContain(List <ClsCard> arr, ClsCard t)
 {
     foreach (ClsCard c in arr)
     {
         if (t.Value == c.Value && t.Character == c.Character)
         {
             return(true);
         }
     }
     return(false);
 }
示例#2
0
 public bool IsContain(List <ClsCard> arr, ClsCard t)//kiểm tra sự tồn tại của 1 quân bài
 {
     foreach (ClsCard c in arr)
     {
         if (t.Value == c.Value && t.Character == c.Character)
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
        private void btnPlay_Click_1(object sender, EventArgs e)
        {
            List <int> IndexOfSel = new List <int>();

            for (int i = 0; i < ctrl.Count; i++)
            {
                if (hand.arrCard[i].Played == false && ctrl[i].Location.Y != 581)
                {
                    PictureBox temp_pic = ctrl[i] as PictureBox;

                    string nameImage = filename[i];

                    string[] temp = nameImage.Split('_');
                    ClsCard  c    = new ClsCard();
                    c.Value     = Convert.ToInt32(temp[0]);
                    c.Character = Convert.ToInt32(temp[1]);
                    hand.arrSelCards.Add(c);
                    IndexOfSel.Add(i);
                }
            }
            bool check = rule.IsValid(hand.arrSelCards);

            if (check == true)
            {
                byte[] buf = new byte[1024];
                buf = Serialize(hand.arrSelCards);
                WaitingRoom.sk_card.Send(buf);
                ListenToSignalDel();
                if (signal == "OK")
                {
                    foreach (int item in IndexOfSel)
                    {
                        PictureBox temp_pic = ctrl[item] as PictureBox;
                        temp_pic.Visible = false;
                        int x = ctrl[item].Location.X;
                        int y = ctrl[item].Location.Y;
                        ctrl[item].Location       = new System.Drawing.Point(x, y + 26);
                        hand.arrCard[item].Played = true;
                    }
                    hand.numOfSelectedCards = hand.arrSelCards.Count;
                    hand.numOfRemainCards  -= hand.numOfSelectedCards;
                    ShowCards(hand);
                    //gửi socket xong -> xóa arrsel

                    hand.arrSelCards.RemoveRange(0, hand.arrSelCards.Count);
                    hand.Activated    = false;
                    btnPlay.Enabled   = false;
                    btnIgnore.Enabled = false;
                }
                else
                {
                    foreach (PictureBox item in ctrl)
                    {
                        if (item.Location.Y != 581)
                        {
                            int x = item.Location.X;
                            int y = item.Location.Y;
                            item.Location = new System.Drawing.Point(x, y + 26);
                            hand.arrSelCards.RemoveRange(0, hand.arrSelCards.Count);
                        }
                    }
                    ShowCards(hand);
                }
            }
            else
            {
                foreach (PictureBox item in ctrl)
                {
                    if (item.Location.Y != 581)
                    {
                        int x = item.Location.X;
                        int y = item.Location.Y;
                        item.Location = new System.Drawing.Point(x, y + 26);
                        hand.arrSelCards.RemoveRange(0, hand.arrSelCards.Count);
                    }
                }
                ShowCards(hand);
            }
        }