コード例 #1
0
        public IActionResult CheckAnswer(string[] answer, int[] bet)
        {
            Answer.IsValidate = true;
            var getQuest = _questionData.SelectQuestion(AnswerViewModel.ID);
            int BetMoney = 0;

            foreach (var x in bet)
            {
                BetMoney += x;
            }
            if (BetMoney != Player.Amount)
            {
                Answer.IsValidate = false;
                return(RedirectToAction("SelectedQuestion", new { id = AnswerViewModel.ID }));
            }

            var checkAnswer = _questionData.CheckAnswer(getQuest.CorrectAnswer, answer, bet);

            if (checkAnswer == true)
            {
                if (Player.AnswerNumber == 8)
                {
                    return(RedirectToAction("FinalResult"));
                }
                else
                {
                    Player.AnswerNumber++;
                    return(View(getQuest));
                }
            }
            else
            {
                TempData["ans"] = getQuest.CorrectAnswer;
                QuestLvl        = 0;
                _questionData.ResetDatas();
                return(RedirectToAction("BadAnswer"));
            }

            return(Ok());
        }
コード例 #2
0
 public IActionResult EndWithoutScore()
 {
     _questionData.ResetDatas();
     _playerData.ResetData();
     return(RedirectToAction("Index"));
 }