//MVC will attempt to create an instance of the parameters in this method, // and will also try to map values in the GET/POST to propeties of those // instances. public ActionResult StartGame(CreateGameOptions options) { GameViewModel model = new GameViewModel(); model.CreateGame(options); //The string "GameBoard" corresponds to the name of a view in the Game folder. //Also, we use PartialView() here so we only render the html that's in the view, // and not use the full layout page. return PartialView("GameBoard", model); }
public Guid CreateGame(CreateGameOptions options) { Guid identifier = Guid.NewGuid(); Game game = new Game(); game.Id = Id++; game.PlayerOneName = options.PlayerOneName; game.PlayerTwoName = options.PlayerTwoName; game.Board = new char[3][]; for (int i = 0; i < 3; i++) { game.Board[i] = new char[3]; } game.Board[0][0] = 'X'; game.Board[2][2] = 'Y'; //Just to show something on the board. this.TicTacToeGames.Add(identifier, game); return identifier; }
public void CreateGame(CreateGameOptions options) { this.GameId = TicTacTotalDominationContext.Instance.CreateGame(options); this.Game = TicTacTotalDominationContext.Instance.GetGame(this.GameId); }