annotate frontends/src/wix/quiz_game.py @ 361:141eeb7cd9e6

Quizz game: first draft
author Goffi <goffi@goffi.org>
date Sun, 12 Jun 2011 16:28:33 +0200
parents
children 208107419b17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
361
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
5 wix: a SAT frontend
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6 Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
7
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
12
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU General Public License for more details.
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
17
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
23
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 import wx
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 import os.path, glob
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 import pdb
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from logging import debug, info, error
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from sat.tools.jid import JID
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from time import time
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from math import sin, cos, pi
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32 CARD_WIDTH = 74
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33 CARD_HEIGHT = 136
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34 WIDTH = 800
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
35 HEIGHT = 600
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37 class GraphicElement():
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38 """This class is used to represent a card, graphically and logically"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 def __init__(self, file, x=0, y=0, zindex=10, transparent=True):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41 """ Image used to build the game visual
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
42 @param file: path of the PNG file
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 @param zindex: layer of the element (0=background; the bigger, the more in the foreground)"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
44 self.bitmap = wx.Image(file).ConvertToBitmap()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self.x = x
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self.y = y
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.zindex = zindex
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.transparent = transparent
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
50 def __cmp__(self, other):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
51 return self.zindex.__cmp__(other.zindex)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
52
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
53 def draw(self, dc, x=None, y=None):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
54 """Draw the card on the device context
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55 @param dc: device context
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
56 @param x: abscissa
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 @param y: ordinate"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58 dc.DrawBitmap(self.bitmap, x or self.x, y or self.y, self.transparent)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
60 class BaseWindow(wx.Window):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
61 """This is the panel where the game is drawed, under the other widgets"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
62
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
63 def __init__(self, parent):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
64 wx.Window.__init__(self, parent, pos=(0,0), size=(WIDTH, HEIGHT))
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
65 self.parent = parent
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
66 self.SetMinSize(wx.Size(WIDTH, HEIGHT))
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
67 self.Bind(wx.EVT_PAINT, self.onPaint)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
68 self.graphic_elts = {}
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
69 self.loadImages("images/quiz/")
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
70
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
71 def loadImages(self, dir):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
72 """Load all the images needed for the game
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
73 @param dir: directory where the PNG files are"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
74 for name, sub_dir, filename, x, y, zindex, transparent in [("background", "backgrounds", "blue_background.png", 0, 0, 0, False),
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
75 ("joueur0", "characters/zombie", "zombie.png", 24, 170, 5, True),
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
76 ("joueur1", "characters/nerd", "nerd2.png", 209, 170, 5, True),
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
77 ("joueur2", "characters/zombie", "zombie.png", 392, 170, 5, True),
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
78 ("joueur3", "characters/zombie", "zombie.png", 578, 170, 5, True),
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
79 ("foreground", "foreground", "foreground.png", 0, 0, 10, True)]:
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
80 self.graphic_elts[name] = GraphicElement(os.path.join(dir, sub_dir, filename), x = x, y = y, zindex=zindex, transparent=transparent)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
81
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
82 def fullPaint(self, device_context):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
83 """Paint all the game on the given dc
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
84 @param device_context: wx.DC"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
85 elements = self.graphic_elts.values()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
86 elements.sort()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
87 for elem in elements:
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
88 elem.draw(device_context)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
89 #device_context.DrawArc(39,127, 39, 127,
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
90
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
91 _font = wx.Font(65, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
92 device_context.SetFont(_font)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
93 device_context.SetTextForeground(wx.BLACK)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
94
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
95 x = 100
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
96 for score in [0,1,4,9]:
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
97 device_context.DrawText("%d" % score, x, 355)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
98 x+=184
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
99
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
100
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
101 if self.parent.time_origin:
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
102 device_context.SetPen(wx.BLACK_PEN)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
103 radius = 20
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
104 center_x = 760
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
105 center_y = 147
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106 origin = self.parent.time_origin
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
107 current = time()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
108 limit = self.parent.time_limit
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
109 print "limit:", limit
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
110 total = limit - origin
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
111 left = self.parent.time_left = max(0,limit - current)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
112 device_context.SetBrush(wx.RED_BRUSH if left/total < 1/4.0 else wx.WHITE_BRUSH)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
113 print "left:",left
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
114 if left:
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
115 #we now draw the timer
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
116 print "total - left:", total - left
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
117 angle = ((-2*pi)*((total-left)/total) + (pi/2))
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
118 print "angle:", angle*57.3
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
119 x = center_x + radius * cos(angle)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
120 y = center_y - radius * sin(angle)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
121 print "x: %s, y:%s" % (x, y)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
122 device_context.DrawArc(center_x, center_y-radius, x, y, center_x, center_y)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
123
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
124
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
125
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
126 def onPaint(self, event):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
127 dc = wx.PaintDC(self)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
128 self.fullPaint(dc)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
129
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
130
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
131
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
132 class QuizPanel(wx.Panel):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
133 """This class is used to display the quiz game"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
134
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
135 def __init__(self, parent, referee, players, player_nick):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
136 wx.Panel.__init__(self, parent)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
137 self.time_origin = None #set to unix time when the timer start
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
138 self.time_limit = None
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
139 self.time_left = None
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
140 self.parent = parent
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
141 self.SetMinSize(wx.Size(WIDTH, HEIGHT))
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
142 self.SetSize(wx.Size(WIDTH, HEIGHT))
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
143 self.base = BaseWindow(self)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
144 self.question = wx.TextCtrl(self.base, -1, "", pos=(168,17), size=(613, 94), style=wx.TE_MULTILINE | wx.TE_READONLY)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
145 self.reponse = wx.TextCtrl(self.base, -1, pos=(410,569), size=(342, 21), style=wx.TE_PROCESS_ENTER)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
146 self.parent.host.bridge.quizGameReady(player_nick, referee, profile_key = self.parent.host.profile)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
147 self.state = None
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
148
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
149 def startTimer(self, timer=60):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
150 """Start the timer to answer the question"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
151 def _refresh():
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
152 self.Refresh()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
153 if self.time_left:
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
154 wx.CallLater(1000, _refresh)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
155 self.time_left = timer
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
156 self.time_origin = time()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
157 self.time_limit = self.time_origin + timer
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
158 _refresh()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
159
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
160 def quizGameNew(self, data):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
161 """Start a new game, with given hand"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
162 if data.has_key('instructions'):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
163 self.question.ChangeValue(data['instructions'])
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
164 self.Refresh()
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
165
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
166 def quizGameQuestion(self, question_id, question, timer):
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
167 """Called when a new question is available
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
168 @param question: question to ask"""
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
169 self.question.ChangeValue(question)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
170 self.startTimer(timer)
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
171