UNPKG

koc

Version:

Library to parse data from the online MMORPG Kings of Chaos

4,246 lines (1,273 loc) 65.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Module: koc</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">Module: koc</h1> <section> <header> <h2> koc </h2> </header> <article> <div class="container-overview"> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line10">line 10</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <dl> <dt> <h4 class="name" id="attack"><span class="type-signature"></span>attack<span class="signature">(userid, <span class="optional">turing</span>)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Attack the given user and return the attack detail in case of success </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>userid</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">userid of the defender</td> </tr> <tr> <td class="name"><code>turing</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">turing of this page (optional)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line1218">line 1218</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="attackfield"><span class="type-signature"></span>attackfield<span class="signature">()</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the page of the battlefield we are listed on </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line970">line 970</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="attackLog"><span class="type-signature"></span>attackLog<span class="signature">(b_start, o_start)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the attack log </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>b_start</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">page (by you)</td> </tr> <tr> <td class="name"><code>o_start</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">page (on you)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line928">line 928</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="attackOrRaid"><span class="type-signature"></span>attackOrRaid<span class="signature">(attack_type, userid, <span class="optional">turing</span>)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Attack or Raid the given user with the given turing (optional) </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>attack_type</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>userid</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>turing</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </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="koc.js.html">koc.js</a>, <a href="koc.js.html#line1133">line 1133</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="battlefield"><span class="type-signature"></span>battlefield<span class="signature">(page)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the given battlefield page </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>page</code></td> <td class="type"> <span class="param-type">number</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="koc.js.html">koc.js</a>, <a href="koc.js.html#line983">line 983</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="battleReport"><span class="type-signature"></span>battleReport<span class="signature">(attack_id)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the battle report </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>attack_id</code></td> <td class="type"> <span class="param-type">number</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="koc.js.html">koc.js</a>, <a href="koc.js.html#line1006">line 1006</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="buyWeapons"><span class="type-signature"></span>buyWeapons<span class="signature">(turing, inputNameValue)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Buy weapons. Use getArmory() to find out the turing and inputNameValue. </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>turing</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">The turing of the last armory page you visited</td> </tr> <tr> <td class="name"><code>inputNameValue</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">example: { "buy_weapon[62]": 1, "buy_weapon[25]: 14 }</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line809">line 809</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="changeRace"><span class="type-signature"></span>changeRace<span class="signature">(new_race)</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Change the race </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>new_race</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">the race to change to</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line624">line 624</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> A promise which will eventually succeed and parse the base </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="createRequestPromise"><span class="type-signature"></span>createRequestPromise<span class="signature">(options, onSuccess)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Given express options, create and return a request promise to KoC server </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>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The options to send to request</td> </tr> <tr> <td class="name"><code>onSuccess</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Callback to call on success</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line248">line 248</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> the HTTP request promise (use .then() and .fail() on it) </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getChangeCommanderInfo"><span class="type-signature"></span>getChangeCommanderInfo<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Get the number of times we can change the commander and the statement to copy (image) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line656">line 656</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> A promise which if succeed returns an object with 'success', 'nbTimesCanChange', 'errorMessage' and 'statement' properties </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getKoCHost"><span class="type-signature"></span>getKoCHost<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> </dt> <dd> <div class="description"> Get the base URL of KoC website </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line62">line 62</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> KoC URL </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getKoCReCaptchaUrl"><span class="type-signature"></span>getKoCReCaptchaUrl<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> </dt> <dd> <div class="description"> Get the URL of the Javascript to get a new challenge for KoC </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line79">line 79</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> captcha url </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getKoCSessionCookieName"><span class="type-signature"></span>getKoCSessionCookieName<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> </dt> <dd> <div class="description"> Get the name of the cookie that KoC uses to store the session id </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line45">line 45</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> the cookie name </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getRacesInformation"><span class="type-signature"></span>getRacesInformation<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Get the races information </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line597">line 597</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> A promise to the races information </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getReCaptchaChallenge"><span class="type-signature"></span>getReCaptchaChallenge<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Get a new ReCaptcha challenge for KoC </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line381">line 381</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Promise of the HTTP request which should return an object containing "success" and "session" fields at least. Use .then() and .fail() to catch the promise result </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getRecaptchaImage"><span class="type-signature"></span>getRecaptchaImage<span class="signature">(server, challenge)</span><span class="type-signature"> &rarr; {String}</span></h4> </dt> <dd> <div class="description"> Get a link to a ReCaptcha image given the server and the challenge </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>server</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">ReCaptcha Server</td> </tr> <tr> <td class="name"><code>challenge</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">ReCaptcha challenge</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line89">line 89</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> URL to the ReCaptcha image </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getReCaptchaImageFormat"><span class="type-signature"></span>getReCaptchaImageFormat<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> </dt> <dd> <div class="description"> Get the format of the URL to get the recaptcha image from (server, challenge) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line106">line 106</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> URL format </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getRequestOptions"><span class="type-signature"></span>getRequestOptions<span class="signature">(method, page, <span class="optional">params</span>, <span class="optional">xhr</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Get request options that we can pass to node request </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>method</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> </td> <td class="description last">HTTP method to use (GET, POST, HEAD)</td> </tr> <tr> <td class="name"><code>page</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> </td> <td class="description last">KoC page to request (login.php, battlefield.php, etc...)</td> </tr> <tr> <td class="name"><code>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Parameters for GET and POST requests</td> </tr> <tr> <td class="name"><code>xhr</code></td> <td class="type"> <span class="param-type">Boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Whether or not request through XHR (Ajax)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line190">line 190</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> the options to pass to node request </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getSession"><span class="type-signature"></span>getSession<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> </dt> <dd> <div class="description"> Get current session id </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line123">line 123</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> current session id </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> </dd> <dt> <h4 class="name" id="getUserInfo"><span class="type-signature"></span>getUserInfo<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Get user info. You need to be logged in and have a session already. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line583">line 583</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Return an object with 'success', 'error', 'session' and 'user' </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="hasSession"><span class="type-signature"></span>hasSession<span class="signature">()</span><span class="type-signature"> &rarr; {Boolean}</span></h4> </dt> <dd> <div class="description"> Returns true if there is a session (non empty), false otherwise </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line133">line 133</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> whether or not there is a session set (non empty) </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Boolean</span> </dd> </dl> </dd> <dt> <h4 class="name" id="index"><span class="type-signature"></span>index<span class="signature">()</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the index </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line1043">line 1043</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="intelDetail"><span class="type-signature"></span>intelDetail<span class="signature">(report_id)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the spy report for given report_id </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>report_id</code></td> <td class="type"> <span class="param-type">number</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="koc.js.html">koc.js</a>, <a href="koc.js.html#line1031">line 1031</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="intelFile"><span class="type-signature"></span>intelFile<span class="signature">(asset_id)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the intelligence files for the given asset_id </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>asset_id</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">usually same as the user_id</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line1019">line 1019</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="intelligence"><span class="type-signature"></span>intelligence<span class="signature">(files_start, intercepted_start)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Retrieve the intelligence log </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>files_start</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">page (b_start : by you)</td> </tr> <tr> <td class="name"><code>intercepted_start</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">page (o_start : on you)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line951">line 951</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="login"><span class="type-signature"></span>login<span class="signature">(username, password)</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Login to KoC </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>username</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>password</code></td> <td class="type"> <span class="param-type">String</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="koc.js.html">koc.js</a>, <a href="koc.js.html#line354">line 354</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Promise of the HTTP request which should return an object containing "success" and "session" fields at least. Use .then() and .fail() to catch the promise result </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="prepareResponse"><span class="type-signature"></span>prepareResponse<span class="signature">()</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Wrapper to prepare a response having all the fields. Especially adds the session and the last known location. Nest the result under "result", keeping top-level error/success </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line143">line 143</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="raid"><span class="type-signature"></span>raid<span class="signature">(userid, <span class="optional">turing</span>)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Raid the given user and return the attack detail in case of success </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>userid</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">userid of the defender</td> </tr> <tr> <td class="name"><code>turing</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">turing of this page (optional)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line1228">line 1228</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="recon"><span class="type-signature"></span>recon<span class="signature">(userid, <span class="optional">turing</span>)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Spy the given user and return the intel detail in case of success </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>userid</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">userid of the defender</td> </tr> <tr> <td class="name"><code>turing</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">turing of this page</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="koc.js.html">koc.js</a>, <a href="koc.js.html#line1056">line 1056</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Q.Promise</span> </dd> </dl> </dd> <dt> <h4 class="name" id="register"><span class="type-signature"></span>register<span class="signature">(race, username, password, email, challenge, challenge_response)</span><span class="type-signature"> &rarr; {Object}</span></h4> </dt> <dd> <div class="description"> Register a new user to KoC </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>race</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Humans, Dwarves, Elves, Undead, Orcs</td> </tr> <tr> <td class="name"><code>username</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>password</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>email</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>challenge</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>challenge_response</code></td> <td class="type"> <span class="param-type">String</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="koc.js.html">koc.js</a>, <a href="koc.js.html#line441">line 441</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Promise of the HTTP request which should return an object containing "success" and "session" fields at least. Use .then() and .fail() to catch the promise result </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="requestPage"><span class="type-signature"></span>requestPage<span class="signature">(mustBeLoggedIn, method, page, params, onSuccess, <span class="optional">xhr</span>)</span><span class="type-signature"> &rarr; {Q.Promise}</span></h4> </dt> <dd> <div class="description"> Create a request to KoC website and return a node request promise </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>mustBeLoggedIn</code></td> <td class="type"> <span class="param-type">Boolean</span> </td> <td class="attributes"> </td> <td class="default">