Example #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            var userAnswer = string.Join("", textBoxModelsList.Where(t => t.TextBox.Visible).Select(t => t.TextBox.Text));
            var correct    = string.Equals(userAnswer, currentRiddle.Answer, StringComparison.InvariantCultureIgnoreCase);
            await answerHistoryService.CreateHistory(gameSession.Id, UserProfile.Id, currentRiddle.Id, userAnswer, correct);

            if (correct)
            {
                currentRiddle    = GetNextRiddle();
                totalUserPoints += pointsForOneRiddle;
                label4.Text      = string.Format("Очки пользователя: {0}", totalUserPoints);
                if (currentRiddle == null)
                {
                    dispose = false;
                    timer1.Stop();
                    await gameSessionService.CompleteGameSessionForUser(gameSession.Id, UserProfile.Id, totalTime.ToString("m:s"), totalUserPoints);

                    var rivalGameSessionUser = gameSessionService.GetGameSessionUser(gameSession.Id, UserProfile.RivalName);
                    if (!rivalGameSessionUser.Finished)
                    {
                        MessageBox.Show("Пожалуйста подождите пока ваш соперник закончит игру.\nВы автоматичски будете переброшенны на страницу результатов!", "Игра окончена", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        pictureBox3.Image   = Image.FromFile(@"Resources/99px_ru_animacii_20594_kot_krutitsja_kak_kolesiko_zagruzki.gif");
                        pictureBox3.Dock    = DockStyle.Fill;
                        pictureBox3.Visible = true;
                    }
                    else
                    {
                        await gameSessionService.CompleteGameSession(gameSession.Id);

                        HubService.RivalFinishedRequest(UserProfile.RivalName);
                        ResultForm resultForm = new ResultForm(totalTime.ToString("m:s"), totalUserPoints, rivalGameSessionUser.TotalTime, rivalGameSessionUser.Points);
                        resultForm.Show();
                        this.Close();
                    }
                }
                else
                {
                    HideAllTextBox();
                    label1.Text = currentRiddle.Text;
                    VisibleNeededTextBox(currentRiddle.Answer);
                    CleanTextBox();
                }
            }
            else
            {
                MessageBox.Show("Ответ неверный!\nПопробуйте ещё раз.", "Ответ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
 public void CompleteGameSession([FromBody] int gameSessionId)
 {
     try
     {
         gameSessionService.CompleteGameSession(gameSessionId);
     }
     catch (Exception ex)
     {
         throw;
     }
 }