Initial commit
[trapthecap.git] / doc / classes / Game.html
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <title>Class: Game</title>
9 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10 <meta http-equiv="Content-Script-Type" content="text/javascript" />
11 <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12 <script type="text/javascript">
13 // <![CDATA[
14
15 function popupCode( url ) {
16 window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17 }
18
19 function toggleCode( id ) {
20 if ( document.getElementById )
21 elem = document.getElementById( id );
22 else if ( document.all )
23 elem = eval( "document.all." + id );
24 else
25 return false;
26
27 elemStyle = elem.style;
28
29 if ( elemStyle.display != "block" ) {
30 elemStyle.display = "block"
31 } else {
32 elemStyle.display = "none"
33 }
34
35 return true;
36 }
37
38 // Make codeblocks hidden by default
39 document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
41 // ]]>
42 </script>
43
44 </head>
45 <body>
46
47
48
49 <div id="classHeader">
50 <table class="header-table">
51 <tr class="top-aligned-row">
52 <td><strong>Class</strong></td>
53 <td class="class-name-in-header">Game</td>
54 </tr>
55 <tr class="top-aligned-row">
56 <td><strong>In:</strong></td>
57 <td>
58 <a href="../files/lib/libttc_rb.html">
59 lib/libttc.rb
60 </a>
61 <br />
62 </td>
63 </tr>
64
65 <tr class="top-aligned-row">
66 <td><strong>Parent:</strong></td>
67 <td>
68 Object
69 </td>
70 </tr>
71 </table>
72 </div>
73 <!-- banner header -->
74
75 <div id="bodyContent">
76
77
78
79 <div id="contextContent">
80
81 <div id="description">
82 <p>
83 A game of Trap the Cap. It keeps a history of all previous states.
84 </p>
85
86 </div>
87
88
89 </div>
90
91 <div id="method-list">
92 <h3 class="section-bar">Methods</h3>
93
94 <div class="name-list">
95 <a href="#M000037">apply_move!</a>&nbsp;&nbsp;
96 <a href="#M000039">apply_moves!</a>&nbsp;&nbsp;
97 <a href="#M000042">build_state_string</a>&nbsp;&nbsp;
98 <a href="#M000036">new</a>&nbsp;&nbsp;
99 <a href="#M000040">next_player!</a>&nbsp;&nbsp;
100 <a href="#M000041">possible_moves</a>&nbsp;&nbsp;
101 <a href="#M000046">read_game</a>&nbsp;&nbsp;
102 <a href="#M000043">show_state</a>&nbsp;&nbsp;
103 <a href="#M000044">to_s</a>&nbsp;&nbsp;
104 <a href="#M000045">to_str</a>&nbsp;&nbsp;
105 <a href="#M000038">undo_move!</a>&nbsp;&nbsp;
106 </div>
107 </div>
108
109 </div>
110
111
112 <!-- if includes -->
113
114 <div id="section">
115
116
117
118
119
120 <div id="attribute-list">
121 <h3 class="section-bar">Attributes</h3>
122
123 <div class="name-list">
124 <table>
125 <tr class="top-aligned-row context-row">
126 <td class="context-item-name">board</td>
127 <td class="context-item-value">&nbsp;[R]&nbsp;</td>
128 <td class="context-item-desc"></td>
129 </tr>
130 <tr class="top-aligned-row context-row">
131 <td class="context-item-name">current_player</td>
132 <td class="context-item-value">&nbsp;[R]&nbsp;</td>
133 <td class="context-item-desc"></td>
134 </tr>
135 <tr class="top-aligned-row context-row">
136 <td class="context-item-name">history</td>
137 <td class="context-item-value">&nbsp;[R]&nbsp;</td>
138 <td class="context-item-desc"></td>
139 </tr>
140 <tr class="top-aligned-row context-row">
141 <td class="context-item-name">pieces</td>
142 <td class="context-item-value">&nbsp;[R]&nbsp;</td>
143 <td class="context-item-desc"></td>
144 </tr>
145 <tr class="top-aligned-row context-row">
146 <td class="context-item-name">players</td>
147 <td class="context-item-value">&nbsp;[R]&nbsp;</td>
148 <td class="context-item-desc"></td>
149 </tr>
150 </table>
151 </div>
152 </div>
153
154
155
156 <!-- if method_list -->
157 <div id="methods">
158 <h3 class="section-bar">Public Class methods</h3>
159
160 <div id="method-M000036" class="method-detail">
161 <a name="M000036"></a>
162
163 <div class="method-heading">
164 <a href="Game.src/M000036.html" target="Code" class="method-signature"
165 onclick="popupCode('Game.src/M000036.html');return false;">
166 <span class="method-name">new</span><span class="method-args">(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, pieces_each = 6)</span>
167 </a>
168 </div>
169
170 <div class="method-description">
171 <p>
172 Create a <a href="Game.html#M000036">new</a> game
173 </p>
174 </div>
175 </div>
176
177 <div id="method-M000046" class="method-detail">
178 <a name="M000046"></a>
179
180 <div class="method-heading">
181 <a href="Game.src/M000046.html" target="Code" class="method-signature"
182 onclick="popupCode('Game.src/M000046.html');return false;">
183 <span class="method-name">read_game</span><span class="method-args">(gamelines)</span>
184 </a>
185 </div>
186
187 <div class="method-description">
188 <p>
189 Given a set of lines from an input file, turn them into a <a
190 href="Game.html">Game</a> object and a set of <a href="Move.html">Move</a>
191 objects. Note the multiple return values. Class method
192 </p>
193 </div>
194 </div>
195
196 <h3 class="section-bar">Public Instance methods</h3>
197
198 <div id="method-M000037" class="method-detail">
199 <a name="M000037"></a>
200
201 <div class="method-heading">
202 <a href="Game.src/M000037.html" target="Code" class="method-signature"
203 onclick="popupCode('Game.src/M000037.html');return false;">
204 <span class="method-name">apply_move!</span><span class="method-args">(move, player = @current_player)</span>
205 </a>
206 </div>
207
208 <div class="method-description">
209 <p>
210 Apply a single move to a game.
211 </p>
212 </div>
213 </div>
214
215 <div id="method-M000039" class="method-detail">
216 <a name="M000039"></a>
217
218 <div class="method-heading">
219 <a href="Game.src/M000039.html" target="Code" class="method-signature"
220 onclick="popupCode('Game.src/M000039.html');return false;">
221 <span class="method-name">apply_moves!</span><span class="method-args">(moves)</span>
222 </a>
223 </div>
224
225 <div class="method-description">
226 <p>
227 Apply a list of moves in order
228 </p>
229 </div>
230 </div>
231
232 <div id="method-M000042" class="method-detail">
233 <a name="M000042"></a>
234
235 <div class="method-heading">
236 <a href="Game.src/M000042.html" target="Code" class="method-signature"
237 onclick="popupCode('Game.src/M000042.html');return false;">
238 <span class="method-name">build_state_string</span><span class="method-args">()</span>
239 </a>
240 </div>
241
242 <div class="method-description">
243 </div>
244 </div>
245
246 <div id="method-M000040" class="method-detail">
247 <a name="M000040"></a>
248
249 <div class="method-heading">
250 <a href="Game.src/M000040.html" target="Code" class="method-signature"
251 onclick="popupCode('Game.src/M000040.html');return false;">
252 <span class="method-name">next_player!</span><span class="method-args">()</span>
253 </a>
254 </div>
255
256 <div class="method-description">
257 <p>
258 Set the current player to be the next player
259 </p>
260 </div>
261 </div>
262
263 <div id="method-M000041" class="method-detail">
264 <a name="M000041"></a>
265
266 <div class="method-heading">
267 <a href="Game.src/M000041.html" target="Code" class="method-signature"
268 onclick="popupCode('Game.src/M000041.html');return false;">
269 <span class="method-name">possible_moves</span><span class="method-args">(die_result, player = @current_player)</span>
270 </a>
271 </div>
272
273 <div class="method-description">
274 <p>
275 Return an array of all possible moves from this state, given the die roll
276 and the active player
277 </p>
278 </div>
279 </div>
280
281 <div id="method-M000043" class="method-detail">
282 <a name="M000043"></a>
283
284 <div class="method-heading">
285 <a href="Game.src/M000043.html" target="Code" class="method-signature"
286 onclick="popupCode('Game.src/M000043.html');return false;">
287 <span class="method-name">show_state</span><span class="method-args">()</span>
288 </a>
289 </div>
290
291 <div class="method-description">
292 <p>
293 Show the state of the board
294 </p>
295 </div>
296 </div>
297
298 <div id="method-M000044" class="method-detail">
299 <a name="M000044"></a>
300
301 <div class="method-heading">
302 <a href="Game.src/M000044.html" target="Code" class="method-signature"
303 onclick="popupCode('Game.src/M000044.html');return false;">
304 <span class="method-name">to_s</span><span class="method-args">()</span>
305 </a>
306 </div>
307
308 <div class="method-description">
309 </div>
310 </div>
311
312 <div id="method-M000045" class="method-detail">
313 <a name="M000045"></a>
314
315 <div class="method-heading">
316 <a href="Game.src/M000045.html" target="Code" class="method-signature"
317 onclick="popupCode('Game.src/M000045.html');return false;">
318 <span class="method-name">to_str</span><span class="method-args">()</span>
319 </a>
320 </div>
321
322 <div class="method-description">
323 </div>
324 </div>
325
326 <div id="method-M000038" class="method-detail">
327 <a name="M000038"></a>
328
329 <div class="method-heading">
330 <a href="Game.src/M000038.html" target="Code" class="method-signature"
331 onclick="popupCode('Game.src/M000038.html');return false;">
332 <span class="method-name">undo_move!</span><span class="method-args">()</span>
333 </a>
334 </div>
335
336 <div class="method-description">
337 <p>
338 Undo a move
339 </p>
340 </div>
341 </div>
342
343
344 </div>
345
346
347 </div>
348
349
350 <div id="validator-badges">
351 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
352 </div>
353
354 </body>
355 </html>