Beispiel #1
0
        public void CheckWinner()
        {//כאשר נגמר סיבוב, הפעולה מראה לשחקנים מי ניצח ונותנת למנצח לבחור מתי לעבור לסיבוב הבא
            Controls.Remove(turnname);
            Card[] usedcards = myICommon.UsedCards();
            winnerid = myICommon.GetWinnerId();

            if (myICommon.isroundover(clientid) && (int)(take[0].Text[0]) + (int)take[1].Text[0] + (int)take[2].Text[0] + (int)take[3].Text[0] - 48 * 4 < usedcards.Length)
            {
                take[winnerid].Text = ((int)take[winnerid].Text[0] - 47).ToString();
            }

            if (winnerid == clientid)
            {
                nextround.Text     = "המשך לסיבוב הבא";
                nextround.Location = new Point(645, 320);
                nextround.Size     = new Size(100, 100);
                nextround.Click   += NextRound;
                Controls.Add(nextround);
            }

            winner.Text     = pnames[winnerid] + " !ניצח בסיבוב";
            winner.Location = new Point(650, 300);
            Controls.Add(winner);
        }
Beispiel #2
0
        public void StartGame(object sender, EventArgs args)
        {
            timer.Start();
            if (clientid == -1)
            {
                clientid = myICommon.Id();
            }
            myICommon.Name(clientid, pnamesasking.Text);

            Image img = Image.FromFile("..\\..\\..\\PNG\\3S.png");

            img = Resize(img, 54, 83);
            for (int i = 0; i < 4; i++)
            {
                thisroundlabels[i]      = new Label();
                thisroundlabels[i].Size = img.Size;
            }
            thisroundlabels[clientid].Location = new Point(670, 450);
            if (clientid == 0)
            {
                thisroundlabels[1].Location = new Point(450, 320);
                thisroundlabels[2].Location = new Point(670, 175);
                thisroundlabels[3].Location = new Point(900, 320);
            }
            else
            {
                if (clientid == 1)
                {
                    thisroundlabels[0].Location = new Point(900, 320);
                    thisroundlabels[2].Location = new Point(450, 320);
                    thisroundlabels[3].Location = new Point(670, 175);
                }
                else
                {
                    if (clientid == 2)
                    {
                        thisroundlabels[0].Location = new Point(670, 175);
                        thisroundlabels[1].Location = new Point(900, 320);
                        thisroundlabels[3].Location = new Point(450, 320);
                    }
                    else
                    {
                        thisroundlabels[0].Location = new Point(450, 320);
                        thisroundlabels[1].Location = new Point(670, 175);
                        thisroundlabels[2].Location = new Point(900, 320);
                    }
                }
            }
            for (int i = 0; i < 4; i++)
            {
                declares[i]          = new Label();
                declares[i].Location = thisroundlabels[i].Location;
            }

            Controls.Remove((Button)sender);
            Controls.Remove(pnamesasking);
            Createcards();
            if (clientid == 3)
            {
                txt.Text             = "או";
                choosetrump.Text     = "בחרו את השליט";
                circle.Text          = "ערכו סבב בין השחקנים";
                choosetrump.Size     = new Size(105, 25);
                circle.Size          = new Size(145, 25);
                choosetrump.Location = new Point(740, 360);
                txt.Location         = new Point(709, 365);
                circle.Location      = new Point(558, 360);
                choosetrump.Click   += GetTrump;
                circle.Click        += SetDeclare;
                Controls.Add(choosetrump);
                Controls.Add(circle);
                Controls.Add(txt);
            }
        }
Beispiel #3
0
        public void Timer1(object sender, EventArgs args)
        {//(...המשתמש מגיע לפעולה הזאת כל 50 מילישניות על מנת להתעדכן במצב המשחק (אם מתחיל המשחק, אם נגמר הסיבוב
            if (myICommon.GetNextGame(clientid))
            {
                myICommon.SetNextGameFalse(clientid);
                Button send = new Button();
                Controls.Clear();
                StartGame(send, args);
                ShowNames();
                currentturn = -1;
                Controls.Remove(turnname);
            }
            thisroundcards = myICommon.ThisRoundCards();
            if (myICommon.GetRemoveCards(clientid))
            {
                for (int i = 0; i < 4; i++)
                {
                    if (thisroundlabels[i].Image != null)
                    {
                        Controls.Remove(thisroundlabels[i]);
                        thisroundlabels[i].Image = null;
                        thisroundcards[i]        = null;
                    }
                }
                myICommon.SetRemoveCardsFalse(clientid);
                if (Controls.Contains(nextround))
                {
                    Controls.Remove(nextround);
                }
                Controls.Remove(winner);
            }

            if (myICommon.NewDeclare(clientid))
            {
                thisdeclare = myICommon.ThisDeclare();
                declares[(int)thisdeclare[thisdeclare.Length - 1] - 48].Text = thisdeclare.Substring(0, thisdeclare.Length - 1);
                Controls.Add(declares[(int)thisdeclare[thisdeclare.Length - 1] - 48]);
            }

            if (myICommon.GetNames())
            {
                if (names[3] == null || names[2] == null || names[3].Text == "" || names[2].Text == "")
                {
                    ShowNames();
                }

                turn2();


                if (currentturn != myICommon.GetTurn() && !Controls.Contains(circle))
                {
                    CurrentTurn();
                }

                if (myICommon.NewCard(clientid))
                {
                    NewCard();
                }

                if (myICommon.IsCurrneTurn(clientid) || myICommon.ThisRoundPlays())
                {
                    turn2();
                }
                if (myICommon.ThisRoundPlays())
                {
                    CheckWinner();
                }
            }
        }
Beispiel #4
0
        public void Timer1(object sender, EventArgs args)
        {//(...המשתמש מגיע לפעולה הזאת כל 50 מילישניות על מנת להתעדכן במצב המשחק (אם מתחיל המשחק, אם נגמר הסיבוב
            if (gotnames || myICommon.GetNames())
            {
                if ((names[3] == null || names[2] == null || names[3].Text == "" || names[2].Text == ""))
                {
                    gotnames = true;
                    ShowNames();
                }
                else
                {
                    thisroundcards = myICommon.ThisRoundCards();
                    if (myICommon.GetRemoveCards(clientid))
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            if (thisroundlabels[i].Image != null)
                            {
                                Controls.Remove(thisroundlabels[i]);
                                thisroundlabels[i].Image = null;
                                thisroundcards[i]        = null;
                            }
                        }
                        myICommon.SetRemoveCardsFalse(clientid);
                        if (Controls.Contains(nextround))
                        {
                            Controls.Remove(nextround);
                        }
                        Controls.Remove(winner);
                    }
                    if (myICommon.NewCard(clientid))
                    {
                        NewCard();
                    }
                    if (myICommon.NewDeclare(clientid))
                    {
                        thisdeclare = myICommon.ThisDeclare();
                        declares[(int)thisdeclare[thisdeclare.Length - 1] - 48].Text = thisdeclare.Substring(0, thisdeclare.Length - 1);
                        Controls.Add(declares[(int)thisdeclare[thisdeclare.Length - 1] - 48]);
                    }


                    if (myICommon.IsNewFrischCard(clientid))
                    {
                        ShowFrischCards();
                    }

                    if (myICommon.IsCurrneTurn(clientid) || myICommon.ThisRoundPlays())
                    {
                        turn2();
                    }
                    if (myICommon.ThisRoundPlays())
                    {
                        CheckWinner();
                    }
                    if (myICommon.GetFrisch(clientid))
                    {
                        Frisch();
                    }

                    if (declares[3] != null && declares[3].Text != "" && myICommon.IsDeclareOver(clientid))
                    {
                        declares[3].Text = "";
                        for (int i = 0; i < 4; i++)
                        {
                            Controls.Remove(declares[i]);
                        }
                    }
                    if (myICommon.RemoveFrischCard(clientid))
                    {
                        int[] takencard = myICommon.TookCard(clientid);
                        Controls.Remove(frischlabels[takencard[0], takencard[1]]);
                    }

                    if (currentturn != myICommon.GetTurn() && !Controls.Contains(circle))
                    {
                        CurrentTurn();
                    }
                    if (frischcards.Count != 0 && myICommon.AreAllCardsTaken())
                    {
                        Controls.Remove(itsfrisch);
                        frischcounter = 0;
                    }
                    if (myICommon.GetNextGame(clientid))
                    {
                        currentturn     = -1;
                        cards           = new List <Label>();
                        othercards1     = new List <Label>();
                        othercards2     = new List <Label>();
                        othercards3     = new List <Label>();
                        cnum            = new Button[9];
                        csha            = new Button[4];
                        trump           = null;
                        firstid         = -1;
                        firstturn       = new Button[4];
                        choosetrump     = new Button();
                        circle          = new Button();
                        txt             = new Label();
                        thisroundlabels = new Label[4];
                        thisroundcards  = null;
                        nextround       = new Button();
                        winner          = new Label();
                        take            = new Label[4];
                        Ip                = new TextBox();
                        declarenum        = null;
                        pass              = null;
                        currentturn       = -1;
                        turnname          = new Label();
                        declares          = new Label[4];
                        thisdeclare       = null;
                        frischcounter     = 0;
                        frischcards       = new List <Card>();
                        frischpcards      = null;
                        alreadyincontrols = new bool[4, 3];
                        frischlabels      = new Label[4, 3];
                        Controls.Remove(turnname);


                        myICommon.SetNextGameFalse(clientid);
                        Button send = new Button();
                        Controls.Clear();
                        StartGame(send, args);
                        ShowNames();
                    }
                }
            }
        }
Beispiel #5
0
        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();
                    }
                }
            }
        }
Beispiel #6
0
        public void Timer1(object sender, EventArgs args)
        {//(...המשתמש מגיע לפעולה הזאת כל 50 מילישניות על מנת להתעדכן במצב המשחק (אם מתחיל המשחק, אם נגמר הסיבוב
            thisroundcards = myICommon.ThisRoundCards();
            if (myICommon.GetRemoveLabels())
            {
                for (int i = 0; i < 4; i++)
                {
                    if (thisroundlabels[i] != null)
                    {
                        Controls.Remove(thisroundlabels[i]);
                        thisroundlabels[i] = null;
                    }
                }
                Controls.Remove(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 (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, 86, 132);
                                    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(1400, 450);
                            }

                            if (thisroundcards[2] != null)
                            {
                                thisroundlabels[2].Location = new Point(915, 200);
                            }

                            if (thisroundcards[3] != null)
                            {
                                thisroundlabels[3].Location = new Point(500, 450);
                            }
                        }
                        else
                        {
                            if (clientid == 1)
                            {
                                if (thisroundcards[0] != null)
                                {
                                    thisroundlabels[0].Location = new Point(500, 450);
                                }

                                if (thisroundcards[2] != null)
                                {
                                    thisroundlabels[2].Location = new Point(1400, 450);
                                }

                                if (thisroundcards[3] != null)
                                {
                                    thisroundlabels[3].Location = new Point(915, 200);
                                }
                            }
                            else
                            {
                                if (clientid == 2)
                                {
                                    if (thisroundcards[0] != null)
                                    {
                                        thisroundlabels[0].Location = new Point(915, 200);
                                    }

                                    if (thisroundcards[1] != null)
                                    {
                                        thisroundlabels[1].Location = new Point(500, 450);
                                    }

                                    if (thisroundcards[3] != null)
                                    {
                                        thisroundlabels[3].Location = new Point(1400, 450);
                                    }
                                }
                                else
                                {
                                    if (thisroundcards[0] != null)
                                    {
                                        thisroundlabels[0].Location = new Point(1400, 450);
                                    }

                                    if (thisroundcards[1] != null)
                                    {
                                        thisroundlabels[1].Location = new Point(915, 200);
                                    }

                                    if (thisroundcards[2] != null)
                                    {
                                        thisroundlabels[2].Location = new Point(500, 450);
                                    }
                                }
                            }
                        }
                    }
                    if (thisroundplays == 4)
                    {
                        turn2();
                        CheckWinner();
                    }
                }
            }
        }