<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Game</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: Game</h1> <section> <header> <h2>Game</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="Game"><span class="type-signature"></span>new Game<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Game </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line641">line 641</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Members</h3> <h4 class="name" id="hasStarted"><span class="type-signature"></span>hasStarted<span class="type-signature"> :boolean</span></h4> <div class="description"> Flag that shows if game has started </div> <h5>Type:</h5> <ul> <li> <span class="param-type">boolean</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line658">line 658</a> </li></ul></dd> </dl> <h4 class="name" id="id"><span class="type-signature"></span>id<span class="type-signature"> :number</span></h4> <div class="description"> Unique ID of game </div> <h5>Type:</h5> <ul> <li> <span class="param-type">number</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line646">line 646</a> </li></ul></dd> </dl> <h4 class="name" id="isOver"><span class="type-signature"></span>isOver<span class="type-signature"> :boolean</span></h4> <div class="description"> Flag that shows if game is over/has finished </div> <h5>Type:</h5> <ul> <li> <span class="param-type">boolean</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line664">line 664</a> </li></ul></dd> </dl> <h4 class="name" id="moveSequence"><span class="type-signature"></span>moveSequence<span class="type-signature"></span></h4> <div class="description"> Sequence number that is incremented each time a piece is moved during the game </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line703">line 703</a> </li></ul></dd> </dl> <h4 class="name" id="previousState"><span class="type-signature"></span>previousState<span class="type-signature"></span></h4> <div class="description"> Previous game state, used for undoing moves </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line693">line 693</a> </li></ul></dd> </dl> <h4 class="name" id="previousTurnDice"><span class="type-signature"></span>previousTurnDice<span class="type-signature"></span></h4> <div class="description"> Previous dice state, used for undoing moves </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line698">line 698</a> </li></ul></dd> </dl> <h4 class="name" id="state"><span class="type-signature"></span>state<span class="type-signature"> :<a href="State.html">State</a></span></h4> <div class="description"> Board state </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="State.html">State</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line652">line 652</a> </li></ul></dd> </dl> <h4 class="name" id="turnConfirmed"><span class="type-signature"></span>turnConfirmed<span class="type-signature"> :boolean</span></h4> <div class="description"> Flag that shows if the moves made in current turn have been confirmed by the player. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">boolean</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line688">line 688</a> </li></ul></dd> </dl> <h4 class="name" id="turnDice"><span class="type-signature"></span>turnDice<span class="type-signature"> :<a href="Dice.html">Dice</a></span></h4> <div class="description"> Dice for current turn. Should be null if dice haven't been rolled yet. </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="Dice.html">Dice</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line682">line 682</a> </li></ul></dd> </dl> <h4 class="name" id="turnNumber"><span class="type-signature"></span>turnNumber<span class="type-signature"> :number</span></h4> <div class="description"> Number (index) of turn </div> <h5>Type:</h5> <ul> <li> <span class="param-type">number</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line670">line 670</a> </li></ul></dd> </dl> <h4 class="name" id="turnPlayer"><span class="type-signature"></span>turnPlayer<span class="type-signature"> :<a href="Player.html">Player</a></span></h4> <div class="description"> Show which player's turn it is </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="Player.html">Player</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line676">line 676</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <h4 class="name" id=".createNew"><span class="type-signature">(static) </span>createNew<span class="signature">(rule)</span><span class="type-signature"> → {<a href="Game.html">Game</a>}</span></h4> <div class="description"> Create new game object with unique ID and initialize it. Game object is not saved in database. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>rule</code></td> <td class="type"> <span class="param-type"><a href="Rule.html">Rule</a></span> </td> <td class="description last">Rule object to use</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line712">line 712</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - A new game object with unique ID </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Game.html">Game</a></span> </dd> </dl> <h4 class="name" id=".diceWasRolled"><span class="type-signature">(static) </span>diceWasRolled<span class="signature">(game)</span><span class="type-signature"> → {boolean}</span></h4> <div class="description"> Check if dice has been rolled </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line758">line 758</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - True if dice has been rolled (turnDice is not null) </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".hasMoreMoves"><span class="type-signature">(static) </span>hasMoreMoves<span class="signature">(game)</span><span class="type-signature"> → {boolean}</span></h4> <div class="description"> Check if there are more moves to make </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line767">line 767</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - True if there are any moves left to make </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".hasMove"><span class="type-signature">(static) </span>hasMove<span class="signature">(game, value)</span><span class="type-signature"> → {boolean}</span></h4> <div class="description"> Check if a specific move value is available in movesLeft </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game</td> </tr> <tr> <td class="name"><code>value</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Move value to check for</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line778">line 778</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - True if specified move value is available </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".init"><span class="type-signature">(static) </span>init<span class="signature">(game, rule)</span><span class="type-signature"></span></h4> <div class="description"> Initialize game object </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game to initialize</td> </tr> <tr> <td class="name"><code>rule</code></td> <td class="type"> <span class="param-type"><a href="Rule.html">Rule</a></span> </td> <td class="description last">Rule to use</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line724">line 724</a> </li></ul></dd> </dl> <h4 class="name" id=".isPlayerTurn"><span class="type-signature">(static) </span>isPlayerTurn<span class="signature">(game, player)</span><span class="type-signature"> → {boolean}</span></h4> <div class="description"> Check if it is specified player's turn </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game</td> </tr> <tr> <td class="name"><code>player</code></td> <td class="type"> <span class="param-type"><a href="Player.html">Player</a></span> </td> <td class="description last">Specified player</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line736">line 736</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - True if it is specified player's turn </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".isTypeTurn"><span class="type-signature">(static) </span>isTypeTurn<span class="signature">(game, type)</span><span class="type-signature"> → {boolean}</span></h4> <div class="description"> Check if it is specified player's turn, but check by their piece type, and not player object </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game</td> </tr> <tr> <td class="name"><code>type</code></td> <td class="type"> <span class="param-type"><a href="global.html#PieceType">PieceType</a></span> </td> <td class="description last">Player's piece type</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line748">line 748</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - True if it is specified player's turn </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".restoreState"><span class="type-signature">(static) </span>restoreState<span class="signature">(game)</span><span class="type-signature"></span></h4> <div class="description"> Restore game state from last snapshot - if player requested to undoing of moves </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line796">line 796</a> </li></ul></dd> </dl> <h4 class="name" id=".snapshotState"><span class="type-signature">(static) </span>snapshotState<span class="signature">(game)</span><span class="type-signature"></span></h4> <div class="description"> Store current game state - in case the player wants to undo moves later </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>game</code></td> <td class="type"> <span class="param-type"><a href="Game.html">Game</a></span> </td> <td class="description last">Game</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="model.js.html">model.js</a>, <a href="model.js.html#line787">line 787</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Dice.html">Dice</a></li><li><a href="Game.html">Game</a></li><li><a href="Match.html">Match</a></li><li><a href="MoveAction.html">MoveAction</a></li><li><a href="Piece.html">Piece</a></li><li><a href="Player.html">Player</a></li><li><a href="PlayerStats.html">PlayerStats</a></li><li><a href="Random.html">Random</a></li><li><a href="Rule.html">Rule</a></li><li><a href="RuleBgCasual.html">RuleBgCasual</a></li><li><a href="RuleBgGulbara.html">RuleBgGulbara</a></li><li><a href="RuleBgTapa.html">RuleBgTapa</a></li><li><a href="State.html">State</a></li><li><a href="Utils.html">Utils</a></li></ul><h3>Global</h3><ul><li><a href="global.html#Message">Message</a></li><li><a href="global.html#MoveActionType">MoveActionType</a></li><li><a href="global.html#PieceType">PieceType</a></li><li><a href="global.html#Protocol">Protocol</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Dec 18 2016 20:10:05 GMT+0200 (EET) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>