Initial commit
[trapthecap.git] / doc / classes / Game.src / M000011.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>
7 <head>
8 <title>new (Game)</title>
9 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10 <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11 </head>
12 <body class="standalone-code">
13 <pre><span class="ruby-comment cmt"># File lib/libttc.rb, line 329</span>
14 <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">players</span> = <span class="ruby-value">6</span>, <span class="ruby-identifier">spokes</span> = <span class="ruby-value">6</span>, <span class="ruby-identifier">spoke_length</span> = <span class="ruby-value">6</span>, <span class="ruby-identifier">arc_length</span> = <span class="ruby-value">6</span>,
15 <span class="ruby-identifier">pieces_each</span> = <span class="ruby-value">6</span>)
16 <span class="ruby-ivar">@board</span> = <span class="ruby-constant">Board</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">spokes</span>, <span class="ruby-identifier">spoke_length</span>, <span class="ruby-identifier">arc_length</span>)
17 <span class="ruby-ivar">@history</span> = []
18 <span class="ruby-ivar">@pieces</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
19 <span class="ruby-ivar">@players</span> = <span class="ruby-keyword kw">case</span>
20 <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">players</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> ; [<span class="ruby-value str">'a'</span>, <span class="ruby-value str">'d'</span>]
21 <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">players</span> <span class="ruby-operator">==</span> <span class="ruby-value">3</span> ; [<span class="ruby-value str">'a'</span>, <span class="ruby-value str">'c'</span>, <span class="ruby-value str">'e'</span>]
22 <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">players</span> <span class="ruby-operator">==</span> <span class="ruby-value">4</span> ; [<span class="ruby-value str">'a'</span>, <span class="ruby-value str">'b'</span>, <span class="ruby-value str">'d'</span>, <span class="ruby-value str">'e'</span>]
23 <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">players</span> <span class="ruby-operator">==</span> <span class="ruby-value">5</span> ; [<span class="ruby-value str">'a'</span>, <span class="ruby-value str">'b'</span>, <span class="ruby-value str">'c'</span>, <span class="ruby-value str">'d'</span>, <span class="ruby-value str">'e'</span>]
24 <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">players</span> <span class="ruby-operator">==</span> <span class="ruby-value">6</span> ; [<span class="ruby-value str">'a'</span>, <span class="ruby-value str">'b'</span>, <span class="ruby-value str">'c'</span>, <span class="ruby-value str">'d'</span>, <span class="ruby-value str">'e'</span>, <span class="ruby-value str">'f'</span>]
25 <span class="ruby-keyword kw">end</span>
26 <span class="ruby-ivar">@current_player</span> = <span class="ruby-value str">'a'</span>
27 <span class="ruby-ivar">@players</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">player</span><span class="ruby-operator">|</span>
28 <span class="ruby-identifier">players_base</span> = <span class="ruby-identifier">board</span>.<span class="ruby-identifier">positions</span>[<span class="ruby-identifier">player</span>]
29 (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">pieces_each</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">count</span><span class="ruby-operator">|</span>
30 <span class="ruby-identifier">piece</span> = <span class="ruby-constant">Piece</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">count</span>, <span class="ruby-identifier">players_base</span>, <span class="ruby-identifier">player</span>)
31 <span class="ruby-ivar">@pieces</span>[<span class="ruby-identifier">player</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">count</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">piece</span>
32 <span class="ruby-keyword kw">end</span>
33 <span class="ruby-keyword kw">end</span>
34 <span class="ruby-keyword kw">end</span></pre>
35 </body>
36 </html>