示例#1
0
文件: Form1.cs 项目: 74805/Whist
        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();
                    }
                }
            }
        }