This commit is contained in:
Sarsoo 2021-07-09 21:31:30 +00:00
parent f440a60a92
commit 067e9d2fe1
8 changed files with 24 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Top-level object for managing [`Board`]s, applying and managing turns"><meta name="keywords" content="rust, rustlang, rust-lang, game"><title>draught::game - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><script src="../../crates.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../draught/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module game</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../index.html">draught</a></p><div id="sidebar-vars" data-name="game" data-ty="mod" data-relpath="../"></div><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" class="help-button">?</button>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">draught</a>::<wbr><a class="mod" href="">game</a><button id="copy-path" onclick="copy_path(this)"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../src/draught/game/mod.rs.html#1-143" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Top-level object for managing <a href="../board/struct.Board.html" title="Board"><code>Board</code></a>s, applying and managing turns</p>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">draught</a>::<wbr><a class="mod" href="">game</a><button id="copy-path" onclick="copy_path(this)"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../src/draught/game/mod.rs.html#1-145" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Top-level object for managing <a href="../board/struct.Board.html" title="Board"><code>Board</code></a>s, applying and managing turns</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.Game.html" title="draught::game::Game struct">Game</a></td><td class="docblock-short"><p>Root-level structure for managing the game as a collection of board states</p>
</td></tr></table></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="draught" data-search-index-js="../../search-index.js" data-search-js="../../search.js"></div>

View File

@ -9,16 +9,16 @@
</div><h2 id="fields" class="fields small-section-header">
Fields<a href="#fields" class="anchor"></a></h2><span id="structfield.current" class="structfield small-section-header"><a href="#structfield.current" class="anchor field"></a><code>current: <a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a></code></span><span id="structfield.previous_boards" class="structfield small-section-header"><a href="#structfield.previous_boards" class="anchor field"></a><code>previous_boards: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a>&gt;</code></span><span id="structfield.painter" class="structfield small-section-header"><a href="#structfield.painter" class="anchor field"></a><code>painter: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../paint/struct.Painter.html" title="struct draught::paint::Painter">Painter</a>&gt;</code></span><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#30-40" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.previous_board" class="method"><code>pub fn <a href="#method.previous_board" class="fnname">previous_board</a>(&amp;self, turn: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; &amp;<a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a></code><a href="#method.previous_board" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#32-34" title="goto source code">[src]</a></h4><div class="docblock"><p>Get a read-only copy of a previous turns board</p>
</div><h4 id="method.current_board" class="method"><code>pub fn <a href="#method.current_board" class="fnname">current_board</a>(&amp;self) -&gt; &amp;<a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a></code><a href="#method.current_board" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#37-39" title="goto source code">[src]</a></h4><div class="docblock"><p>Set current board to given</p>
</div></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-1" class="impl"><code class="in-band">impl <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl-1" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#43-137" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.current_board_cells" class="method"><code>pub fn <a href="#method.current_board_cells" class="fnname">current_board_cells</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*const </a><a class="struct" href="../board/struct.Square.html" title="struct draught::board::Square">Square</a></code><a href="#method.current_board_cells" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#45-47" title="goto source code">[src]</a></h4><div class="docblock"><p>Get pointer to current boards squares</p>
</div></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-1" class="impl"><code class="in-band">impl <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl-1" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#43-139" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.current_board_cells" class="method"><code>pub fn <a href="#method.current_board_cells" class="fnname">current_board_cells</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*const </a><a class="struct" href="../board/struct.Square.html" title="struct draught::board::Square">Square</a></code><a href="#method.current_board_cells" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#45-47" title="goto source code">[src]</a></h4><div class="docblock"><p>Get pointer to current boards squares</p>
</div><h4 id="method.current_board_len" class="method"><code>pub fn <a href="#method.current_board_len" class="fnname">current_board_len</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a href="#method.current_board_len" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#50-52" title="goto source code">[src]</a></h4><div class="docblock"><p>Get pointer to current boards squares</p>
</div><h4 id="method.current_turn" class="method"><code>pub fn <a href="#method.current_turn" class="fnname">current_turn</a>(&amp;self) -&gt; <a class="enum" href="../board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#method.current_turn" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#55-57" title="goto source code">[src]</a></h4><div class="docblock"><p>Current turns team</p>
</div><h4 id="method.make_move" class="method"><code>pub fn <a href="#method.make_move" class="fnname">make_move</a>(&amp;mut self, from: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>, to: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>)</code><a href="#method.make_move" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#60-79" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempt to make a move given a source and destination index</p>
</div><h4 id="method.execute_move" class="method"><code>pub fn <a href="#method.execute_move" class="fnname">execute_move</a>(&amp;mut self, from: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>, to: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>)</code><a href="#method.execute_move" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#82-85" title="goto source code">[src]</a></h4><div class="docblock"><p>Update board state with given move and push new board into current state</p>
</div><h4 id="method.execute_jump" class="method"><code>pub fn <a href="#method.execute_jump" class="fnname">execute_jump</a>(&amp;mut self, from: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>, to: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>)</code><a href="#method.execute_jump" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#88-91" title="goto source code">[src]</a></h4><div class="docblock"><p>Update board state with given jump move and push new board into current state</p>
</div><h4 id="method.push_new_board" class="method"><code>pub fn <a href="#method.push_new_board" class="fnname">push_new_board</a>(&amp;mut self, board: <a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a>)</code><a href="#method.push_new_board" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#94-97" title="goto source code">[src]</a></h4><div class="docblock"><p>Push current board into the previous turns and set given board to current</p>
</div><h4 id="method.set_current" class="method"><code>pub fn <a href="#method.set_current" class="fnname">set_current</a>(&amp;mut self, board: <a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a>)</code><a href="#method.set_current" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#100-102" title="goto source code">[src]</a></h4><div class="docblock"><p>Set current board to given</p>
</div><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;height: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;piece_rows: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;first_turn: <a class="enum" href="../board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a><br>) -&gt; <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#method.new" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#105-113" title="goto source code">[src]</a></h4><h4 id="method.new_with_canvas" class="method"><code>pub fn <a href="#method.new_with_canvas" class="fnname">new_with_canvas</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;height: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;piece_rows: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;first_turn: <a class="enum" href="../board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;canvas_id: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;canvas_width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;canvas_height: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -&gt; <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#method.new_with_canvas" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#115-125" title="goto source code">[src]</a></h4><h4 id="method.set_painter" class="method"><code>pub fn <a href="#method.set_painter" class="fnname">set_painter</a>(&amp;mut self, value: <a class="struct" href="../paint/struct.Painter.html" title="struct draught::paint::Painter">Painter</a>)</code><a href="#method.set_painter" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#127-129" title="goto source code">[src]</a></h4><h4 id="method.draw" class="method"><code>pub fn <a href="#method.draw" class="fnname">draw</a>(&amp;self)</code><a href="#method.draw" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#131-136" title="goto source code">[src]</a></h4></div></details><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#23" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.fmt" class="method hidden trait-impl"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a href="#method.fmt" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#23" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#139-143" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.fmt-1" class="method hidden trait-impl"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a href="#method.fmt-1" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#140-142" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div><h4 id="method.make_move" class="method"><code>pub fn <a href="#method.make_move" class="fnname">make_move</a>(&amp;mut self, from: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>, to: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>) -&gt; <a class="enum" href="../board/enums/enum.Moveable.html" title="enum draught::board::enums::Moveable">Moveable</a></code><a href="#method.make_move" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#60-81" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempt to make a move given a source and destination index</p>
</div><h4 id="method.execute_move" class="method"><code>pub fn <a href="#method.execute_move" class="fnname">execute_move</a>(&amp;mut self, from: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>, to: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>)</code><a href="#method.execute_move" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#84-87" title="goto source code">[src]</a></h4><div class="docblock"><p>Update board state with given move and push new board into current state</p>
</div><h4 id="method.execute_jump" class="method"><code>pub fn <a href="#method.execute_jump" class="fnname">execute_jump</a>(&amp;mut self, from: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>, to: <a class="struct" href="../board/struct.BrdIdx.html" title="struct draught::board::BrdIdx">BrdIdx</a>)</code><a href="#method.execute_jump" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#90-93" title="goto source code">[src]</a></h4><div class="docblock"><p>Update board state with given jump move and push new board into current state</p>
</div><h4 id="method.push_new_board" class="method"><code>pub fn <a href="#method.push_new_board" class="fnname">push_new_board</a>(&amp;mut self, board: <a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a>)</code><a href="#method.push_new_board" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#96-99" title="goto source code">[src]</a></h4><div class="docblock"><p>Push current board into the previous turns and set given board to current</p>
</div><h4 id="method.set_current" class="method"><code>pub fn <a href="#method.set_current" class="fnname">set_current</a>(&amp;mut self, board: <a class="struct" href="../board/struct.Board.html" title="struct draught::board::Board">Board</a>)</code><a href="#method.set_current" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#102-104" title="goto source code">[src]</a></h4><div class="docblock"><p>Set current board to given</p>
</div><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;height: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;piece_rows: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;first_turn: <a class="enum" href="../board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a><br>) -&gt; <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#method.new" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#107-115" title="goto source code">[src]</a></h4><h4 id="method.new_with_canvas" class="method"><code>pub fn <a href="#method.new_with_canvas" class="fnname">new_with_canvas</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;height: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;piece_rows: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;first_turn: <a class="enum" href="../board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;canvas_id: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;canvas_width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;canvas_height: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -&gt; <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#method.new_with_canvas" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#117-127" title="goto source code">[src]</a></h4><h4 id="method.set_painter" class="method"><code>pub fn <a href="#method.set_painter" class="fnname">set_painter</a>(&amp;mut self, value: <a class="struct" href="../paint/struct.Painter.html" title="struct draught::paint::Painter">Painter</a>)</code><a href="#method.set_painter" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#129-131" title="goto source code">[src]</a></h4><h4 id="method.draw" class="method"><code>pub fn <a href="#method.draw" class="fnname">draw</a>(&amp;self)</code><a href="#method.draw" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#133-138" title="goto source code">[src]</a></h4></div></details><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#23" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.fmt" class="method hidden trait-impl"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a href="#method.fmt" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#23" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#141-145" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.fmt-1" class="method hidden trait-impl"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a href="#method.fmt-1" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#142-144" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-From%3CGame%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a>&gt; for <a class="struct" href="https://docs.rs/wasm-bindgen/0.2/wasm_bindgen/struct.JsValue.html" title="struct wasm_bindgen::JsValue">JsValue</a></code><a href="#impl-From%3CGame%3E" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#22" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="method.from" class="method hidden trait-impl"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(value: <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a>) -&gt; Self</code><a href="#method.from" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#22" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><h3 id="impl-FromWasmAbi" class="impl"><code class="in-band">impl <a class="trait" href="https://docs.rs/wasm-bindgen/0.2/wasm_bindgen/convert/traits/trait.FromWasmAbi.html" title="trait wasm_bindgen::convert::traits::FromWasmAbi">FromWasmAbi</a> for <a class="struct" href="struct.Game.html" title="struct draught::game::Game">Game</a></code><a href="#impl-FromWasmAbi" class="anchor"></a><a class="srclink" href="../../src/draught/game/mod.rs.html#22" title="goto source code">[src]</a></h3></summary><div class="impl-items"><h4 id="associatedtype.Abi-1" class="type trait-impl"><code>type <a href="https://docs.rs/wasm-bindgen/0.2/wasm_bindgen/convert/traits/trait.FromWasmAbi.html#associatedtype.Abi" class="type">Abi</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a href="#associatedtype.Abi-1" class="anchor"></a></h4><div class='docblock'><p>The wasm ABI type that this converts from when coming back out from the
ABI boundary. <a href="https://docs.rs/wasm-bindgen/0.2/wasm_bindgen/convert/traits/trait.FromWasmAbi.html#associatedtype.Abi">Read more</a></p>

File diff suppressed because one or more lines are too long

View File

@ -144,6 +144,8 @@
<span id="141">141</span>
<span id="142">142</span>
<span id="143">143</span>
<span id="144">144</span>
<span id="145">145</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="doccomment">//! Top-level object for managing [`Board`]s, applying and managing turns</span>
@ -204,7 +206,7 @@
}
<span class="doccomment">/// Attempt to make a move given a source and destination index</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">make_move</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">from</span>: <span class="ident">BrdIdx</span>, <span class="ident">to</span>: <span class="ident">BrdIdx</span>) {
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">make_move</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">from</span>: <span class="ident">BrdIdx</span>, <span class="ident">to</span>: <span class="ident">BrdIdx</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Moveable</span> {
<span class="kw">let</span> <span class="ident">able</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">current</span>.<span class="ident">can_move</span>(<span class="ident">from</span>, <span class="ident">to</span>);
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">Moveable::Allowed</span> <span class="op">=</span> <span class="ident">able</span> {
@ -223,6 +225,8 @@
<span class="comment">// board has been changed, update player turn</span>
<span class="self">self</span>.<span class="ident">current</span>.<span class="ident">current_turn</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">current</span>.<span class="ident">current_turn</span>.<span class="ident">opponent</span>();
<span class="ident">able</span>
}
<span class="doccomment">/// Update board state with given move and push new board into current state</span>

View File

@ -39,11 +39,17 @@
<p class="text-muted">Working on an implementation of checkers in Rust WASM with a thin Js frontend, mainly as an exercise to learn Rust and to have a larger project in the language to fiddle with. The idea is to use the <a href="https://en.wikipedia.org/wiki/Minimax">minimax</a> algorithm to create an AI player that can operate with reasonable performance as a result of Rust's compiled performance.</p>
</div>
</div>
<div class="row p-1">
<div class="row p-3">
<div class="col-sm-12">
<a href="doc/draught" class="btn btn-secondary">Docs</a>
</div>
</div>
<div class="row p-1">
<div class="col-sm-12">
<p hidden id="status-p"></p>
</div>
</div>
</div>
</div>