UNPKG

game-battleship

Version:
712 lines (191 loc) 8.08 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Player</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: Player</h1> <section> <header> <h2><span class="attribs"><span class="type-signature"></span></span>Player<span class="signature">(area, targets, opponentPlayerName, name)</span><span class="type-signature"></span></h2> <div class="class-description">Player</div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="Player"><span class="type-signature"></span>new Player<span class="signature">(area, targets, opponentPlayerName, name)</span><span class="type-signature"></span></h4> <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>area</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">This repreents the battle area of the player</td> </tr> <tr> <td class="name"><code>targets</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Array of all the predefined targets</td> </tr> <tr> <td class="name"><code>opponentPlayerName</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Name of the opponent</td> </tr> <tr> <td class="name"><code>name</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">player's name</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="player.js.html">player.js</a>, <a href="player.js.html#line15">line 15</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="getNextTarget"><span class="type-signature"></span>getNextTarget<span class="signature">(targetIndex)</span><span class="type-signature"> &rarr; {string}</span></h4> <div class="description"> Function to get next target of the player </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>targetIndex</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">: index of the desired target</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="player.js.html">player.js</a>, <a href="player.js.html#line29">line 29</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> target at the index </div> <dl> <dt> Type </dt> <dd> <span class="param-type">string</span> </dd> </dl> <h4 class="name" id="isDefeated"><span class="type-signature"></span>isDefeated<span class="signature">()</span><span class="type-signature"> &rarr; {Boolean}</span></h4> <div class="description"> Function to check if the player is deafted or not </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="player.js.html">player.js</a>, <a href="player.js.html#line61">line 61</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> returns true if area is destroyed else false </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Boolean</span> </dd> </dl> <h4 class="name" id="takeHit"><span class="type-signature"></span>takeHit<span class="signature">(coordinates)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Function to take a hit on this player </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">: hit target</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="player.js.html">player.js</a>, <a href="player.js.html#line38">line 38</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> returns true if hit else false </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</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>