Exemplo n.º 1
0
        //Write out player names
        void SetUpPlayerNamesAndTable()
        {
            //SetUp: Name label
            PlayerOneNameL.Invoke((MethodInvoker)(() => PlayerOneNameL.Visible = true));
            PlayerTwoNameL.Invoke((MethodInvoker)(() => PlayerTwoNameL.Visible = true));
            //SetuUp: ELO label
            PlayerOneELOLabel.Invoke((MethodInvoker)(() => PlayerOneELOLabel.Visible = true));
            PlayerTwoELOLabel.Invoke((MethodInvoker)(() => PlayerTwoELOLabel.Visible = true));
            PlayerOneELORankLabel.Invoke((MethodInvoker)(() => PlayerOneELORankLabel.Visible = true));
            PlayerTwoELORankLabel.Invoke((MethodInvoker)(() => PlayerTwoELORankLabel.Visible = true));
            //SetUp: Name
            PlayerOneNameL.Invoke((MethodInvoker)(() => PlayerOneNameL.Text = "[ " + table.players[0].Name + " ]"));
            PlayerTwoNameL.Invoke((MethodInvoker)(() => PlayerTwoNameL.Text = "[ " + table.players[1].Name + " ]"));
            //SetuUp: ELO
            Thread a = new Thread(SetUpPlayerDatas);

            a.Start();
            //SetUp: Table
            POUPG = PlayerOneUnitsP.CreateGraphics();
            PTUPG = PlayerTwoUnitsP.CreateGraphics();
            Graphics[] c = { PTUPG, POUPG };

            foreach (Graphics u in c)
            {
                u.DrawRectangle(Pens.Black, 0, 0, 130, 26);
            }
        }
Exemplo n.º 2
0
        //Reset!
        public void Reset()
        {
            //Game win/lose || dodge too
            if (table.endgame != 2)
            {
                if (table.players.Find((v) => v != table.players[table.endgame]) == PlayerOne)
                {
                    int val = kliens.GameEnd(PlayerOne, table.players[table.endgame]);
                    endform.Win(val);
                }
                else
                {
                    endform.Lose();
                }
            }
            else
            {
                int val = kliens.GameEnd(PlayerOne, table.players.Find((v) => v.Name != PlayerOne.Name));
                endform.Win(val);
            }


            //Reset: Game
            table  = null;
            kliens = new Client(PlayerOne, getplayermove, findmatch, richTextBox1, resetgame, this);
            richTextBox1.Invoke((MethodInvoker)(() => richTextBox1.Text += "--------------------------"));
            StartButton.Invoke((MethodInvoker)(() => StartButton.Visible = true));
            //Reset: Sakk label
            PlayerOneSakkL.Invoke((MethodInvoker)(() => PlayerOneSakkL.Visible = false));
            PlayerTwoSakkL.Invoke((MethodInvoker)(() => PlayerTwoSakkL.Visible = false));
            //Reset: Name label
            PlayerOneNameL.Invoke((MethodInvoker)(() => PlayerOneNameL.Visible = false));
            PlayerTwoNameL.Invoke((MethodInvoker)(() => PlayerTwoNameL.Visible = false));
            //SetuUp: ELO label
            PlayerOneELOLabel.Invoke((MethodInvoker)(() => PlayerOneELOLabel.Visible = false));
            PlayerTwoELOLabel.Invoke((MethodInvoker)(() => PlayerTwoELOLabel.Visible = false));
            PlayerOneELORankLabel.Invoke((MethodInvoker)(() => PlayerOneELORankLabel.Visible = false));
            PlayerTwoELORankLabel.Invoke((MethodInvoker)(() => PlayerTwoELORankLabel.Visible = false));

            Graphics[] c = { PTUPG, POUPG };
            graphics.FillRectangle(Brushes.WhiteSmoke, 0, 0, 216, 216);

            foreach (Graphics u in c)
            {
                u.FillRectangle(Brushes.WhiteSmoke, 0, 0, 131, 27);
            }
            c = null;
        }
Exemplo n.º 3
0
        //DownlaodPlayerDatas
        void SetUpPlayerDatas()
        {
            //Get mmr data
            WebClient a = new WebClient();

            string[] str = new string[2];
            for (int i = 0; i < 2; i++)
            {
                try { str[i] = a.DownloadString(Client.shost + "type=0&name=" + table.players[i].Name); } catch (Exception) { return; }
            }

            //Setlabels
            PlayerOneELOLabel.Invoke((MethodInvoker)(() => PlayerOneELOLabel.Text = str[0].Split(':')[2]));
            PlayerTwoELOLabel.Invoke((MethodInvoker)(() => PlayerTwoELOLabel.Text = str[1].Split(':')[2]));

            //Get rank data
            string ranks = "";

            try { ranks = a.DownloadString(Client.shost + "type=3&name=" + table.players[0].Name); } catch (Exception) { return; }
            if (ranks == "")
            {
                return;
            }

            //Setlabels
            List <string> split = new List <string>(ranks.Split('/'));

            int[] s = new int[2];
            for (int i = 0; i < 2; i++)
            {
                s[i] = split.FindIndex((v) => v.Split(':')[0] == table.players[i].Name) + 1;
            }
            PlayerOneELORankLabel.Invoke((MethodInvoker)(() => PlayerOneELORankLabel.Text = (s[0] != 0) ? "|#" + s[0].ToString() + "|" : ""));
            PlayerTwoELORankLabel.Invoke((MethodInvoker)(() => PlayerTwoELORankLabel.Text = (s[1] != 0) ? "|#" + s[1].ToString() + "|" : ""));
            return;
        }