UNPKG

game-battleship

Version:
814 lines (229 loc) 9.23 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Global</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">Global</h1> <section> <header> <h2></h2> </header> <article> <div class="container-overview"> <dl class="details"> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="battle"><span class="type-signature"></span>battle<span class="signature">(player1, player2)</span><span class="type-signature"> &rarr; {Object}</span></h4> <div class="description"> This function is the battle field for the two players, it devises the logic for the players to target each other turn by 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>player1</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">: Player class</td> </tr> <tr> <td class="name"><code>player2</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">: Player Class</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="battle.js.html">battle.js</a>, <a href="battle.js.html#line9">line 9</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> winner: Player </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> <h4 class="name" id="fileReader"><span class="type-signature"></span>fileReader<span class="signature">(filePath, testStream)</span><span class="type-signature"> &rarr; {Promise}</span></h4> <div class="description"> This function would read file from a path line by line and populate the filecontent object for further processing </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>filePath</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>testStream</code></td> <td class="type"> <span class="param-type">Readable</span> </td> <td class="description last">: sole purpose of this stream is for testing</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="utilities_fileReader.js.html">utilities/fileReader.js</a>, <a href="utilities_fileReader.js.html#line14">line 14</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> this would resolve when all of the content is read from the file </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise</span> </dd> </dl> <h4 class="name" id="parseCoordinates"><span class="type-signature"></span>parseCoordinates<span class="signature">(coordinates)</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Helper method to parse coordinates, this would parse the character on its ascii value </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>coordinates</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">: these are the coordinates inside the player area. i.e. "A1"</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="utilities_helpers.js.html">utilities/helpers.js</a>, <a href="utilities_helpers.js.html#line7">line 7</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> It returns the parsed xand y coordinates </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="validateArgs"><span class="type-signature"></span>validateArgs<span class="signature">(fileContents)</span><span class="type-signature"> &rarr; {Object}</span></h4> <div class="description"> This function would validate the filecontents on the basis of pre-defined business rules Rules : 1 <= Width of Battle area (M’) <= 9, A <= Height of Battle area (N’) <= Z 1 <= Number of battleships <= M’ * N’ Type of ship = {‘P’, ‘Q’} 1 <= Width of battleship <= M’ A <= Height of battleship <= N 1 <= X coordinate of ship <= M’ A <= Y coordinate of ship <= N’ </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>fileContents</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="utilities_validator.js.html">utilities/validator.js</a>, <a href="utilities_validator.js.html#line75">line 75</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> ValidatedArgs : This would the object of validated filecontents </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Area.html">Area</a></li><li><a href="Player.html">Player</a></li><li><a href="Ship.html">Ship</a></li></ul><h3>Global</h3><ul><li><a href="global.html#battle">battle</a></li><li><a href="global.html#fileReader">fileReader</a></li><li><a href="global.html#parseCoordinates">parseCoordinates</a></li><li><a href="global.html#validateArgs">validateArgs</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 19 2019 14:14:50 GMT+0530 (India Standard Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>