コード例 #1
0
        public GameViewModel GetGameViewModel()
        {
            var game    = _gameService.GetCurrentGame(_playerName);
            var count   = _roundService.GetPlayersId(game.Id).Count() - 2;
            var players = _gameService.GetPlayers(_playerName, count);
            List <List <byte> > cards  = null;
            List <byte>         scores = null;
            var  rounds           = _roundService.GetRounds(game.Id);
            var  round            = rounds[rounds.Count() - 1];
            bool isCompletedRound = round.IsCompleted;

            if (isCompletedRound)
            {
                _roundService.StartRound(game.Id);
            }
            if (!isCompletedRound)
            {
                cards  = _roundService.GetCardsByRound(game.Id, round.Id);
                scores = _roundService.GetScores(game.Id);
            }
            GameViewModel gameViewModel = new GameViewModel
            {
                Game    = game,
                Players = players,
                Cards   = cards,
                Scores  = scores
            };

            return(gameViewModel);
        }
コード例 #2
0
        public List <RoundViewModel> GetRoundsViewModel(int gameId)
        {
            var roundViewModels = new List <RoundViewModel>();
            var rounds          = _roundService.GetRounds(gameId);

            foreach (Round round in rounds)
            {
                var playersId      = _roundService.GetPlayersId(gameId).ToList();
                var roundViewModel = new RoundViewModel
                {
                    Round   = round,
                    Players = _gameService.GetNamePlayers(playersId),
                    Scores  = _roundService.GetScoresByRoundId(gameId, round.Id),
                    IsWins  = _roundService.GetIsWinsByRound(gameId, round.Id),
                    Cards   = _roundService.GetCardsByRound(gameId, round.Id)
                };
                roundViewModels.Add(roundViewModel);
            }
            return(roundViewModels);
        }