Exemplo n.º 1
0
        public async Task <ActionResult> Game(long gameId, PlayerChoose number)
        {
            try
            {
                ShowGameView gameStatistics = new ShowGameView();
                gameStatistics.ShowGameViewItems = await _gameService.ContinuePlaying((long)gameId, number);

                foreach (var player in gameStatistics.ShowGameViewItems)
                {
                    if (player.PlayerStatus == PlayerStatus.Won)
                    {
                        return(View("~/Views/Game/GameResult.cshtml", gameStatistics.ShowGameViewItems));
                    }
                }
                return(View(gameStatistics.ShowGameViewItems));
            }
            catch (Exception exeption)
            {
                return(View("~/Views/Shared/Error.cshtml", exeption));
            }
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <ShowGameViewItem> > ContinuePlaying(long gameId, PlayerChoose choose)
        {
            IEnumerable <ShowGameViewItem> gameStatistics = await InitializGameStatistics(gameId);

            if (choose == PlayerChoose.ContinueGame)
            {
                gameStatistics = await TakeCard(gameStatistics);
            }
            if (choose == PlayerChoose.StopGame)
            {
                gameStatistics.ToList().Find(p => p.PlayerType == PlayerType.User).PlayerStatus = PlayerStatus.Wait;
                gameStatistics = await DropCard(gameStatistics);
            }
            gameStatistics = await CheckEndGame(gameStatistics);

            return(gameStatistics);
        }