Class: CypherPokerContract

CypherPokerContract(gameRef)

A virtual smart contract interface for an associated CypherPokerGame instance. Communicates with an API interface directly rather than being routed through CypherPokerGame communication functions.

Constructor

new CypherPokerContract(gameRef)

Creates a new proxy contract instance.
Parameters:
Name Type Description
gameRef CypherPokerGame The active game instance with which this contract interface is associated.
Source:

Extends

Members

active

Properties:
Name Type Default Description
active Boolean false Indicates whether or not the contract is currently active (recording or resolving a game).
Source:

contractID

Properties:
Name Type Default Description
contractID String null The ID of the contract instance, usually as returned by the remote contract host. If this is null, this instance should not be considered valid.
Source:

cypherpoker

Properties:
Name Type Description
cypherpoker CypherPoker A reference to the CypherPokerContract#game's cypherpoker instance or null if none exists.
Source:

deferredActions

Properties:
Name Type Description
deferredActions Array Indexed list of objects containing game state snapshot, invoke, promise, parent contract, and boolean complete properties.
Source:

deferredActivePromises

Properties:
Name Type Description
deferredActivePromises Array Indexed list of Promise instances currently in the CypherPokerContract#deferredActions array which have the property: complete == false
Source:

deferredPromises

Properties:
Name Type Description
deferredPromises Array Complete indexed list of Promise instances currently in the CypherPokerContract#deferredActions array.
Source:

game

Properties:
Name Type Description
game CypherPokerGame Reference to the associated game for which to act as contract handler.
Source:

history

Properties:
Name Type Default Description
history Array null Indexed array of external contract snapshots with index 0 being the most recent.
Source:

players

Properties:
Name Type Description
players Array Indexed list of {CypherPokerPlayer} instances copied from the associated CypherPokerContract#game instance.
Source:

ready

Properties:
Name Type Default Description
ready Boolean false Indicates whether or not the contract is ready (has been successfully remotely created).
Source:

table

Properties:
Name Type Description
table TableObject A copy of the table associated with the CypherPokerContract#game instance.
Source:

Methods

addEventListener(type, listener, contextopt)

Registers a new event listener with the extending class instance.
Parameters:
Name Type Attributes Default Description
type String The event type to register.
listener function The listening function to invoke on the event.
context Object <optional>
null Unlike the traditional addEventListener parameter, this is the context or scope in which to invoke the listening function (since we can't use capture phases). If null, the listener is invoked in the context of the EventDispatcher or extending instance.
Inherited From:
Source:

gameSnapshot()

Creates a snapshot (copy) of the associated CypherPokerContract#game instance's current data in the format of a contract data object for use as a condition in subsequent contract actions.
Source:

getDealer() → {CypherPokerPlayer}

Returns the CypherPokerPlayer that is currently flagged as the dealer in the CypherPokerContract#players array.
Source:
Returns:
The CypherPokerPlayer instance that is flagged as a dealer. null is returned if no dealer is flagged.
Type
CypherPokerPlayer

getListeners(type) → {Array}

Returns all registered listeners for a specific event type.
Parameters:
Name Type Description
type String The event type to return registered listeners for.
Inherited From:
Source:
Returns:
A list of registered event listener objects for the specific event. Each object contains a listener function reference and an execution context reference.
Type
Array

getPlayer(privateID) → {CypherPokerPlayer}

Returns a CypherPokerPlayer instance associated with this game instance.
Parameters:
Name Type Description
privateID String The private ID of the player.
Source:
Returns:
The CypherPokerPlayer for the private ID associated with this game. null is returned if no matching player private ID can be found.
Type
CypherPokerPlayer

getPlayers(includeKeychainsopt, includePasswordsopt) → {Object}

Returns a condensed array containing the copied properties of the CypherPokerContract#players array. Use the object returned by this function with JSON.stringify instead of using CypherPokerContract#players directly in order to prevent circular reference errors.
Parameters:
Name Type Attributes Default Description
includeKeychains Boolean <optional>
false If true, the CypherPokerPlayer#keychain array of each player will be included in the returned object.
includePasswords Boolean <optional>
false If true, the CypherPokerAccount#password property of each CypherPokerPlayer#account reference will be included with the returned object.
Source:
Returns:
The condensed players array associated with this game instance.
Type
Object

removeEventListener(type, listener, contextopt)

Removes an event listener from the extending instance.
Parameters:
Name Type Attributes Default Description
type String The event type to remove the function from.
listener function The listening function to remove.
context Object <optional>
null The context or scope in which the listener exists.
Inherited From:
Source:

Events

timeout

The contract appears to have timed out due to player inactivity. This is a local event and does not necessarily reflect the state of the actual contract.
Type:
  • Event
Properties:
Name Type Description
contract CypherPokerContract The instance dispatching the event.
penalized Array Array of objects containing private ID(s) and the amount tahat the associated player(s) were penalized. Typically only one player will time out (penalized[0]), but under certain conditions more than one player may time out.
Source:

timeoutinvalid

The contract timeout is no longer valid (e.g. the game has ended).
Type:
  • Event
Properties:
Name Type Description
contract CypherPokerContract The instance dispatching the event.
Source:

timeoutstart

The contract timeout timer has been started or restarted.
Type:
  • Event
Properties:
Name Type Description
contract CypherPokerContract The instance dispatching the event.
seconds Number The number of seconds that must elapse without player activity before the contract times out.
cSeconds Number The number of courtesy seconds that will be allowed to elapse before the contract's "timeout" function is invoked. Note that the timeout may occur at any time after the contract has timed out (hence "courtesy" seconds).
Source: