moneypot
v1.0.1
Published
Node.js package for Moneypot
Downloads
2
Readme
API Reference
Amounts of Bitcoin are given and expected in satoshi (0.00000001 BTC) unless noted otherwise.
Multipliers are given and expected in integer format, e.g. 1920
for 19.20x unless noted otherwise.
calculateElapsed(multiplier) -> Number
calculateMultiplier(elapsed) -> Number
getCookie(options) -> Promise
getToken(options) -> Promise
formatBTC(amount, [unit]) -> String
losingOdds(multiplier, [start]) -> Number
winningOdds(multiplier, [start]) -> Number
Game
Player
Session
MoneyPot
calculateElapsed(multiplier) -> Number
Calculate the amount of time in milliseconds that must pass for multiplier
to be reached.
calculateMultiplier(elapsed) -> Number
Calculate the current multiplier of a game after a given amount of time in milliseconds has passed.
getCookie(options) -> Promise
Acquire a new session cookie and return a Bluebird Promise.
options
must be an Object that must have the fields username
and password
, which will be used to obtain a new session cookie.
options
may also contain a loginURI
String field, which will override the default login URI of https://www.moneypot.com/login
.
getToken(options) -> Promise
Acquire a new one-time token and return a Bluebird Promise.
options
must be an Object that must have a cookie
field, which will be used to obtain the one-time token.
options
may also contain a tokenURI
String field, which will override the default one-time token URI of https://www.moneypot.com/ott
.
formatBTC(amount, [unit]) -> String
Return a string representation of amount
satoshi using unit
, which must be one of the following:
BTC
mBTC
bit
orµBTC
oruBTC
satoshi
If unit
is omitted, an appropriate one is chosen automatically.
losingOdds(target, [start]) -> Number
Calculate the probability of a game crashing before target
is reached rounded to six decimals.
start
is the multiplier which has already been reached at the time of the calculation. If it is omitted, the game is assumed to have not yet started.
winningOdds(target, [start]) -> Number
Calculate the probability of a game crashing after target
is reached rounded to six decimals.
start
is the multiplier which has already been reached at the time of the calculation. If it is omitted, the game is assumed to have not yet started.
Game
{
id: Number,
players: [ Player ],
multiplier: Number,
state: String,
maxWin: Number
}
new Game([players]) -> Game
Return a new Game.
players
is optional and must be an Array of Player objects. players
is not required to be sorted.
addPlayer(player, [wager, [multiplier]])
Add a new Player to the game's players
array in the correct location.
player
must be either a Player object, in which case wager
and multiplier
are ignored, or a String, in which case a new Player is created.
wager
and multiplier
default to 0 if omitted.
bonus([player]) -> Number or Object
Calculate the boni of the current game.
player
must be a Player or a String, in which case a Number indicating the player's bonus for this game is returned. If it is a Player, it is matched to the player in players
by its name field, not by reference.
If player
is omitted, a map of player names to their respective bonus is returned instead.
changeMultiplier(player, multiplier)
Change a player's multiplier while keeping the sorting order of players
intact.
player
must be a Player or a String. If it is a Player, it is matched to the player in players
by its name field, not by reference.
changeWager(player, wager)
Change a player's wager while keeping the sorting order of players
intact.
player
must be a Player or a String. If it is a Player, it is matched to the player in players
by its name field, not by reference.
clone() -> Object
Create a deep copy of the Game, retaining the standard fields.
contains(player) -> Boolean
Return true
if the game contains player
and false
otherwise.
player
must be a Player or a String. If it is a Player, it is matched to the player in players
by its name field, not by reference.
isSorted() -> Boolean
Returns true
if the game's players
array is correctly sorted and false
otherwise.
Player
{
name: String,
wager: Number,
multiplier: Number,
}
new Player(name, [wager, [multiplier]]) -> Player
Create a new Player.
wager
and multiplier
both default to 0 when omitted.
Session
{
username: String,
balance: Number,
game: Game
}
new Session(options) -> Promise
Open a new connection to MoneyPot and return a Bluebird Promise that resolves with an array containing the Session and the results from the join process as soon as the join process is completed.
options
must be an Object that may have a token
field, which is a one-time token as returned by MoneyPot.getToken
in String from. If no token
field is provided, an unauthenticated session is created.
options
may also contain a socketURI
String field, which will override the default game server URI of wss://game.moneypot.com
.
cashOut([multiplier]) -> Promise
Cash the player out and return a Bluebird Promise.
If multiplier
is given, the player is attempted to be cashed out at that multiplier or immediately if the multiplier has already passed.
If multiplier
is omitted, the cash-out is attempted immediately.
close()
Close the underlying socket.
submitWager(wager, [multiplier]) -> Promise
Make a new bet with an optional auto cash-out multiplier and return a Bluebird Promise.