Browse Source

DJ display + DJ editing

Sebastian Lohff 6 years ago
parent
commit
036edcc1cd
2 changed files with 25 additions and 6 deletions
  1. 5
    1
      game.py
  2. 20
    5
      windows.py

+ 5
- 1
game.py View File

@@ -210,13 +210,17 @@ class SeopardyGame(QtGui.QWidget):
210 210
 		tries = answers.get_tries()
211 211
 		if len(tries) > numTries:
212 212
 			btnstr = "...\n"
213
+
214
+		first = True
213 215
 		for player, correct in answers.get_tries()[-numTries:]:
214 216
 			if correct:
215 217
 				btncolor = player.color
216 218
 				prefix = "+"
217 219
 			else:
218 220
 				prefix = "-"
219
-			btnstr += "%s%s\n" % (prefix, player.name)
221
+			dj = " (D)" if first and answers.get_dj_points() is not None else ""
222
+			btnstr += "%s%s%s\n" % (prefix, player.name, dj)
223
+			first = False
220 224
 
221 225
 		if not answers.got_answered():
222 226
 			btnstr += "+nobody"

+ 20
- 5
windows.py View File

@@ -135,6 +135,8 @@ class EditAnswersWindow(QtGui.QDialog):
135 135
 		self._players = players
136 136
 		self._answers = answers
137 137
 		self._nobody = not answers.got_answered()
138
+		self._dj_points = answers.get_dj_points()
139
+		self._in_window = False
138 140
 		if self._answers:
139 141
 			self._tries = copy.copy(self._answers.get_tries())
140 142
 		else:
@@ -145,7 +147,8 @@ class EditAnswersWindow(QtGui.QDialog):
145 147
 		self.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
146 148
 
147 149
 	def get_new_answers(self):
148
-		qa = QuestionAnswers(self._answers.section, self._answers.qnumber)
150
+		qa = QuestionAnswers(self._answers.section, self._answers.qnumber, dj_points=self._dj_points)
151
+
149 152
 		rightPlayer = None
150 153
 		for player, correct in self._tries:
151 154
 			if correct:
@@ -171,7 +174,7 @@ class EditAnswersWindow(QtGui.QDialog):
171 174
 		self._resetAllButtons()
172 175
 		self.layout.addLayout(self.answerlayout)
173 176
 
174
-		self.xlabel = QtGui.QLabel("+/- right/wrong, d delete, a add, arrows change player")
177
+		self.xlabel = QtGui.QLabel("+/- right/wrong, d delete, a add, arrows change player\ne edit double jeopardy")
175 178
 		self.xlabel.setStyleSheet("QLabel { font-size: 15px; }")
176 179
 		self.layout.addWidget(self.xlabel)
177 180
 
@@ -180,6 +183,15 @@ class EditAnswersWindow(QtGui.QDialog):
180 183
 	def keyPressEvent(self, e):
181 184
 		if e.key() == QtCore.Qt.Key_Escape:
182 185
 			self.close()
186
+		elif e.key() == QtCore.Qt.Key_E:
187
+			# edit double jeopardy
188
+			if self._dj_points is not None and len(self._tries) > 0 and not self._in_window:
189
+				self._in_window = True
190
+				dwin = DoubleJeopardyWindow(self._players, self._answers.qnumber*100, self._tries[0][0], current_points=self._dj_points, parent=self)
191
+				dwin.exec_()
192
+				self._dj_points = dwin.get_chosen_points()
193
+				self._tries[0] = (dwin.get_player(), self._tries[0][1])
194
+				self._in_window = False
183 195
 		else:
184 196
 			currFocus = self._getCurrFocus()
185 197
 			if currFocus is None and e.key() != QtCore.Qt.Key_A:
@@ -247,15 +259,18 @@ class EditAnswersWindow(QtGui.QDialog):
247 259
 			f = self.answerlayout.takeAt(0)
248 260
 
249 261
 		# add buttons
262
+		first = True
250 263
 		for player, correct in self._tries:
251
-			self._addAnswerButton(player, correct)
264
+			self._addAnswerButton(player, correct, first)
265
+			first = False
252 266
 
253 267
 		# add the nobody button
254 268
 		self._addAnswerButton(Player("nobody", nobodyColor), self._nobody)
255 269
 
256
-	def _addAnswerButton(self, player, correct=False):
270
+	def _addAnswerButton(self, player, correct=False, first=False):
257 271
 		prefix = "+" if correct else "-"
258
-		btn = QtGui.QPushButton("\n%s%s\n" % (prefix, player.name), self)
272
+		dj = " (D)" if first and self._dj_points is not None else ""
273
+		btn = QtGui.QPushButton("\n%s%s%s\n" % (prefix, player.name, dj), self)
259 274
 		btn.setStyleSheet("QPushButton { background-color: %s; color: white; font-size: 20px; border: none; }" % (player.color.name(),))
260 275
 		btn.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
261 276
 		self.answerlayout.addWidget(btn)

Loading…
Cancel
Save