1 <?xml version="1.0" encoding="iso-8859-1"?>
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
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">
15 function popupCode( url ) {
16 window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
19 function toggleCode( id ) {
20 if ( document.getElementById )
21 elem = document.getElementById( id );
22 else if ( document.all )
23 elem = eval( "document.all." + id );
27 elemStyle = elem.style;
29 if ( elemStyle.display != "block" ) {
30 elemStyle.display = "block"
32 elemStyle.display = "none"
38 // Make codeblocks hidden by default
39 document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
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>
55 <tr class="top-aligned-row">
56 <td><strong>In:</strong></td>
58 <a href="../files/lib/libttc_rb.html">
65 <tr class="top-aligned-row">
66 <td><strong>Parent:</strong></td>
73 <!-- banner header -->
75 <div id="bodyContent">
79 <div id="contextContent">
81 <div id="description">
83 A game of Trap the Cap. It keeps a history of all previous states.
91 <div id="method-list">
92 <h3 class="section-bar">Methods</h3>
94 <div class="name-list">
95 <a href="#M000037">apply_move!</a>
96 <a href="#M000039">apply_moves!</a>
97 <a href="#M000042">build_state_string</a>
98 <a href="#M000036">new</a>
99 <a href="#M000040">next_player!</a>
100 <a href="#M000041">possible_moves</a>
101 <a href="#M000046">read_game</a>
102 <a href="#M000043">show_state</a>
103 <a href="#M000044">to_s</a>
104 <a href="#M000045">to_str</a>
105 <a href="#M000038">undo_move!</a>
120 <div id="attribute-list">
121 <h3 class="section-bar">Attributes</h3>
123 <div class="name-list">
125 <tr class="top-aligned-row context-row">
126 <td class="context-item-name">board</td>
127 <td class="context-item-value"> [R] </td>
128 <td class="context-item-desc"></td>
130 <tr class="top-aligned-row context-row">
131 <td class="context-item-name">current_player</td>
132 <td class="context-item-value"> [R] </td>
133 <td class="context-item-desc"></td>
135 <tr class="top-aligned-row context-row">
136 <td class="context-item-name">history</td>
137 <td class="context-item-value"> [R] </td>
138 <td class="context-item-desc"></td>
140 <tr class="top-aligned-row context-row">
141 <td class="context-item-name">pieces</td>
142 <td class="context-item-value"> [R] </td>
143 <td class="context-item-desc"></td>
145 <tr class="top-aligned-row context-row">
146 <td class="context-item-name">players</td>
147 <td class="context-item-value"> [R] </td>
148 <td class="context-item-desc"></td>
156 <!-- if method_list -->
158 <h3 class="section-bar">Public Class methods</h3>
160 <div id="method-M000036" class="method-detail">
161 <a name="M000036"></a>
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>
170 <div class="method-description">
172 Create a <a href="Game.html#M000036">new</a> game
177 <div id="method-M000046" class="method-detail">
178 <a name="M000046"></a>
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>
187 <div class="method-description">
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
196 <h3 class="section-bar">Public Instance methods</h3>
198 <div id="method-M000037" class="method-detail">
199 <a name="M000037"></a>
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>
208 <div class="method-description">
210 Apply a single move to a game.
215 <div id="method-M000039" class="method-detail">
216 <a name="M000039"></a>
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>
225 <div class="method-description">
227 Apply a list of moves in order
232 <div id="method-M000042" class="method-detail">
233 <a name="M000042"></a>
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>
242 <div class="method-description">
246 <div id="method-M000040" class="method-detail">
247 <a name="M000040"></a>
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>
256 <div class="method-description">
258 Set the current player to be the next player
263 <div id="method-M000041" class="method-detail">
264 <a name="M000041"></a>
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>
273 <div class="method-description">
275 Return an array of all possible moves from this state, given the die roll
276 and the active player
281 <div id="method-M000043" class="method-detail">
282 <a name="M000043"></a>
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>
291 <div class="method-description">
293 Show the state of the board
298 <div id="method-M000044" class="method-detail">
299 <a name="M000044"></a>
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>
308 <div class="method-description">
312 <div id="method-M000045" class="method-detail">
313 <a name="M000045"></a>
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>
322 <div class="method-description">
326 <div id="method-M000038" class="method-detail">
327 <a name="M000038"></a>
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>
336 <div class="method-description">
350 <div id="validator-badges">
351 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>