public void Createcards() { Card[] cards = myICommon.GetCards(clientid); int spa = 0, dia = 0, hea = 0; List <Card> spad = new List <Card>(); List <Card> hear = new List <Card>(); List <Card> diam = new List <Card>(); List <Card> clu = new List <Card>(); Card[] cards1 = new Card[13]; for (int i = 0; i < 13; i++) { if (cards[i].GetShape() == "spades") { spad.Add(cards[i]); spa++; } if (cards[i].GetShape() == "hearts") { hear.Add(cards[i]); hea++; } if (cards[i].GetShape() == "diamonds") { diam.Add(cards[i]); dia++; } if (cards[i].GetShape() == "clubs") { clu.Add(cards[i]); } } for (int i = 0; i < spa; i++) { for (int j = i + 1; j < spa; j++) { if (spad[i].GetNum() < spad[j].GetNum()) { Card card = new Card(spad[j]); spad[j] = new Card(spad[i]); spad[i] = card; } } cards1[i] = spad[i]; } for (int i = 0; i < hea; i++) { for (int j = i + 1; j < hea; j++) { if (hear[i].GetNum() < hear[j].GetNum()) { Card card = new Card(hear[j]); hear[j] = new Card(hear[i]); hear[i] = card; } } cards1[i + spa] = hear[i]; } for (int i = 0; i < dia; i++) { for (int j = i + 1; j < dia; j++) { if (diam[i].GetNum() < diam[j].GetNum()) { Card card = new Card(diam[j]); diam[j] = new Card(diam[i]); diam[i] = card; } } cards1[i + 13 - dia] = diam[i]; } for (int i = 0; i < 13 - spa - hea - dia; i++) { for (int j = i + 1; j < 13 - spa - hea - dia; j++) { if (clu[i].GetNum() < clu[j].GetNum()) { Card card = new Card(clu[j]); clu[j] = new Card(clu[i]); clu[i] = card; } } cards1[i + spa + hea] = clu[i]; } for (int i = 0; i < 13; i++) { Card card = cards1[i]; Label label = new Label(); string str = card.GetNum().ToString() + card.GetShape().ToUpper()[0]; Image img = Image.FromFile("..\\..\\..\\PNG\\" + str + ".png"); img = Resize(img, 54, 83); label.Image = img; label.Location = new Point(335 + i * 56, 550); label.Size = img.Size; label.Tag = card; this.cards.Add(label); Controls.Add(label); Label label1 = new Label(); Image img1 = Image.FromFile("..\\..\\..\\PNG\\gray_back.png"); img1 = Resize(img1, 83, 54); label1.Image = img1; label1.Size = img1.Size; label1.Location = new Point(1100, 150 + i * 30); Controls.Add(label1); othercards1.Add(label1); Label label2 = new Label(); Image img2 = Image.FromFile("..\\..\\..\\PNG\\green_back.png"); img2 = Resize(img2, 83, 54); label2.Image = img2; label2.Size = img2.Size; label2.Location = new Point(190, 150 + i * 30); Controls.Add(label2); othercards2.Add(label2); Label label3 = new Label(); Image img3 = Image.FromFile("..\\..\\..\\PNG\\blue_back.png"); img3 = Resize(img3, 54, 83); label3.Image = img3; label3.Size = img3.Size; label3.Location = new Point(480 + i * 30, 60); Controls.Add(label3); othercards3.Add(label3); } }
public void ShowNames() {//לאחר שכל השחקנים התחברו, הפעולה מראה את השם של כל שחקן על המסך ואת מספר הסיבובים שבהן ניצח for (int i = 0; i < 4; i++) { names[i] = new Label(); names[i].Text = pnames[i]; take[i] = new Label(); take[i].Text = 0.ToString(); } names[clientid].Location = new Point(660, 640); take[clientid].Location = new Point(550, 640); if (clientid != 3) { names[clientid + 1].Location = new Point(1200, 350); take[clientid + 1].Location = new Point(1200, 450); } else { names[0].Location = new Point(1200, 350); take[0].Location = new Point(1200, 450); } if (clientid == 0 || clientid == 1) { names[clientid + 2].Location = new Point(660, 10); take[clientid + 2].Location = new Point(550, 10); } else { if (clientid == 2) { names[0].Location = new Point(660, 10); take[0].Location = new Point(550, 10); } else { names[1].Location = new Point(660, 10); take[1].Location = new Point(550, 10); } } if (clientid == 0) { names[3].Location = new Point(80, 350); take[3].Location = new Point(80, 450); } else { if (clientid == 1) { names[0].Location = new Point(80, 350); take[0].Location = new Point(80, 450); } else { if (clientid == 2) { names[1].Location = new Point(80, 350); take[1].Location = new Point(80, 450); } else { names[2].Location = new Point(80, 350); take[2].Location = new Point(80, 450); } } } for (int i = 0; i < 4; i++) { Controls.Add(take[i]); Controls.Add(names[i]); } }
/* public void Declare(object sender, EventArgs args) * { * * for (int i = 0; i < 9; i++) * { * cnum[i] = new Button(); * cnum[i].Text = (i + 5).ToString(); * cnum[i].Location = new Point(518 + 100 * i, 700); * string str = (i + 5).ToString(); * cnum[i].Tag = i + 5; * cnum[i].Size = new Size(50, 50); * cnum[i].Click += SetBetNumber; * Controls.Add(cnum[i]); * } * * } * /*public void SetBetNumber(object sender, EventArgs args) * { * * if (myICommon.IsCurrneTurn(clientid)) * { * Button btn = (Button)sender; * betnum[clientid] = (int)btn.Tag; * CardShape(); * * } * * }*/ public void turn2() {//הפעולה for (int i = 0; i < 4; i++) { if (thisroundlabels[i] != null && thisroundlabels[i].Location.X != 0 && !Controls.Contains(thisroundlabels[i])) { Controls.Add(thisroundlabels[i]); } } if (myICommon.IsCurrneTurn(clientid)) { for (int i = 0; i < cards.Count; i++) { if (cards[i] != null) { cards[i].Click += CardClick; } } } }
public void Timer1(object sender, EventArgs args) {//(...המשתמש מגיע לפעולה הזאת כל 50 מילישניות על מנת להתעדכן במצב המשחק (אם מתחיל המשחק, אם נגמר הסיבוב if (myICommon.GetNextGame(clientid)) { myICommon.SetNextGameFalse(clientid); Button send = new Button(); Controls.Clear(); StartGame(send, args); } thisroundcards = myICommon.ThisRoundCards(); if (myICommon.GetRemoveCards(clientid)) { for (int i = 0; i < 4; i++) { if (thisroundlabels[i] != null) { Controls.Remove(thisroundlabels[i]); thisroundlabels[i] = null; thisroundcards[i] = null; } } myICommon.SetRemoveCardsFalse(clientid); if (Controls.Contains(nextround)) { Controls.Remove(nextround); } Controls.Remove(winner); } int counter = 0; pnames = myICommon.GetNames(); for (int i = 0; i < 4; i++) { if (pnames[i] != null) { counter++; } } if (counter == 4) { if (!Controls.Contains(names[3]))//names[3]==null) { ShowNames(); } { turn2(); int thisroundplays = 0; int lastcheckedplays = 0; for (int i = 0; i < 4; i++) { if (thisroundcards[i] != null) { thisroundplays++; } if (thisroundlabels[i] != null) { lastcheckedplays++; } } if (thisroundplays > lastcheckedplays) { for (int i = 0; i < 4; i++) { if (thisroundcards[i] != null && thisroundlabels[i] == null) { thisroundlabels[i] = new Label(); if (thisroundlabels[i].Image == null) { Image img = Image.FromFile("..\\..\\..\\PNG\\" + thisroundcards[i].GetNum().ToString() + thisroundcards[i].GetShape().ToUpper()[0] + ".png"); img = Resize(img, 54, 83); thisroundlabels[i].Size = img.Size; thisroundlabels[i].Image = img; thisroundlabels[i].Tag = thisroundcards[i]; } } } if (clientid == 0) { if (thisroundcards[1] != null) { thisroundlabels[1].Location = new Point(900, 320); } if (thisroundcards[2] != null) { thisroundlabels[2].Location = new Point(670, 175); } if (thisroundcards[3] != null) { thisroundlabels[3].Location = new Point(450, 320); } } else { if (clientid == 1) { if (thisroundcards[0] != null) { thisroundlabels[0].Location = new Point(450, 320); } if (thisroundcards[2] != null) { thisroundlabels[2].Location = new Point(900, 320); } if (thisroundcards[3] != null) { thisroundlabels[3].Location = new Point(670, 175); } } else { if (clientid == 2) { if (thisroundcards[0] != null) { thisroundlabels[0].Location = new Point(670, 175); } if (thisroundcards[1] != null) { thisroundlabels[1].Location = new Point(450, 320); } if (thisroundcards[3] != null) { thisroundlabels[3].Location = new Point(900, 320); } } else { if (thisroundcards[0] != null) { thisroundlabels[0].Location = new Point(900, 320); } if (thisroundcards[1] != null) { thisroundlabels[1].Location = new Point(670, 175); } if (thisroundcards[2] != null) { thisroundlabels[2].Location = new Point(450, 320); } } } } } if (thisroundplays == 4) { turn2(); CheckWinner(); } } } }