示例#1
0
        public StatisticForm(Player pl1, Player pl2)
        {
            InitializeComponent();

            lName1.Text = pl1.Name;
            lName2.Text = pl2.Name;
            lPlayed1.Text = (pl1.GetWin() + pl1.GetLose()).ToString();
            lPlayed2.Text = (pl2.GetWin() + pl2.GetLose()).ToString();
            lLose1.Text = pl1.GetLose().ToString();
            lLose2.Text = pl2.GetLose().ToString();
            lWin1.Text = pl1.GetWin().ToString();
            lWin2.Text = pl2.GetWin().ToString();
        }
示例#2
0
        public StatisticForm(Player pl1, Player pl2)
        {
            InitializeComponent();

            lName1.Text   = pl1.Name;
            lName2.Text   = pl2.Name;
            lPlayed1.Text = (pl1.GetWin() + pl1.GetLose()).ToString();
            lPlayed2.Text = (pl2.GetWin() + pl2.GetLose()).ToString();
            lLose1.Text   = pl1.GetLose().ToString();
            lLose2.Text   = pl2.GetLose().ToString();
            lWin1.Text    = pl1.GetWin().ToString();
            lWin2.Text    = pl2.GetWin().ToString();
        }
示例#3
0
        public void Run()
        {
            Player        player = game.Player2;
            NetworkStream ns     = null;
            TcpClient     client = null;

            try
            {
                listener = new TcpListener(IPAddress.Any, 12000);
                listener.Start(1);
                client = listener.AcceptTcpClient();
                view.AddToLog(String.Format("Подключен клиент {0}\nИграем за белых", client.Client.RemoteEndPoint.ToString()));
                ns = client.GetStream();
                string playername = ReadString(ns);
                int    lose, win;
                win         = ReadInt(ns);
                lose        = ReadInt(ns);
                player.Name = playername;
                player.SetStatistic(win, lose);
                // send player info
                player = game.Player1;
                WriteString(ns, player.Name);
                WriteInt(ns, player.GetWin());
                WriteInt(ns, player.GetLose());
                view.HideServerBanner();
                CommandLoop(ns, view, game);
                client.Close();
            }
            catch (Exception e)
            {
                view.Message(e.Message);
            }
            finally
            {
                if (ns != null)
                {
                    ns.Close();
                }
                if (client != null)
                {
                    client.Close();
                }
                if (listener != null)
                {
                    // Остановим его
                    listener.Stop();
                }
            }
        }
示例#4
0
        public void Run()
        {
            TcpClient     client = null;
            NetworkStream ns     = null;
            Player        player = game.Player2;

            try
            {
                client = new TcpClient();
                client.Connect(new IPEndPoint(IPAddress.Parse(server), port));
                ns = client.GetStream();
                view.AddToLog(String.Format("Подключен к серверу {0}:{1}\nИграем за черных", server, port));
                WriteString(ns, player.Name);
                WriteInt(ns, player.GetWin());
                WriteInt(ns, player.GetLose());
                // get first player
                player = game.Player1;
                string playername = ReadString(ns);
                int    lose, win;
                win         = ReadInt(ns);
                lose        = ReadInt(ns);
                player.Name = playername;
                player.SetStatistic(win, lose);
                view.Invoke(new Action(() => game.ClientGameView()));
                CommandLoop(ns, view, game);
            }
            catch (Exception e) {
                view.Message(e.Message);
            }
            finally
            {
                if (ns != null)
                {
                    ns.Close();
                }
                if (client != null)
                {
                    client.Close();
                }
            }
        }