/// <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(); }
protected void GetSuperiority(NetworkStream ns, View view, Game game) { BinaryFormatter formatter = new BinaryFormatter(); FigureTypes figtype = (FigureTypes)formatter.Deserialize(ns); Position pos = (Position)formatter.Deserialize(ns); view.Invoke(new Action( () => { game.DirectStateCycle(); game.Field.TransformPawn(pos, figtype); view.DrawField(); game.Field.ShahCheck(game.Field.GetFigureAt(pos)); view.SetTurnText(); view.WhiteCount(game.Player1.GetCount()); view.BlackCount(game.Player2.GetCount()); })); }