-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form_Game.cs
132 lines (122 loc) · 4.09 KB
/
Form_Game.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace iTriviant
{
public partial class Form_Game : Form
{
internal Participant participant = null;
internal List<Question> questions = new List<Question>();
internal Subject subject = null;
int QuestionsAnswerd = 0;
int RightAnswers = 0;
DateTime beginTime = DateTime.Parse("01-01-2000 01:05:00");
public Form_Game()
{
InitializeComponent();
}
void NextQuestion()
{
if (QuestionsAnswerd != questions.Count)
{
label_Question.Text = questions[QuestionsAnswerd].questionText;
button_A.Text = questions[QuestionsAnswerd].answers[0].answerText;
button_B.Text = questions[QuestionsAnswerd].answers[1].answerText;
button_C.Text = questions[QuestionsAnswerd].answers[2].answerText;
button_D.Text = questions[QuestionsAnswerd].answers[3].answerText;
}
else
{
MessageBox.Show($"Jou totale score is: {RightAnswers} van de {questions.Count}.\n Jou tijd was {label_Timer.Text}");
Round round = new Round(0, DateTime.Now, participant, subject);
round.Create();
List<Round> rounds = Round.Read();
foreach(Round r in rounds)
{
if(r.date == round.date && r.winner.id == round.winner.id && r.subject.id == round.subject.id)
{
round = r;
}
}
Token token = new Token(0, $"{subject.name}-Token", subject);
token.Create(participant);
}
}
private void Form_Game_Load(object sender, EventArgs e)
{
NextQuestion();
timer_Counter.Enabled = true;
}
private void button_A_Click(object sender, EventArgs e)
{
foreach (Question q in questions)
{
if (q.questionText == label_Question.Text)
{
if (q.rightAnswer.answerText == button_A.Text)
{
RightAnswers++;
}
}
}
QuestionsAnswerd++;
NextQuestion();
}
private void button_B_Click(object sender, EventArgs e)
{
foreach (Question q in questions)
{
if (q.questionText == label_Question.Text)
{
if (q.rightAnswer.answerText == button_B.Text)
{
RightAnswers++;
}
}
}
QuestionsAnswerd++;
NextQuestion();
}
private void button_C_Click(object sender, EventArgs e)
{
foreach (Question q in questions)
{
if (q.questionText == label_Question.Text)
{
if (q.rightAnswer.answerText == button_C.Text)
{
RightAnswers++;
}
}
}
QuestionsAnswerd++;
NextQuestion();
}
private void button_D_Click(object sender, EventArgs e)
{
foreach (Question q in questions)
{
if (q.questionText == label_Question.Text)
{
if (q.rightAnswer.answerText == button_D.Text)
{
RightAnswers++;
}
}
}
QuestionsAnswerd++;
NextQuestion();
}
private void timer_Counter_Tick(object sender, EventArgs e)
{
beginTime = beginTime.Subtract(new TimeSpan(0, 0, 1));
label_Timer.Text = beginTime.ToString("mm:ss");
}
}
}