Esempio n. 1
0
        public async Task <bool> SendBluff(string userId, SendBluffViewModel model)
        {
            var roundAnswers = _roundAnswerService.RoundAnswers(model.GameRoundId);

            if (roundAnswers.All(x => x.Choice != Enum.RockPaperScissorsType.NotAnswered))
            {
                return(false);
            }

            BluffParams bluffParams = _bluffService.GetBluffParams(model, userId, model.Choice);

            _bluffService.CreateOrUpdate(bluffParams);
            await _bluffService.TextBluff(model, userId);

            return(true);
        }
Esempio n. 2
0
        public RoundResult CalculateRoundEnd(int gameRoundId)
        {
            var bluff        = _bluffService.Entities.FirstOrDefault(x => x.GameRoundId == gameRoundId);
            var isBluff      = bluff == null ? false : !bluff.IsSuperBluff;
            var isSuperBluff = bluff == null ? false : bluff.IsSuperBluff;

            var roundAnswers = _roundAnswerService.RoundAnswers(gameRoundId);
            var hostUserId   = roundAnswers.FirstOrDefault().UserId;
            var guestUserId  = roundAnswers.LastOrDefault().UserId;

            var winModel = WinnerModel(
                roundAnswers.FirstOrDefault().Choice,
                hostUserId,
                roundAnswers.LastOrDefault().Choice,
                guestUserId);

            var roundResult = new RoundResult(winModel.UserId, winModel.ChoiceResultType, isBluff, isSuperBluff);

            return(roundResult);
        }
Esempio n. 3
0
        public bool IsFirstAnswer(int gameRoundId)
        {
            var answerCount = _roundAnswerService.RoundAnswers(gameRoundId).Count;

            return(answerCount < 2 ? true : false);
        }