Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        public ChessField(Player p1, Player p2)
        {
            field = new Figure[8, 8];
            blacklastmoved = null;
            whitelastmoved = null;
            p1.alivefigures.Clear();
            p2.alivefigures.Clear();
            p1.deadfigures.Clear();
            p2.deadfigures.Clear();
            p1.ArrangeFigures(this);
            p2.ArrangeFigures(this);

            pl1 = p1;
            pl2 = p2;

            foreach (Figure fig in p1.alivefigures)
            {
                SetFigureAt(fig.Position, fig);
            }
            foreach (Figure fig in p2.alivefigures)
            {
                SetFigureAt(fig.Position, fig);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Создает нового игрока или использует статистику старого если username == null
 /// </summary>
 private Player CreateUser(string username, Side side,Player player)
 {
     if (username == null && player != null && player.Side == side)
         return player;
     else
     {
         if (username == null)
         {
             if (side == Side.White)
                 username = "******";
             else
                 username = "******";
         }
         return new Player(username, side);
     }
 }
Ejemplo n.º 4
0
        public void NewServerGame()
        {
            gametype = GameType.ServerGame;
            this.player1 = CreateUser(view.GetUserName(Side.White), Side.White, player1);
            this.player2 = new Player("", Side.Black);
            //this.player1 = new Player("", Side.White);
            //this.player2 = new Player("", Side.Black);

            state = GameState.WaitWhite;
            Field = new ChessField(player1, player2);
            field.SetPawnSuperiousListener(PawnSuperiorityHandler);
            field.SetKingShahListener(KingShahHandler);
            field.SetKingStalemateListener(KingStalemateHandler);

            view.ClearLog();
            server = new ServerThread(view, this);
            Thread thread = new Thread(server.Run);
            thread.Start();
            thread.IsBackground = true;
            DialogResult dialogresult = view.ShowServerBanner();

            if (dialogresult == DialogResult.Abort)
                {
                    server.listener.Stop();
                    thread.Abort();
                    return;
                }
            //thread.Join();

            view.ShowgbChessField(true);
            view.ShowrtbLog(true);
            view.EnableDefeat(true);
            view.EnableSave(true);
            view.EnableUndo(true);
            view.EnableNewGame(false);
            view.EnableNewLanGame(false);
            view.EnableLoad(false);
            view.ShowgbHUD(true);
            view.DrawField();
            view.SetWhiteName(player1.Name);
            view.SetBlackName(player2.Name);
            view.WhiteCount(player1.GetCount());
            view.BlackCount(player2.GetCount());
            view.SetTurnText();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Новая игра
        /// </summary>
        public void NewGame()
        {
            gametype = GameType.LocalGame;
            this.player1 = CreateUser(view.GetUserName(Side.White), Side.White, player1);
            this.player2 = CreateUser(view.GetUserName(Side.Black), Side.Black, player2);
            //this.player1 = new Player("", Side.White);
            //this.player2 = new Player("", Side.Black);
            state = GameState.WaitWhite;
            Field = new ChessField(player1, player2);

            view.ClearLog();
            view.ShowgbChessField(true);
            view.ShowrtbLog(true);
            view.EnableDefeat(true);
            view.EnableSave(true);
            view.EnableUndo(true);
            view.EnableNewGame(false);
            view.EnableNewLanGame(false);
            view.EnableLoad(false);
            view.ShowgbHUD(true);
            field.SetPawnSuperiousListener(PawnSuperiorityHandler);
            field.SetKingShahListener(KingShahHandler);
            field.SetKingStalemateListener(KingStalemateHandler);
            view.DrawField();
            view.SetWhiteName(player1.Name);
            view.SetBlackName(player2.Name);
            view.WhiteCount(player1.GetCount());
            view.BlackCount(player2.GetCount());
            view.SetTurnText();
        }
Ejemplo n.º 6
0
        public void NewClientGame()
        {
            gametype = GameType.ClientGame;

            this.player1 = new Player("", Side.White);
            this.player2 = CreateUser(view.GetUserName(Side.Black), Side.Black, player2);
            //this.player1 = new Player("", Side.White);
            //this.player2 = new Player("", Side.Black);

            state = GameState.WaitWhite;
            Field = new ChessField(player1, player2);
            field.SetPawnSuperiousListener(PawnSuperiorityHandler);
            field.SetKingShahListener(KingShahHandler);
            field.SetKingStalemateListener(KingStalemateHandler);
            view.ClearLog();
            client = new ClientThread(view, this, view.GetServerAddress(), 12000);
            Thread thread = new Thread(client.Run);
            thread.Start();
            thread.IsBackground = true;
            //thread.Join();
        }