Esempio n. 1
0
        public BluffParams GetBluffParams(SendBluffViewModel model, string userId, RockPaperScissorsType choice)
        {
            var bluffParams = _mapper.Map <SendBluffViewModel, BluffParams>(model);

            bluffParams.UserId      = userId;
            bluffParams.GameRoundId = model.GameRoundId;

            return(bluffParams);
        }
Esempio n. 2
0
        private WinModel WinnerModel(RockPaperScissorsType hostChoice, string hostUserId, RockPaperScissorsType guestChoice, string guestUserId)
        {
            if (hostChoice == guestChoice)
            {
                return(new WinModel(string.Empty, ChoiceResultType.Draw));
            }

            if (hostChoice == RockPaperScissorsType.Paper && guestChoice == RockPaperScissorsType.Scissors)
            {
                return(new WinModel(guestUserId, ChoiceResultType.ScissorCutsPaper));
            }
            else if (hostChoice == RockPaperScissorsType.Rock && guestChoice == RockPaperScissorsType.Paper)
            {
                return(new WinModel(guestUserId, ChoiceResultType.PaperCoversRock));
            }
            else if (hostChoice == RockPaperScissorsType.Scissors && guestChoice == RockPaperScissorsType.Rock)
            {
                return(new WinModel(guestUserId, ChoiceResultType.RockBreaksScissor));
            }
            else if (hostChoice == RockPaperScissorsType.NotAnswered)
            {
                return(new WinModel(guestUserId, ChoiceResultType.NotAnswered));
            }

            if (guestChoice == RockPaperScissorsType.Paper && hostChoice == RockPaperScissorsType.Scissors)
            {
                return(new WinModel(hostUserId, ChoiceResultType.ScissorCutsPaper));
            }
            else if (guestChoice == RockPaperScissorsType.Rock && hostChoice == RockPaperScissorsType.Paper)
            {
                return(new WinModel(hostUserId, ChoiceResultType.PaperCoversRock));
            }
            else if (guestChoice == RockPaperScissorsType.Scissors && hostChoice == RockPaperScissorsType.Rock)
            {
                return(new WinModel(hostUserId, ChoiceResultType.RockBreaksScissor));
            }
            else if (guestChoice == RockPaperScissorsType.NotAnswered)
            {
                return(new WinModel(hostUserId, ChoiceResultType.NotAnswered));
            }

            throw new WrongChoiceTypeException("Given Choice is not valid");
        }
Esempio n. 3
0
 public async Task TextBluff(string userId, RockPaperScissorsType choice)
 {
     await Clients.User(userId).SendAsync("TextBluff", choice);
 }