public StartGamePage() { InitializeComponent(); StartGameViewModel startGameViewModel = new StartGameViewModel(); DataContext = startGameViewModel; }
public async Task <ActionResult> Index() { try { List <PlayerViewModel> playerExist = (await _service.GetAllPlayers()).ToList(); var model = new StartGameViewModel { Players = playerExist.Select(player => new SelectListItem { Value = player.Name.ToLower(), Text = player.Name.ToLower() }).ToList(), NumberOfBots = new List <SelectListItem> { new SelectListItem { Value = "1", Text = "1" }, new SelectListItem { Value = "2", Text = "2" }, new SelectListItem { Value = "3", Text = "3" }, new SelectListItem { Value = "4", Text = "4" } } }; return(View(model)); } catch (Exception) { return(RedirectToAction("Error")); } }
/// <summary> /// Creates a new start game screen object /// </summary> /// <param name="game">game object</param> public StartGameScreen(TheGame game) : base(game) { this.viewModel = new StartGameViewModel(game); this.InitUserInterface(game); this.spriteBatch = new SpriteBatch(this.GraphicsDevice); }
public StartGame() { InitializeComponent(); var viewModel = new StartGameViewModel(); DataContext = viewModel; viewModel.FinishCheck += (e, a) => DialogResult = true; }
public async Task <IActionResult> Index() { var playerChoices = await _playerProvider.GetList(); var model = new StartGameViewModel() { PlayerChoices = playerChoices, PlayerSelectItems = playerChoices.Select(x => new SelectListItem() { Value = x.Item1.ToString(), Text = x.Item2 }) }; return(View(model)); }
public async Task <ActionResult> StartGame(StartGameViewModel startGame) { try { int gameId = await _gameService.StartGame(startGame); await _gameService.StartFirstGameRound(gameId); return(RedirectToAction("Play", new { id = gameId })); return(View()); } catch (Exception e) { return(View("Error")); } }
public async Task <int> StartGame(StartGameViewModel startGame) { Game game = new Game(); game.Name = startGame.Name; int gameId = await _gameRepository.InsertGame(game); GamePlayer gamePlayer = new GamePlayer(); GamePlayer gameDealer = new GamePlayer(); gamePlayer.PlayerId = startGame.PlayerId; gamePlayer.GameId = gameId; gamePlayer.Points = 0; gamePlayer.Result = string.Empty; gameDealer.PlayerId = startGame.DealerId; gameDealer.GameId = gameId; gameDealer.Points = 0; gameDealer.Result = string.Empty; await _gamePlayerRepository.InsertGamePlayer(gamePlayer); await _gamePlayerRepository.InsertGamePlayer(gameDealer); var bots = await _playerRepository.GetBots(); int botNumberCounter = 0; foreach (Player bot in bots) { if (botNumberCounter >= startGame.BotsNumber) { break; } GamePlayer gameBot = new GamePlayer(); gameBot.PlayerId = bot.Id; gameBot.GameId = gameId; gameBot.Points = 0; gameBot.Result = string.Empty; await _gamePlayerRepository.InsertGamePlayer(gameBot); botNumberCounter++; } return(gameId); }
public ActionResult Index() { StartGameViewModel viewmodel = new StartGameViewModel(); if (!_player_identifier.has_indenitfier()) { _player_identifier.set_player_identifier(Guid.NewGuid()); } else { var game_view = _presenter.get_view_of_minefield_for(_player_identifier.get_player_identifier()); if (game_view != null && !game_view.game_has_finished) { viewmodel.show_resume_game_button = true; } } return(View(viewmodel)); }
public IActionResult StartGame(StartGameViewModel model) { return(View("Index", model)); }