deploy: 17ed845125
This commit is contained in:
parent
6d57a15a29
commit
2edf48854e
BIN
03257114f6704ea051f4.module.wasm
Normal file
BIN
03257114f6704ea051f4.module.wasm
Normal file
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
<!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="Standard height of a checkers board is 8 squares"><meta name="keywords" content="rust, rustlang, rust-lang, STD_HEIGHT"><title>draught::board::STD_HEIGHT - 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 constant"><!--[if lte IE 8]><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">☰</div><a href='../../draught/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="../index.html">draught</a>::<wbr><a href="index.html">board</a></p><div id="sidebar-vars" data-name="STD_HEIGHT" data-ty="constant" 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><script src="../../theme.js"></script><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">Constant <a href="../index.html">draught</a>::<wbr><a href="index.html">board</a>::<wbr><a class="constant" href="">STD_HEIGHT</a></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">−</span>]</a></span><a class="srclink" href="../../src/draught/board/mod.rs.html#18" title="goto source code">[src]</a></span></h1><pre class="rust const">pub const STD_HEIGHT: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> = 8;</pre><div class="docblock"><p>Standard height of a checkers board is 8 squares</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">Constant <a href="../index.html">draught</a>::<wbr><a href="index.html">board</a>::<wbr><a class="constant" href="">STD_HEIGHT</a></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">−</span>]</a></span><a class="srclink" href="../../src/draught/board/mod.rs.html#20" title="goto source code">[src]</a></span></h1><pre class="rust const">pub const STD_HEIGHT: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> = 8;</pre><div class="docblock"><p>Standard height of a checkers board is 8 squares</p>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="draught" data-search-js="../../search-index.js"></div>
|
||||
<script src="../../main.js"></script></body></html>
|
@ -1,6 +1,6 @@
|
||||
<!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="Standard width of a checkers board is 8 squares"><meta name="keywords" content="rust, rustlang, rust-lang, STD_WIDTH"><title>draught::board::STD_WIDTH - 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 constant"><!--[if lte IE 8]><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">☰</div><a href='../../draught/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="../index.html">draught</a>::<wbr><a href="index.html">board</a></p><div id="sidebar-vars" data-name="STD_WIDTH" data-ty="constant" 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><script src="../../theme.js"></script><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">Constant <a href="../index.html">draught</a>::<wbr><a href="index.html">board</a>::<wbr><a class="constant" href="">STD_WIDTH</a></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">−</span>]</a></span><a class="srclink" href="../../src/draught/board/mod.rs.html#16" title="goto source code">[src]</a></span></h1><pre class="rust const">pub const STD_WIDTH: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> = 8;</pre><div class="docblock"><p>Standard width of a checkers board is 8 squares</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">Constant <a href="../index.html">draught</a>::<wbr><a href="index.html">board</a>::<wbr><a class="constant" href="">STD_WIDTH</a></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">−</span>]</a></span><a class="srclink" href="../../src/draught/board/mod.rs.html#18" title="goto source code">[src]</a></span></h1><pre class="rust const">pub const STD_WIDTH: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> = 8;</pre><div class="docblock"><p>Standard width of a checkers board is 8 squares</p>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="draught" data-search-js="../../search-index.js"></div>
|
||||
<script src="../../main.js"></script></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,15 +1,15 @@
|
||||
<!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="API documentation for the Rust `Team` enum in crate `draught`."><meta name="keywords" content="rust, rustlang, rust-lang, Team"><title>draught::board::enums::Team - 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 enum"><!--[if lte IE 8]><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">☰</div><a href='../../../draught/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Enum Team</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Black">Black</a><a href="#variant.White">White</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Copy">Copy</a><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Eq">Eq</a><a href="#impl-FromWasmAbi">FromWasmAbi</a><a href="#impl-IntoWasmAbi">IntoWasmAbi</a><a href="#impl-OptionFromWasmAbi">OptionFromWasmAbi</a><a href="#impl-OptionIntoWasmAbi">OptionIntoWasmAbi</a><a href="#impl-PartialEq%3CTeam%3E">PartialEq<Team></a><a href="#impl-StructuralEq">StructuralEq</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a><a href="#impl-WasmDescribe">WasmDescribe</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ReturnWasmAbi">ReturnWasmAbi</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a><a href="#impl-VZip%3CV%3E">VZip<V></a></div></div><p class="location"><a href="../../index.html">draught</a>::<wbr><a href="../index.html">board</a>::<wbr><a href="index.html">enums</a></p><div id="sidebar-vars" data-name="Team" data-ty="enum" 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><script src="../../../theme.js"></script><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>
|
||||
<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 enum"><!--[if lte IE 8]><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">☰</div><a href='../../../draught/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Enum Team</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Black">Black</a><a href="#variant.White">White</a></div><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.opponent">opponent</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Copy">Copy</a><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Eq">Eq</a><a href="#impl-FromWasmAbi">FromWasmAbi</a><a href="#impl-IntoWasmAbi">IntoWasmAbi</a><a href="#impl-OptionFromWasmAbi">OptionFromWasmAbi</a><a href="#impl-OptionIntoWasmAbi">OptionIntoWasmAbi</a><a href="#impl-PartialEq%3CTeam%3E">PartialEq<Team></a><a href="#impl-StructuralEq">StructuralEq</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a><a href="#impl-WasmDescribe">WasmDescribe</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ReturnWasmAbi">ReturnWasmAbi</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a><a href="#impl-VZip%3CV%3E">VZip<V></a></div></div><p class="location"><a href="../../index.html">draught</a>::<wbr><a href="../index.html">board</a>::<wbr><a href="index.html">enums</a></p><div id="sidebar-vars" data-name="Team" data-ty="enum" 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><script src="../../../theme.js"></script><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">Enum <a href="../../index.html">draught</a>::<wbr><a href="../index.html">board</a>::<wbr><a href="index.html">enums</a>::<wbr><a class="enum" href="">Team</a></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">−</span>]</a></span><a class="srclink" href="../../../src/draught/board/enums.rs.html#9-12" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum"><span class="docblock attributes top-attr">#[repr(u8)]</span>pub enum Team {
|
||||
Black,
|
||||
White,
|
||||
}</pre></div><h2 id="variants" class="variants small-section-header">
|
||||
Variants<a href="#variants" class="anchor"></a></h2>
|
||||
<div id="variant.Black" class="variant small-section-header"><a href="#variant.Black" class="anchor field"></a><code>Black</code></div><div id="variant.White" class="variant small-section-header"><a href="#variant.White" class="anchor field"></a><code>White</code></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
<div id="variant.Black" class="variant small-section-header"><a href="#variant.Black" class="anchor field"></a><code>Black</code></div><div id="variant.White" class="variant small-section-header"><a href="#variant.White" class="anchor field"></a><code>White</code></div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#14-21" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.opponent" class="method"><code>pub fn <a href="#method.opponent" class="fnname">opponent</a>(&self) -> <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a class="srclink" href="../../../src/draught/board/enums.rs.html#15-20" title="goto source code">[src]</a></h4></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||||
</div></div><h3 id="impl-Copy" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-Copy" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" title="goto source code">[src]</a></h3><div class="impl-items"></div><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="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" 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><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="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#14-21" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/draught/board/enums.rs.html#15-20" 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><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="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#23-30" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/draught/board/enums.rs.html#24-29" 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><h3 id="impl-Eq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-Eq" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#8" title="goto source code">[src]</a></h3><div class="impl-items"></div><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="enum" href="../../../draught/board/enums/enum.Team.html" title="enum draught::board::enums::Team">Team</a></code><a href="#impl-FromWasmAbi" class="anchor"></a><a class="srclink" href="../../../src/draught/board/enums.rs.html#6" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Abi" class="type"><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></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>
|
||||
</div><h4 id="method.from_abi" class="method hidden"><code>unsafe fn <a href="https://docs.rs/wasm-bindgen/0.2/wasm_bindgen/convert/traits/trait.FromWasmAbi.html#tymethod.from_abi" class="fnname">from_abi</a>(js: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> Self</code><a class="srclink" href="../../../src/draught/board/enums.rs.html#6" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Recover a <code>Self</code> from <code>Self::Abi</code>. <a href="https://docs.rs/wasm-bindgen/0.2/wasm_bindgen/convert/traits/trait.FromWasmAbi.html#tymethod.from_abi">Read more</a></p>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!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="API documentation for the Rust `enums` mod in crate `draught`."><meta name="keywords" content="rust, rustlang, rust-lang, enums"><title>draught::board::enums - 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 8]><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">☰</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 enums</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#enums">Enums</a></li></ul></div><p class="location"><a href="../../index.html">draught</a>::<wbr><a href="../index.html">board</a></p><div id="sidebar-vars" data-name="enums" 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><script src="../../../theme.js"></script><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 href="../index.html">board</a>::<wbr><a class="mod" href="">enums</a></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">−</span>]</a></span><a class="srclink" href="../../../src/draught/board/enums.rs.html#1-61" title="goto source code">[src]</a></span></h1><h2 id="enums" class="section-header"><a href="#enums">Enums</a></h2>
|
||||
<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 href="../index.html">board</a>::<wbr><a class="mod" href="">enums</a></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">−</span>]</a></span><a class="srclink" href="../../../src/draught/board/enums.rs.html#1-72" title="goto source code">[src]</a></span></h1><h2 id="enums" class="section-header"><a href="#enums">Enums</a></h2>
|
||||
<table><tr class="module-item"><td><a class="enum" href="enum.Moveable.html" title="draught::board::enums::Moveable enum">Moveable</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="enum" href="enum.SquareState.html" title="draught::board::enums::SquareState enum">SquareState</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="enum" href="enum.Strength.html" title="draught::board::enums::Strength enum">Strength</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="enum" href="enum.Team.html" title="draught::board::enums::Team enum">Team</a></td><td class="docblock-short"></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="draught" data-search-js="../../../search-index.js"></div>
|
||||
<script src="../../../main.js"></script></body></html>
|
@ -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="Board module for components related to the checkers board and game structure"><meta name="keywords" content="rust, rustlang, rust-lang, board"><title>draught::board - 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 8]><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">☰</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 board</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li></ul></div><p class="location"><a href="../index.html">draught</a></p><div id="sidebar-vars" data-name="board" 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><script src="../../theme.js"></script><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="">board</a></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">−</span>]</a></span><a class="srclink" href="../../src/draught/board/mod.rs.html#1-732" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Board module for components related to the checkers board and game structure</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="">board</a></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">−</span>]</a></span><a class="srclink" href="../../src/draught/board/mod.rs.html#1-630" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Board module for components related to the checkers board and game structure</p>
|
||||
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
|
||||
<table><tr class="module-item"><td><a class="mod" href="enums/index.html" title="draught::board::enums mod">enums</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="mod" href="iter/index.html" title="draught::board::iter mod">iter</a></td><td class="docblock-short"></td></tr></table><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||||
<table><tr class="module-item"><td><a class="struct" href="struct.Board.html" title="draught::board::Board struct">Board</a></td><td class="docblock-short"><p>Models a single state for a checkers board</p>
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -62,6 +62,17 @@
|
||||
<span id="59">59</span>
|
||||
<span id="60">60</span>
|
||||
<span id="61">61</span>
|
||||
<span id="62">62</span>
|
||||
<span id="63">63</span>
|
||||
<span id="64">64</span>
|
||||
<span id="65">65</span>
|
||||
<span id="66">66</span>
|
||||
<span id="67">67</span>
|
||||
<span id="68">68</span>
|
||||
<span id="69">69</span>
|
||||
<span id="70">70</span>
|
||||
<span id="71">71</span>
|
||||
<span id="72">72</span>
|
||||
</pre><div class="example-wrap"><pre class="rust ">
|
||||
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">wasm_bindgen</span>;
|
||||
<span class="kw">use</span> <span class="ident">wasm_bindgen</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;
|
||||
@ -76,6 +87,15 @@
|
||||
<span class="ident">White</span> <span class="op">=</span> <span class="number">1</span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Team</span> {
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">opponent</span>(<span class="kw-2">&</span><span class="self">self</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Team</span>{
|
||||
<span class="kw">match</span> <span class="self">self</span> {
|
||||
<span class="ident">Team</span>::<span class="ident">White</span> <span class="op">=</span><span class="op">></span> <span class="ident">Team</span>::<span class="ident">Black</span>,
|
||||
<span class="ident">Team</span>::<span class="ident">Black</span> <span class="op">=</span><span class="op">></span> <span class="ident">Team</span>::<span class="ident">White</span>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Display</span> <span class="kw">for</span> <span class="ident">Team</span> {
|
||||
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">std</span>::<span class="ident">fmt</span>::<span class="ident">Formatter</span>) <span class="op">-</span><span class="op">></span> <span class="ident">std</span>::<span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
|
||||
<span class="kw">match</span> <span class="self">self</span> {
|
||||
@ -123,6 +143,8 @@
|
||||
<span class="ident">Unplayable</span> <span class="op">=</span> <span class="number">4</span>,
|
||||
<span class="ident">WrongTeamSrc</span> <span class="op">=</span> <span class="number">5</span>,
|
||||
<span class="ident">IllegalTrajectory</span> <span class="op">=</span> <span class="number">6</span>,
|
||||
<span class="ident">NoJumpablePiece</span> <span class="op">=</span> <span class="number">7</span>,
|
||||
<span class="ident">JumpingSameTeam</span> <span class="op">=</span> <span class="number">8</span>,
|
||||
}</pre></div>
|
||||
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="draught" data-search-js="../../../search-index.js"></div>
|
||||
<script src="../../../main.js"></script><script src="../../../source-script.js"></script><script src="../../../source-files.js"></script></body></html>
|
@ -631,111 +631,11 @@
|
||||
<span id="628">628</span>
|
||||
<span id="629">629</span>
|
||||
<span id="630">630</span>
|
||||
<span id="631">631</span>
|
||||
<span id="632">632</span>
|
||||
<span id="633">633</span>
|
||||
<span id="634">634</span>
|
||||
<span id="635">635</span>
|
||||
<span id="636">636</span>
|
||||
<span id="637">637</span>
|
||||
<span id="638">638</span>
|
||||
<span id="639">639</span>
|
||||
<span id="640">640</span>
|
||||
<span id="641">641</span>
|
||||
<span id="642">642</span>
|
||||
<span id="643">643</span>
|
||||
<span id="644">644</span>
|
||||
<span id="645">645</span>
|
||||
<span id="646">646</span>
|
||||
<span id="647">647</span>
|
||||
<span id="648">648</span>
|
||||
<span id="649">649</span>
|
||||
<span id="650">650</span>
|
||||
<span id="651">651</span>
|
||||
<span id="652">652</span>
|
||||
<span id="653">653</span>
|
||||
<span id="654">654</span>
|
||||
<span id="655">655</span>
|
||||
<span id="656">656</span>
|
||||
<span id="657">657</span>
|
||||
<span id="658">658</span>
|
||||
<span id="659">659</span>
|
||||
<span id="660">660</span>
|
||||
<span id="661">661</span>
|
||||
<span id="662">662</span>
|
||||
<span id="663">663</span>
|
||||
<span id="664">664</span>
|
||||
<span id="665">665</span>
|
||||
<span id="666">666</span>
|
||||
<span id="667">667</span>
|
||||
<span id="668">668</span>
|
||||
<span id="669">669</span>
|
||||
<span id="670">670</span>
|
||||
<span id="671">671</span>
|
||||
<span id="672">672</span>
|
||||
<span id="673">673</span>
|
||||
<span id="674">674</span>
|
||||
<span id="675">675</span>
|
||||
<span id="676">676</span>
|
||||
<span id="677">677</span>
|
||||
<span id="678">678</span>
|
||||
<span id="679">679</span>
|
||||
<span id="680">680</span>
|
||||
<span id="681">681</span>
|
||||
<span id="682">682</span>
|
||||
<span id="683">683</span>
|
||||
<span id="684">684</span>
|
||||
<span id="685">685</span>
|
||||
<span id="686">686</span>
|
||||
<span id="687">687</span>
|
||||
<span id="688">688</span>
|
||||
<span id="689">689</span>
|
||||
<span id="690">690</span>
|
||||
<span id="691">691</span>
|
||||
<span id="692">692</span>
|
||||
<span id="693">693</span>
|
||||
<span id="694">694</span>
|
||||
<span id="695">695</span>
|
||||
<span id="696">696</span>
|
||||
<span id="697">697</span>
|
||||
<span id="698">698</span>
|
||||
<span id="699">699</span>
|
||||
<span id="700">700</span>
|
||||
<span id="701">701</span>
|
||||
<span id="702">702</span>
|
||||
<span id="703">703</span>
|
||||
<span id="704">704</span>
|
||||
<span id="705">705</span>
|
||||
<span id="706">706</span>
|
||||
<span id="707">707</span>
|
||||
<span id="708">708</span>
|
||||
<span id="709">709</span>
|
||||
<span id="710">710</span>
|
||||
<span id="711">711</span>
|
||||
<span id="712">712</span>
|
||||
<span id="713">713</span>
|
||||
<span id="714">714</span>
|
||||
<span id="715">715</span>
|
||||
<span id="716">716</span>
|
||||
<span id="717">717</span>
|
||||
<span id="718">718</span>
|
||||
<span id="719">719</span>
|
||||
<span id="720">720</span>
|
||||
<span id="721">721</span>
|
||||
<span id="722">722</span>
|
||||
<span id="723">723</span>
|
||||
<span id="724">724</span>
|
||||
<span id="725">725</span>
|
||||
<span id="726">726</span>
|
||||
<span id="727">727</span>
|
||||
<span id="728">728</span>
|
||||
<span id="729">729</span>
|
||||
<span id="730">730</span>
|
||||
<span id="731">731</span>
|
||||
<span id="732">732</span>
|
||||
</pre><div class="example-wrap"><pre class="rust ">
|
||||
<span class="doccomment">//! Board module for components related to the checkers board and game structure</span>
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span> <span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">tests</span>;
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">enums</span>;
|
||||
<span class="kw">use</span> <span class="ident">enums</span>::<span class="kw-2">*</span>;
|
||||
|
||||
@ -1102,64 +1002,163 @@
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">OutOfBounds</span>;
|
||||
}
|
||||
|
||||
<span class="kw">if</span> <span class="ident">to</span>.<span class="ident">row</span> <span class="op">></span> <span class="self">self</span>.<span class="ident">height</span> <span class="op">-</span> <span class="number">1</span> <span class="op">|</span><span class="op">|</span> <span class="ident">to</span>.<span class="ident">col</span> <span class="op">></span> <span class="self">self</span>.<span class="ident">width</span> <span class="op">-</span> <span class="number">1</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">OutOfBounds</span>;
|
||||
}
|
||||
|
||||
<span class="kw">let</span> <span class="ident">from_square</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">cell</span>(<span class="self">self</span>.<span class="ident">cell_idx</span>(<span class="ident">from</span>));
|
||||
|
||||
<span class="comment">// check source square is occupied</span>
|
||||
<span class="kw">match</span> <span class="ident">from_square</span>.<span class="ident">state</span> {
|
||||
<span class="ident">Empty</span> <span class="op">=</span><span class="op">></span> <span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">UnoccupiedSrc</span>,
|
||||
<span class="ident">Unplayable</span> <span class="op">=</span><span class="op">></span> <span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">Unplayable</span>,
|
||||
<span class="ident">Occupied</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="ident">SquareState</span>::<span class="ident">Empty</span> <span class="op">=</span><span class="op">></span> <span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">UnoccupiedSrc</span>,
|
||||
<span class="ident">SquareState</span>::<span class="ident">Unplayable</span> <span class="op">=</span><span class="op">></span> <span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">Unplayable</span>,
|
||||
<span class="ident">SquareState</span>::<span class="ident">Occupied</span> <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
<span class="comment">// if its not the current teams piece then error</span>
|
||||
<span class="kw">match</span> <span class="ident">from_square</span>.<span class="ident">occupant</span> {
|
||||
<span class="comment">// weird error, shouldn't happen</span>
|
||||
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">></span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">"Square is apparently occupied, but no occupant was found from: {}, to: {}, square: {:?}"</span>, <span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">from_square</span>),
|
||||
<span class="prelude-val">Some</span>(<span class="ident">x</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="prelude-val">Some</span>(<span class="ident">from_square_occupant</span>) <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
<span class="comment">// piece in the source square is not for the current turn's player</span>
|
||||
<span class="kw">if</span> <span class="ident">x</span>.<span class="ident">team</span> <span class="op">!</span><span class="op">=</span> <span class="self">self</span>.<span class="ident">current_turn</span> {
|
||||
<span class="kw">if</span> <span class="ident">from_square_occupant</span>.<span class="ident">team</span> <span class="op">!</span><span class="op">=</span> <span class="self">self</span>.<span class="ident">current_turn</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">WrongTeamSrc</span>;
|
||||
}
|
||||
|
||||
<span class="comment">// cast to signed ints so that -1 will work for black moves</span>
|
||||
<span class="kw">let</span> <span class="ident">row_diff</span>: <span class="ident">i32</span> <span class="op">=</span> <span class="ident">to</span>.<span class="ident">row</span> <span class="kw">as</span> <span class="ident">i32</span> <span class="op">-</span> <span class="ident">from</span>.<span class="ident">row</span> <span class="kw">as</span> <span class="ident">i32</span>;
|
||||
<span class="kw">let</span> <span class="ident">col_diff</span>: <span class="ident">i32</span> <span class="op">=</span> <span class="ident">to</span>.<span class="ident">col</span> <span class="kw">as</span> <span class="ident">i32</span> <span class="op">-</span> <span class="ident">from</span>.<span class="ident">col</span> <span class="kw">as</span> <span class="ident">i32</span>;
|
||||
|
||||
<span class="comment">// depending on whether the piece is a king or not, the piece can make different moves</span>
|
||||
<span class="comment">// TODO: refactor to a IsMove()/IsJump() to check whether the move has a legal trajectory</span>
|
||||
<span class="kw">match</span> <span class="ident">x</span>.<span class="ident">strength</span> {
|
||||
<span class="ident">Man</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">match</span> <span class="self">self</span>.<span class="ident">current_turn</span> {
|
||||
<span class="ident">Black</span> <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
},
|
||||
<span class="ident">White</span> <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
},
|
||||
};
|
||||
},
|
||||
<span class="ident">King</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">match</span> <span class="self">self</span>.<span class="ident">current_turn</span> {
|
||||
<span class="ident">Black</span> <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
},
|
||||
<span class="ident">White</span> <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
},
|
||||
};
|
||||
},
|
||||
<span class="kw">match</span> <span class="ident">from_square_occupant</span>.<span class="ident">strength</span> {
|
||||
<span class="ident">Strength</span>::<span class="ident">Man</span> <span class="op">=</span><span class="op">></span> <span class="self">self</span>.<span class="ident">validate_man_move</span>(<span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">row_diff</span>, <span class="ident">col_diff</span>, <span class="ident">from_square_occupant</span>),
|
||||
<span class="ident">Strength</span>::<span class="ident">King</span> <span class="op">=</span><span class="op">></span> <span class="self">self</span>.<span class="ident">validate_king_move</span>(<span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">row_diff</span>, <span class="ident">col_diff</span>, <span class="ident">from_square_occupant</span>),
|
||||
};
|
||||
|
||||
<span class="comment">// let diagonal = self.adjacent_dir(from);</span>
|
||||
<span class="comment">// let allowable_squares = Vec::with_capacity(4);</span>
|
||||
|
||||
<span class="kw">let</span> <span class="ident">jumpable</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">jumpable_dir</span>(<span class="ident">from</span>);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
<span class="comment">// let is_adjacent = match self.current_turn {</span>
|
||||
<span class="comment">// Team::Black => diagonal.nw,</span>
|
||||
<span class="comment">// Team::White => {},</span>
|
||||
<span class="comment">// }</span>
|
||||
|
||||
<span class="ident">Moveable</span>::<span class="ident">Allowed</span>
|
||||
}
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">validate_man_move</span>(<span class="kw-2">&</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="ident">row_diff</span>: <span class="ident">i32</span>, <span class="ident">col_diff</span>: <span class="ident">i32</span>, <span class="ident">from_square_occupant</span>: <span class="ident">Piece</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Moveable</span> {
|
||||
<span class="comment">// men can only move forwards, below is row difference for each team</span>
|
||||
<span class="kw">let</span> <span class="ident">idx_scale</span>: <span class="ident">i32</span> <span class="op">=</span> <span class="kw">match</span> <span class="self">self</span>.<span class="ident">current_turn</span> {
|
||||
<span class="ident">Team</span>::<span class="ident">Black</span> <span class="op">=</span><span class="op">></span> <span class="op">-</span><span class="number">1</span>,
|
||||
<span class="ident">Team</span>::<span class="ident">White</span> <span class="op">=</span><span class="op">></span> <span class="number">1</span>,
|
||||
};
|
||||
|
||||
<span class="comment">// legal standard move </span>
|
||||
<span class="kw">if</span> <span class="ident">row_diff</span> <span class="op">=</span><span class="op">=</span> <span class="ident">idx_scale</span> {
|
||||
<span class="comment">// destination is directly to the left or right</span>
|
||||
<span class="kw">if</span> <span class="ident">col_diff</span>.<span class="ident">abs</span>() <span class="op">=</span><span class="op">=</span> <span class="number">1</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">Allowed</span>;
|
||||
}
|
||||
<span class="comment">// illegal, not adjacently diagional</span>
|
||||
<span class="kw">else</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">IllegalTrajectory</span>;
|
||||
}
|
||||
}
|
||||
<span class="comment">// legal jump move trajectory</span>
|
||||
<span class="kw">else</span> <span class="kw">if</span> <span class="ident">row_diff</span> <span class="op">=</span><span class="op">=</span> <span class="number">2</span> <span class="op">*</span> <span class="ident">idx_scale</span> {
|
||||
<span class="comment">// destination is directly to the left or right</span>
|
||||
<span class="kw">if</span> <span class="ident">col_diff</span>.<span class="ident">abs</span>() <span class="op">=</span><span class="op">=</span> <span class="number">2</span> {
|
||||
|
||||
<span class="comment">// piece to be jumped over</span>
|
||||
<span class="kw">let</span> <span class="ident">jumpee</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">get_jumpee</span>(<span class="ident">from</span>, <span class="ident">row_diff</span>, <span class="ident">col_diff</span>);
|
||||
<span class="kw">match</span> <span class="ident">jumpee</span>.<span class="ident">state</span> {
|
||||
<span class="ident">SquareState</span>::<span class="ident">Empty</span> <span class="op">=</span><span class="op">></span> <span class="ident">Moveable</span>::<span class="ident">NoJumpablePiece</span>,
|
||||
<span class="ident">SquareState</span>::<span class="ident">Unplayable</span> <span class="op">=</span><span class="op">></span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">"Found an unplayable piece to try to jump over, from: {}, to: {}, jumpee: {:?}"</span>, <span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">jumpee</span>),
|
||||
<span class="ident">SquareState</span>::<span class="ident">Occupied</span> <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
<span class="comment">// check whether jumpee is an opponent's piece</span>
|
||||
<span class="kw">return</span> <span class="ident">Board</span>::<span class="ident">validate_jumpee</span>(<span class="ident">jumpee</span>, <span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">from_square_occupant</span>);
|
||||
},
|
||||
}
|
||||
}
|
||||
<span class="comment">// illegal, not adjacently diagional</span>
|
||||
<span class="kw">else</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">IllegalTrajectory</span>;
|
||||
}
|
||||
}
|
||||
<span class="comment">// illegal, not adjacently diagonal</span>
|
||||
<span class="kw">else</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">IllegalTrajectory</span>;
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">validate_king_move</span>(<span class="kw-2">&</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="ident">row_diff</span>: <span class="ident">i32</span>, <span class="ident">col_diff</span>: <span class="ident">i32</span>, <span class="ident">from_square_occupant</span>: <span class="ident">Piece</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Moveable</span> {
|
||||
<span class="comment">// legal standard move </span>
|
||||
<span class="kw">if</span> <span class="ident">row_diff</span>.<span class="ident">abs</span>() <span class="op">=</span><span class="op">=</span> <span class="number">1</span> {
|
||||
<span class="comment">// destination is directly to the left or right</span>
|
||||
<span class="kw">if</span> <span class="ident">col_diff</span>.<span class="ident">abs</span>() <span class="op">=</span><span class="op">=</span> <span class="number">1</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">Allowed</span>;
|
||||
}
|
||||
<span class="comment">// illegal, not adjacently diagional</span>
|
||||
<span class="kw">else</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">IllegalTrajectory</span>;
|
||||
}
|
||||
}
|
||||
<span class="comment">// legal jump move trajectory</span>
|
||||
<span class="kw">else</span> <span class="kw">if</span> <span class="ident">row_diff</span>.<span class="ident">abs</span>() <span class="op">=</span><span class="op">=</span> <span class="number">2</span> {
|
||||
<span class="comment">// destination is directly to the left or right</span>
|
||||
<span class="kw">if</span> <span class="ident">col_diff</span>.<span class="ident">abs</span>() <span class="op">=</span><span class="op">=</span> <span class="number">2</span> {
|
||||
|
||||
<span class="comment">// piece to be jumped over</span>
|
||||
<span class="kw">let</span> <span class="ident">jumpee</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">get_jumpee</span>(<span class="ident">from</span>, <span class="ident">row_diff</span>, <span class="ident">col_diff</span>);
|
||||
<span class="kw">match</span> <span class="ident">jumpee</span>.<span class="ident">state</span> {
|
||||
<span class="ident">SquareState</span>::<span class="ident">Empty</span> <span class="op">=</span><span class="op">></span> <span class="ident">Moveable</span>::<span class="ident">NoJumpablePiece</span>,
|
||||
<span class="ident">SquareState</span>::<span class="ident">Unplayable</span> <span class="op">=</span><span class="op">></span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">"Found an unplayable piece to try to jump over, from: {}, to: {}, jumpee: {:?}"</span>, <span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">jumpee</span>),
|
||||
<span class="ident">SquareState</span>::<span class="ident">Occupied</span> <span class="op">=</span><span class="op">></span> {
|
||||
|
||||
<span class="comment">// check whether jumpee is an opponent's piece</span>
|
||||
<span class="kw">return</span> <span class="ident">Board</span>::<span class="ident">validate_jumpee</span>(<span class="ident">jumpee</span>, <span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">from_square_occupant</span>);
|
||||
},
|
||||
}
|
||||
}
|
||||
<span class="comment">// illegal, not adjacently diagional</span>
|
||||
<span class="kw">else</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">IllegalTrajectory</span>;
|
||||
}
|
||||
}
|
||||
<span class="comment">// illegal, not adjacently diagonal</span>
|
||||
<span class="kw">else</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">IllegalTrajectory</span>;
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">get_jumpee</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">from</span>: <span class="ident">BrdIdx</span>, <span class="ident">row_diff</span>: <span class="ident">i32</span>, <span class="ident">col_diff</span>: <span class="ident">i32</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Square</span> {
|
||||
<span class="self">self</span>.<span class="ident">cell</span>(
|
||||
<span class="self">self</span>.<span class="ident">cell_idx</span>(
|
||||
<span class="ident">BrdIdx</span>::<span class="ident">from</span>(
|
||||
((<span class="ident">from</span>.<span class="ident">row</span> <span class="kw">as</span> <span class="ident">i32</span>) <span class="op">+</span> <span class="ident">row_diff</span> <span class="op">/</span> <span class="number">2</span>) <span class="kw">as</span> <span class="ident">usize</span>,
|
||||
((<span class="ident">from</span>.<span class="ident">col</span> <span class="kw">as</span> <span class="ident">i32</span>) <span class="op">+</span> <span class="ident">col_diff</span> <span class="op">/</span> <span class="number">2</span>) <span class="kw">as</span> <span class="ident">usize</span>)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">validate_jumpee</span>(<span class="ident">jumpee</span>: <span class="ident">Square</span>, <span class="ident">from</span>: <span class="ident">BrdIdx</span>, <span class="ident">to</span>: <span class="ident">BrdIdx</span>, <span class="ident">from_occ</span>: <span class="ident">Piece</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Moveable</span> {
|
||||
<span class="comment">// check whether jumpee is an opponent's piece</span>
|
||||
<span class="kw">match</span> <span class="ident">jumpee</span>.<span class="ident">occupant</span> {
|
||||
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">></span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">"No occupant found when checking the jumpee, from: {}, to: {}, jumpee: {:?}"</span>, <span class="ident">from</span>, <span class="ident">to</span>, <span class="ident">jumpee</span>),
|
||||
<span class="prelude-val">Some</span>(<span class="ident">jumpee_occupant_uw</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">if</span> <span class="ident">Board</span>::<span class="ident">check_jumpee_team</span>(<span class="ident">from_occ</span>, <span class="ident">jumpee_occupant_uw</span>) {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">Allowed</span>;
|
||||
}
|
||||
<span class="kw">else</span> {
|
||||
<span class="kw">return</span> <span class="ident">Moveable</span>::<span class="ident">JumpingSameTeam</span>;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">check_jumpee_team</span>(<span class="ident">from</span>: <span class="ident">Piece</span>, <span class="ident">jumpee</span>: <span class="ident">Piece</span>) <span class="op">-</span><span class="op">></span> <span class="ident">bool</span> {
|
||||
<span class="kw">return</span> <span class="ident">from</span>.<span class="ident">team</span>.<span class="ident">opponent</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">jumpee</span>.<span class="ident">team</span>
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Iniitalise a game board without game pieces</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">width</span>: <span class="ident">usize</span>, <span class="ident">height</span>: <span class="ident">usize</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Board</span> {
|
||||
<span class="kw">let</span> <span class="ident">total_cells</span> <span class="op">=</span> <span class="ident">width</span> <span class="op">*</span> <span class="ident">height</span>;
|
||||
@ -1262,209 +1261,6 @@
|
||||
|
||||
<span class="macro">write</span><span class="macro">!</span>(<span class="ident">f</span>, <span class="string">"{}"</span>, <span class="ident">string</span>)
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">tests</span> {
|
||||
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
|
||||
<span class="kw">use</span> <span class="ident">wasm_bindgen_test</span>::<span class="kw-2">*</span>;
|
||||
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">log</span>;
|
||||
|
||||
<span class="macro">wasm_bindgen_test_configure</span><span class="macro">!</span>(<span class="ident">run_in_browser</span>);
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">create</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="ident">STD_WIDTH</span>, <span class="ident">STD_HEIGHT</span>);
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="bool-val">true</span>);
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">std_num_cells</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">64</span>, <span class="ident">board</span>.<span class="ident">num_cells</span>());
|
||||
}
|
||||
|
||||
<span class="comment">//////////////</span>
|
||||
<span class="comment">// INDEXING</span>
|
||||
<span class="comment">//////////////</span>
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">cell_index_top_left</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0</span>, <span class="ident">board</span>.<span class="ident">cell_index</span>(<span class="number">0</span>, <span class="number">0</span>));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">cell_index_central</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">9</span>, <span class="ident">board</span>.<span class="ident">cell_index</span>(<span class="number">1</span>, <span class="number">1</span>));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">cell_index_central_2</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">17</span>, <span class="ident">board</span>.<span class="ident">cell_index</span>(<span class="number">2</span>, <span class="number">1</span>));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">board_index</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
|
||||
<span class="comment">// first row</span>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">0</span>, <span class="number">5</span>), <span class="ident">board</span>.<span class="ident">board_index</span>(<span class="number">5</span>));
|
||||
<span class="comment">// second row</span>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">6</span>), <span class="ident">board</span>.<span class="ident">board_index</span>(<span class="number">14</span>));
|
||||
<span class="comment">// third row</span>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">2</span>, <span class="number">4</span>), <span class="ident">board</span>.<span class="ident">board_index</span>(<span class="number">20</span>));
|
||||
}
|
||||
|
||||
<span class="comment">///////////////////</span>
|
||||
<span class="comment">// SQUARE STATE</span>
|
||||
<span class="comment">///////////////////</span>
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">first_square_unplayable</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">SquareState</span>::<span class="ident">Unplayable</span>, <span class="ident">board</span>.<span class="ident">cell_state</span>(<span class="ident">board</span>.<span class="ident">cell_index</span>(<span class="number">0</span>, <span class="number">0</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">first_square_row_5_unplayable</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">SquareState</span>::<span class="ident">Empty</span>, <span class="ident">board</span>.<span class="ident">cell_state</span>(<span class="ident">board</span>.<span class="ident">cell_index</span>(<span class="number">5</span>, <span class="number">0</span>)));
|
||||
}
|
||||
|
||||
<span class="comment">//////////////////////</span>
|
||||
<span class="comment">// DIAGNOAL INDICES</span>
|
||||
<span class="comment">//////////////////////</span>
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_unplayable</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">7</span>, <span class="number">7</span>)));
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">0</span>, <span class="number">0</span>)));
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">1</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_central</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">17</span>, <span class="number">19</span>]), <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">2</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_top_row</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">8</span>, <span class="number">10</span>]), <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">0</span>, <span class="number">1</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_left_column</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">17</span>]), <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">0</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_bottom_row</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">49</span>, <span class="number">51</span>]), <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">7</span>, <span class="number">2</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_right_column</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">14</span>, <span class="number">30</span>]), <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">2</span>, <span class="number">7</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_top_right</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">14</span>]), <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">0</span>, <span class="number">7</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">moveable_indices_bottom_left</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">49</span>]), <span class="ident">board</span>.<span class="ident">diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">7</span>, <span class="number">0</span>)));
|
||||
}
|
||||
|
||||
<span class="comment">//////////////////////</span>
|
||||
<span class="comment">// JUMPABLE INDICES</span>
|
||||
<span class="comment">//////////////////////</span>
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_unplayable</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">7</span>, <span class="number">7</span>)));
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">0</span>, <span class="number">0</span>)));
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">1</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">24</span>, <span class="number">28</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">2</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_central</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">10</span>, <span class="number">14</span>, <span class="number">42</span>, <span class="number">46</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">3</span>, <span class="number">4</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_top_row</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">19</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">0</span>, <span class="number">1</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_left_column</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">26</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">0</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_bottom_row</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">40</span>, <span class="number">44</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">7</span>, <span class="number">2</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_right_column</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">5</span>, <span class="number">37</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">2</span>, <span class="number">7</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_top_right</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">21</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">0</span>, <span class="number">7</span>)));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">jumpable_indices_bottom_left</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">42</span>]), <span class="ident">board</span>.<span class="ident">jumpable_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">7</span>, <span class="number">0</span>)));
|
||||
}
|
||||
|
||||
<span class="comment">// #[wasm_bindgen_test]</span>
|
||||
<span class="comment">// fn init_game() {</span>
|
||||
<span class="comment">// let board = Board::init_game(Board::new(8, 8));</span>
|
||||
<span class="comment">// log!("{}", board);</span>
|
||||
<span class="comment">// }</span>
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">black_diagonal_indices</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>]), <span class="ident">board</span>.<span class="ident">player_diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">2</span>), <span class="ident">Team</span>::<span class="ident">Black</span>));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">wasm_bindgen_test</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">white_diagonal_indices</span>() {
|
||||
<span class="kw">let</span> <span class="ident">board</span> <span class="op">=</span> <span class="ident">Board</span>::<span class="ident">new</span>(<span class="number">8</span>, <span class="number">8</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">17</span>, <span class="number">19</span>]), <span class="ident">board</span>.<span class="ident">player_diagonal_indices</span>(<span class="ident">BrdIdx</span>::<span class="ident">from</span>(<span class="number">1</span>, <span class="number">2</span>), <span class="ident">Team</span>::<span class="ident">White</span>));
|
||||
}
|
||||
}</pre></div>
|
||||
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="draught" data-search-js="../../../search-index.js"></div>
|
||||
<script src="../../../main.js"></script><script src="../../../source-script.js"></script><script src="../../../source-files.js"></script></body></html>
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user