-
Notifications
You must be signed in to change notification settings - Fork 0
/
games.html
549 lines (539 loc) · 27.3 KB
/
games.html
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Game API — Playhouse 0.1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Playhouse 0.1 documentation" href="index.html" />
<link rel="up" title="Web server" href="frontend.html" />
<link rel="next" title="Animations" href="animations.html" />
<link rel="prev" title="Configuration" href="configuration.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="http-routingtable.html" title="HTTP Routing Table"
>routing table</a> |</li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="animations.html" title="Animations"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="configuration.html" title="Configuration"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Playhouse 0.1 documentation</a> »</li>
<li><a href="frontend.html" accesskey="U">Web server</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="game-api">
<span id="gameapi"></span><h1>Game API<a class="headerlink" href="#game-api" title="Permalink to this headline">¶</a></h1>
<p>This documentation gives an overview of how to use the game API (lightgames.py) in order to create a Playhouse game.</p>
<p>Creating a game consists of subclassing the lightgames.Game class, as well as creating template files for the game and its corresponding configuration. For a game ‘yourgame’, the relevant files relative to the repository root are detailed below.</p>
<div class="highlight-py3"><div class="highlight"><pre>─ src
├── games
│ └── yourgame.py
└── lightgames.py
─ static
├── game-base.css
└── game-base.js
─ templates
├── config
│ ├── baseconfig.html
│ └── yourgameconfig.html
└── game
├── base.html
└── yourgame.html
</pre></div>
</div>
<p>The file <tt class="docutils literal"><span class="pre">lightgames.py</span></tt> contains most of the API functions that you will be
interacting with, a well as the class that your game extends. The files
<tt class="docutils literal"><span class="pre">game-base.css</span></tt> and <tt class="docutils literal"><span class="pre">game-base.js</span></tt> contain the CSS and JavaScript code shared
between all games, and are included by the <tt class="docutils literal"><span class="pre">base.html</span></tt> template. The files
<tt class="docutils literal"><span class="pre">base.html</span></tt> and <tt class="docutils literal"><span class="pre">baseconfig.html</span></tt> contain the base HTML outline that all games’
templates (and their respective configuration templates) extend. You don’t
have to edit these files, but may want to inspect them to learn more about how
they work and what functionality they provide.</p>
<div class="section" id="lifetime-of-a-game">
<h2>Lifetime of a game<a class="headerlink" href="#lifetime-of-a-game" title="Permalink to this headline">¶</a></h2>
<p>Your core game class, as previously mentioned, should extend the
<tt class="docutils literal"><span class="pre">lightgames.Game</span> <span class="pre">class</span></tt>. The actual game logic is implemented by overriding
appropriate methods invoked by the rest of the game infrastructure (i.e. the
webserver) when appropriate events happen. This section documents what these
events are, and when they are called.</p>
<p>The <tt class="docutils literal"><span class="pre">Game</span></tt> class itself maintains a set of handlers corresponding to connected clients, so that each game doesn’t have to do that manually.</p>
<div class="section" id="setup-undoing-setup">
<h3>Setup & undoing setup<a class="headerlink" href="#setup-undoing-setup" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">init(self)</span></tt></dt>
<dd><p class="first last">When the game instance is instantiated, its <tt class="docutils literal"><span class="pre">init</span></tt> method is invoked. Add
initialization code for setting up a game instance here. The default
implementation provided by the <tt class="docutils literal"><span class="pre">Game</span></tt> class simply invokes <tt class="docutils literal"><span class="pre">reset</span></tt>.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">reset(self)</span></tt></dt>
<dd><p class="first last">Each time the state of a game object should be reset, its <tt class="docutils literal"><span class="pre">reset</span></tt> method
is invoked. Note that the same instance is re-used for multiple game
sessions. This method is invoked after a game is completed, when options
are changed, etc.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">destroy(self)</span></tt></dt>
<dd><p class="first last">Invoked when this game instance is about to be unloaded, and won’t ever be
re-used. The default implementation notifies all connected users that the
game was destroyed.</p>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="game-implementation">
<h3>Game implementation<a class="headerlink" href="#game-implementation" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">on_message(self,</span> <span class="pre">handler,</span> <span class="pre">message)</span></tt></dt>
<dd><p class="first last">This is the most important method for the purpose of implementing a game.
Invoked each time the game receives a JSON message from a client.
<tt class="docutils literal"><span class="pre">message</span></tt> is the parsed JSON message (as a Dict/List/...) object.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">sync(self,</span> <span class="pre">handler)</span></tt></dt>
<dd><p class="first last">The idea that this method syncs the current state of the game with the
given client (<tt class="docutils literal"><span class="pre">handler</span></tt>). See also the <tt class="docutils literal"><span class="pre">sync_all</span></tt> utility function.</p>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="metadata">
<h3>Metadata<a class="headerlink" href="#metadata" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">set_options(self,</span> <span class="pre">config)</span></tt></dt>
<dd><p class="first last">Invoked when the game options were updated, with a new configuration (as a
dict mapping option-name keys to strings). The game should update its
internal state to take these new options into account, and reset the game.
May return a string, which is then interpreted as an error message
indicating a bad configuration.</p>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="class-variables">
<h3>Class variables<a class="headerlink" href="#class-variables" title="Permalink to this headline">¶</a></h3>
<p>Furthermore, some class variables are defined in <tt class="docutils literal"><span class="pre">lightgames.Game</span></tt> that the
game overrides in order to choose template files and template interpolation
variables to be used when rendering the game. These are:</p>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">config_file</span></tt>:</dt>
<dd><p class="first last">the template file used for configuration (relative to <tt class="docutils literal"><span class="pre">templates/config</span></tt>)</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">template_file</span></tt>:</dt>
<dd><p class="first last">the template file used for the game (relative to <tt class="docutils literal"><span class="pre">templates/game</span></tt>)</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">template_vars</span></tt>:</dt>
<dd><p class="first last">options used for both the templates above.</p>
</dd>
</dl>
</li>
</ul>
</div>
</div>
<div class="section" id="utility-functions">
<h2>Utility functions<a class="headerlink" href="#utility-functions" title="Permalink to this headline">¶</a></h2>
<p>The utility functions provided by the API is split into two groups: methods defined
in the <tt class="docutils literal"><span class="pre">Game</span></tt> class, and static functions provided directly on the <tt class="docutils literal"><span class="pre">lightgames</span></tt> module.</p>
<div class="section" id="lamp-related-methods-methods-on-game">
<h3>Lamp-related methods (methods on <tt class="docutils literal"><span class="pre">Game</span></tt>)<a class="headerlink" href="#lamp-related-methods-methods-on-game" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">send_lamp(self,</span> <span class="pre">x,</span> <span class="pre">y,</span> <span class="pre">change)</span></tt>:</dt>
<dd><p class="first last">perform a lamp change on a single lamp or on all lamps (see lamp API
documentation for an explanation of <tt class="docutils literal"><span class="pre">change</span></tt>).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">send_lamp_all(self,</span> <span class="pre">change)</span></tt>:</dt>
<dd><p class="first last">perform a lamp change on all lamps.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">send_lamp_multi(self,</span> <span class="pre">changes)</span></tt>:</dt>
<dd><p class="first last">performs a set of changes in one batch, see a <tt class="docutils literal"><span class="pre">send_lamp</span></tt> above.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">reset_lamp_all(self)</span></tt>:</dt>
<dd><p class="first last">enables all lamps, but sets them to display “black”, i.e. set all lamps
to a soft-off state. You probably want to invoke this in <tt class="docutils literal"><span class="pre">init</span></tt> or
<tt class="docutils literal"><span class="pre">reset</span></tt> to prepare all lamps.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">send_lamp_animation(self,</span> <span class="pre">coords,</span> <span class="pre">change,</span> <span class="pre">callback=None,</span> <span class="pre">revert=False)</span></tt>:</dt>
<dd><p class="first last">performs a “line” animation by performing <tt class="docutils literal"><span class="pre">change</span></tt> to the lamps in
positions <tt class="docutils literal"><span class="pre">coords</span></tt> one at a time in an animated fashion. If <tt class="docutils literal"><span class="pre">revert</span></tt> is
set, turn off the lamps similarly with a slight delay, to simulate
movement. If <tt class="docutils literal"><span class="pre">callback</span></tt> is given, call it after the whole animation has
completed.</p>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="utility-methods-methods-on-game">
<h3>Utility methods (methods on <tt class="docutils literal"><span class="pre">Game</span></tt>)<a class="headerlink" href="#utility-methods-methods-on-game" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">sync_all(self)</span></tt>:</dt>
<dd><p class="first last">sync all connected handlers by invoking <tt class="docutils literal"><span class="pre">sync</span></tt> on each of them.</p>
</dd>
</dl>
</li>
</ul>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">get_spectators(self)</span></tt>:</dt>
<dd><p class="first last">generator for iterating over spectators.</p>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="utility-functions-functions-on-lightgames">
<h3>Utility functions (functions on <tt class="docutils literal"><span class="pre">lightgames</span></tt>)<a class="headerlink" href="#utility-functions-functions-on-lightgames" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">send_msg(handler,</span> <span class="pre">msg)</span></tt>:</dt>
<dd><p class="first last">send a single message to a single connected client.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">send_msgs(handlers,</span> <span class="pre">msg)</span></tt>:</dt>
<dd><p class="first last">send a single message to a set of clients (<tt class="docutils literal"><span class="pre">handlers</span></tt> is an arbitrary
iterator).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">send_msgs_animation(handlers,</span> <span class="pre">coords,</span> <span class="pre">message,</span> <span class="pre">callback=None,</span> <span class="pre">revert=False)</span></tt>:</dt>
<dd><p class="first last">corresponds to <tt class="docutils literal"><span class="pre">send_lamp_animation</span></tt> but for updating a set of clients.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">set_timeout(deadline,</span> <span class="pre">callback)</span></tt>:</dt>
<dd><p class="first last">call <tt class="docutils literal"><span class="pre">callback</span></tt> after delay <tt class="docutils literal"><span class="pre">deadline</span></tt>. Thin wrapper around Tornado’s
<tt class="docutils literal"><span class="pre">ioloop.add_timeout</span></tt>.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">get_grid_size()</span></tt>:</dt>
<dd><p class="first last">returns the size of the grid as setup in configuration/as defined by
available hardware. Usable by games in order to adjust themselves to
available lamps.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">rgb_to_xyz(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></tt>:</dt>
<dd><p class="first last">performs conversion from the RGB to the xyZ colour space.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">rgb_to_hue(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></tt>:</dt>
<dd><p class="first last">performs conversion from the RGB to the HSL colour space (but only the
hue channel).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">parse_color(color)</span></tt>:</dt>
<dd><p class="first last">parses a hexadecimal RGB colour (i.e. ‘#FF0000’) into a triple <tt class="docutils literal"><span class="pre">(r,g,b)</span></tt>.</p>
</dd>
</dl>
</li>
</ul>
</div>
</div>
<div class="section" id="simplegame">
<h2>SimpleGame<a class="headerlink" href="#simplegame" title="Permalink to this headline">¶</a></h2>
<p><tt class="docutils literal"><span class="pre">simplegame.SimpleGame</span></tt> is a module extending <tt class="docutils literal"><span class="pre">lightgames.Game</span></tt>. It is meant to
be used for turnbased games for two players. The players may have a color, a score,
and a timelimit.</p>
<p>Examples of <tt class="docutils literal"><span class="pre">SimpleGame</span></tt> are <tt class="docutils literal"><span class="pre">mnk-game</span> <span class="pre">(Tic-tac-toe)</span></tt>, <tt class="docutils literal"><span class="pre">Othello</span></tt>, and <tt class="docutils literal"><span class="pre">Connect4</span></tt>.</p>
<p>The timelimit was implemented so that players could not stall and grief by entering
and then not play. The amount of exceeded timelimits is saved, and when one player
has exceeded three times in a row, they are both kicked and new players are
fetched.</p>
<div class="highlight-py3"><div class="highlight"><pre>─ src
├── games
│ └── yourgame.py
├── lightgames.py
└── simplegame.py
─ static
├── game-base.css
└── game-base.js
─ templates
├── config
│ ├── baseconfig.html
│ ├── simplebaseconfig.html
│ └── yourgameconfig.html
└── game
├── base.html
├── simplegamebase.html
└── yourgame.html
</pre></div>
</div>
<div class="section" id="template">
<span id="id1"></span><h3>Template<a class="headerlink" href="#template" title="Permalink to this headline">¶</a></h3>
<p>The <tt class="docutils literal"><span class="pre">template_vars</span></tt> is expanded with the values and will be shown to the clients.</p>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">timelimit</span></tt></dt>
<dd><p class="first last">The time, in seconds, each player has to make their turn.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">color_1</span></tt></dt>
<dd><p class="first last">The color of player one.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">color_2</span></tt></dt>
<dd><p class="first last">The color of player two.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">score_1</span></tt></dt>
<dd><p class="first last">The score of player one.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">score_2</span></tt></dt>
<dd><p class="first last">The score of player two.</p>
</dd>
</dl>
</li>
</ul>
<p>To disable a feature, set the value to <tt class="docutils literal"><span class="pre">None</span></tt> in your game.</p>
</div>
<div class="section" id="utility-methods-methods-on-simplegame">
<h3>Utility methods (methods on <tt class="docutils literal"><span class="pre">SimpleGame</span></tt>)<a class="headerlink" href="#utility-methods-methods-on-simplegame" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">init(self)</span></tt></dt>
<dd><p class="first last">Adds the <tt class="docutils literal"><span class="pre">template_vars</span></tt> mentioned in <a class="reference internal" href="#template"><em>Template</em></a>.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">reset(self)</span></tt></dt>
<dd><p class="first last">Sets up everything with timelimits, turn indications, etc. If you override this, you likely want to invoke this method manually.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">sync_turn(self,</span> <span class="pre">handler)</span></tt></dt>
<dd><p class="first last">Syncs turn-data (timelimit, score, current turn). If you override this, you likely want to invoke this method manually.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">correct_player(self,</span> <span class="pre">handler)</span></tt></dt>
<dd><p class="first last">Checks if this handler corresponds with the current player. Returns True if that is the case, or sends an error to the client otherwise.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">turnover(self,</span> <span class="pre">to_player=None)</span></tt></dt>
<dd><p class="first last">Changes the turn to <tt class="docutils literal"><span class="pre">to_player</span></tt> if specifed, otherwise it will change the player to the opponent. If the timelimit was paused, this method will start it again.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">pause_turn(self)</span></tt></dt>
<dd><p class="first last">Tells the clients to pause the timelimit counter. Should be used when doing animations.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">unpause_turn(self)</span></tt></dt>
<dd><p class="first last">Tells the clients to start the timelimit counter again.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">timelimit_counter(self)</span></tt></dt>
<dd><p class="first last">A serverside counter of how many seconds left. Is sent to the client when they connect. Should not be overridden.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">timelimit_exceeded(self)</span></tt></dt>
<dd><p class="first last">The timelimit given to the player has exceeded. This function counts the number of timelimits exceeded by each player, and resets the game when one have exceeded three times in a row.</p>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="utility-functions-functions-on-simplegame">
<h3>Utility functions (functions on <tt class="docutils literal"><span class="pre">simplegame</span></tt>)<a class="headerlink" href="#utility-functions-functions-on-simplegame" title="Permalink to this headline">¶</a></h3>
<ul>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">reply_wrong_player(game,</span> <span class="pre">handler)</span></tt>:</dt>
<dd><p class="first last">complains to the given player that it shouldn’t perform a move right
now. Defined as a utility function since it is a very common operation
for games to need.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><tt class="docutils literal"><span class="pre">game_over(game,</span> <span class="pre">winnerH,</span> <span class="pre">coords=frozenset())</span></tt>:</dt>
<dd><p class="first last">perform a game over with the given handler <tt class="docutils literal"><span class="pre">winnerH</span></tt> as the winner, and
the set of lamps <tt class="docutils literal"><span class="pre">coords</span></tt> as the winning lamps. Notifies users about
who won the game, plays a victory animation with <tt class="docutils literal"><span class="pre">coords</span></tt>, and then
reset the game via <tt class="docutils literal"><span class="pre">reset</span></tt>.</p>
</dd>
</dl>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Game API</a><ul>
<li><a class="reference internal" href="#lifetime-of-a-game">Lifetime of a game</a><ul>
<li><a class="reference internal" href="#setup-undoing-setup">Setup & undoing setup</a></li>
<li><a class="reference internal" href="#game-implementation">Game implementation</a></li>
<li><a class="reference internal" href="#metadata">Metadata</a></li>
<li><a class="reference internal" href="#class-variables">Class variables</a></li>
</ul>
</li>
<li><a class="reference internal" href="#utility-functions">Utility functions</a><ul>
<li><a class="reference internal" href="#lamp-related-methods-methods-on-game">Lamp-related methods (methods on <tt class="docutils literal"><span class="pre">Game</span></tt>)</a></li>
<li><a class="reference internal" href="#utility-methods-methods-on-game">Utility methods (methods on <tt class="docutils literal"><span class="pre">Game</span></tt>)</a></li>
<li><a class="reference internal" href="#utility-functions-functions-on-lightgames">Utility functions (functions on <tt class="docutils literal"><span class="pre">lightgames</span></tt>)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#simplegame">SimpleGame</a><ul>
<li><a class="reference internal" href="#template">Template</a></li>
<li><a class="reference internal" href="#utility-methods-methods-on-simplegame">Utility methods (methods on <tt class="docutils literal"><span class="pre">SimpleGame</span></tt>)</a></li>
<li><a class="reference internal" href="#utility-functions-functions-on-simplegame">Utility functions (functions on <tt class="docutils literal"><span class="pre">simplegame</span></tt>)</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="configuration.html"
title="previous chapter">Configuration</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="animations.html"
title="next chapter">Animations</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/games.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="http-routingtable.html" title="HTTP Routing Table"
>routing table</a> |</li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="animations.html" title="Animations"
>next</a> |</li>
<li class="right" >
<a href="configuration.html" title="Configuration"
>previous</a> |</li>
<li><a href="index.html">Playhouse 0.1 documentation</a> »</li>
<li><a href="frontend.html" >Web server</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2014, John Eriksson, Arvid Fahlström Myrman, Jonas Höglund, Hannes Leskelä, Christian Lidström, Mattias Palo, Markus Videll, Tomas Wickman, Emil Öhman.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>