public void Run(ChessApp app) { var game = new Game(); game.AddBoard(new StandardBoard()); app.RegisterGame(game); app.Output.OnNewGameStarted(game); }
public GameModule() : base("game") { var output = new AppOutput(); var app = new ChessApp(output); Post["new"] = _ => { app.Handle(new CreateGameAppCommand()); return Response.AsJson(output.NewGame); }; Post["join/{id}/iam/{playerName}/playing/{colour}"] = parameters => { string gameId = parameters.id; string playerName = parameters.playerName; var colour = GetColour(parameters.colour); if (colour == null) { return HttpStatusCode.BadRequest; } app.Handle(new JoinGameAppCommand(gameId, playerName, colour)); return $"{playerName} joined game {gameId} as {colour}"; }; }
/* * Этот класс должен расположить все элементы на экране: * 1. Поле для шахмат. * 2. Историю. * 3. Сообщения игрокам. */ public ChessForm(ChessApp app, IBoardStyle boardStyle, ICellBitmapSelector <ChessPiece> bitmapSelector, IMessageSelector <ChessGame> messageSelector) { this.app = app; this.bitmapSelector = bitmapSelector; this.messageSelector = messageSelector; board = new BoardControl(boardStyle, bitmapSelector.BitmapWidth, bitmapSelector.BitmapHeight); board.CellClick += app.ClickAt; app.StateChanged += Invalidate; // need some layout }
public void Run(ChessApp app) { var game = app.GetGame(_gameName); var player = CreatePlayer(_playerName, _playerColour); var result = game.Join(_playerColour, player); if (!result.WasSuccess) { app.Output.OnColourTakenCannotJoinGameError(_playerColour, game); } else { app.Output.OnPlayerJoiningGame(player, game); } }
// здесь нужен не IWarChessGame, а класс с уровня application public WarChessCellBitmapSelector(IChessStyle style, ChessApp app) { // if piece is visible - select bitmap, othervise - transparent bitmap this.style = style; this.app = app; }
public void Run(ChessApp app) { app.Stop(); app.Output.OnAppStopping(); }