- AnyBoard :
object Global variable AnyBoard.
- playDrawCallback :
function This type of callback will be called when card is drawn or played
- simpleEventCallback :
function Type of callback called upon triggering of events
- tokenTokenEventCallback :
function Type of callback called upon token-token events, i.e. when two tokens interact with eachother, wuch as 'STACK_ON', 'NEXT_TO'
- tokenEventCallback :
function Type of callback called upon triggering of a Token event, i.e. events triggered by the physical interaction with tokens, such as 'LIFT', 'SHAKE', 'TURN'
- tokenConstraintEventCallback :
function Type of callback called upon triggering of a Token-Constraint event, i.e. events triggered by the physical interaction of a token upon a constraint, such as 'MOVED_TO'
- stdStringCallback :
function Generic callback returning a string param
- stdBoolCallback :
function Generic callback returning a bool param
- stdNoParamCallback :
function Generic callback without params
- onScanCallback :
function Type of callback called upon detecting a token
- stdErrorCallback :
function This type of callback will be called upon failure to complete a function
object
Global variable AnyBoard.
Kind: global variable
- AnyBoard :
object- .Driver
- new AnyBoard.Driver(options)
- .toString() ⇒
string
- .Deck
- new AnyBoard.Deck(name, jsonDeck)
- instance
- static
- .Card
- new AnyBoard.Card(deck, options)
- instance
- .onPlay(func)
- .onDraw(callback)
- .toString() ⇒
string
- static
- .Dice
- new AnyBoard.Dice([eyes], [numOfDice])
- .roll() ⇒
number - .rollEach() ⇒
Array
- .Player
- new AnyBoard.Player(name, [options])
- instance
- .pay(resources, [receivingPlayer]) ⇒
boolean - .trade(giveResources, receiveResources, [player]) ⇒
boolean - .recieve(resourceSet)
- .draw(deck, [options]) ⇒
Card - .play(card, [customOptions]) ⇒
boolean - .toString() ⇒
string
- .pay(resources, [receivingPlayer]) ⇒
- static
- .Hand
- .Resource
- .ResourceSet
- .BaseToken
- new AnyBoard.BaseToken(name, address, device, [driver])
- instance
- .isConnected() ⇒
boolean - .connect([win], [fail])
- .disconnect()
- .trigger(eventName, [eventOptions])
- .on(eventName, callbackFunction)
- .once(eventName, callbackFunction)
- .send(data, [win], [fail])
- .print(value, [win], [fail])
- .getFirmwareName([win], [fail])
- .getFirmwareVersion([win], [fail])
- .getFirmwareUUID([win], [fail])
- .hasLed([win], [fail])
- .hasLedColor([win], [fail])
- .hasVibration([win], [fail])
- .hasColorDetection([win], [fail])
- .hasLedScreen([win], [fail])
- .hasRfid([win], [fail])
- .hasNfc([win], [fail])
- .hasAccelometer([win], [fail])
- .hasTemperature([win], [fail])
- .ledOn(value, [win], [fail])
- .ledBlink(value, [win], [fail])
- .ledOff([win], [fail])
- .toString() ⇒
string
- .isConnected() ⇒
- static
- .setDefaultDriver(driver) ⇒
boolean
- .setDefaultDriver(driver) ⇒
- .Drivers :
Object- .get(name) ⇒
Driver|undefined - .getCompatibleDriver(type, compatibility) ⇒
Driver
- .get(name) ⇒
- .TokenManager
- .setDriver(driver)
- .scan([win], [fail], [timeout])
- .get(address) ⇒
BaseToken - .onTokenTokenEvent(eventName, callbackFunction)
- .onceTokenTokenEvent(eventName, callbackFunction)
- .onTokenConstraintEvent(eventName, callbackFunction)
- .onceTokenConstraintEvent(eventName, callbackFunction)
- .onTokenEvent(eventName, callbackFunction)
- .onceTokenEvent(eventName, callbackFunction)
- .Logger
- .Utils
- .isEqual(a, b, [aStack], [bStack]) ⇒
boolean
- .isEqual(a, b, [aStack], [bStack]) ⇒
- .Driver
Kind: static class of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| name | string |
name of the driver |
| description | string |
description of the driver |
| version | string |
version of the driver |
| dependencies | string |
Text describing what, if anything, the driver depends on. |
| date | string |
Date upon release/last build. |
| type | Array |
Array of string describing Type of driver, e.g. "bluetooth" |
| compatibility | Array | object | string |
An object or string that can be used to deduce compatibiity, or an array of different compatibilies. |
| properties | object |
dictionary that holds custom attributes |
Represents a single Driver, e.g. for spesific token or bluetooth discovery
| Param | Type | Description |
|---|---|---|
| options | object |
options for the driver |
| options.name | string |
name of the driver |
| options.description | string |
description of the driver |
| options.version | string |
version of the driver |
| options.type | string |
Type of driver, e.g. "bluetooth" |
| options.compatibility | Array | object | string |
An object or string that can be used to deduce compatibiity, or an array of different compatibilies. How this is used is determined by the set standard driver on TokenManager that handles scanning for and connecting to tokens. |
| [options.dependencies] | string |
(optional) What if anything the driver depends on. |
| [options.date] | string |
(optional) Date upon release/last build. |
| options.yourAttributeHere | any |
custom attributes, as well as specified ones, are all placed in driver.properties. E.g. 'heat' would be placed in driver.properties.heat. |
Returns a short description of the Driver instance
Kind: instance method of Driver
Kind: static class of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| name | string |
name of Deck. |
| cards | Array.<Card> |
complete set of cards in the deck |
| pile | Array.<Card> |
remaining cards in this pile |
| usedPile | Array.<Card> |
cards played from this deck |
| autoUsedRefill | boolean |
(default: true) whether or not to automatically refill pile from usedPile when empty. Is ignored if autoNewRefill is true. |
| autoNewRefill | boolean |
(default: false) whether or not to automatically refill pile with a whole new deck when empty. |
| playListeners | Array.<playDrawCallback> |
holds functions to be called when cards in this deck are played |
| drawListeners | Array.<playDrawCallback> |
holds functions to be called when cards in this deck are drawn |
- .Deck
- new AnyBoard.Deck(name, jsonDeck)
- instance
- static
Represents a Deck of Cards
| Param | Type | Description |
|---|---|---|
| name | string |
name of Deck. This name can be used to retrieve the deck via AnyBoard.Deck.all[name]. |
| jsonDeck | object |
loaded JSON file. See examples/deck-loading/ for JSON format and loading. |
Shuffles the pile of undrawn cards . Pile is automatically shuffled upon construction, and upon initiate(). New cards added upon refill() are also automatically shuffled.
Kind: instance method of Deck
Manually refills the pile. This is not necessary if autoUsedRefill or autoNewRefill property of deck is true.
Kind: instance method of Deck
| Param | Type | Default | Description |
|---|---|---|---|
| [newDeck] | boolean |
false |
True if to refill with a new deck. False if to refill with played cards (from usedPile) |
Adds functions to be executed upon all Cards in this Deck.
Kind: instance method of Deck
| Param | Type | Description |
|---|---|---|
| func | playDrawCallback |
callback function to be executed upon play of card from this deck |
Adds functions to be executed upon draw of Card from this Deck
Kind: instance method of Deck
| Param | Type | Description |
|---|---|---|
| callback | playDrawCallback |
function to be executed with the 3 parameters AnyBoard.Card, AnyBoard.Player, (options) when cards are drawn |
Sting representation of a deck
Kind: instance method of Deck
Deck.get(name) ⇒ Deck
Returns deck with given name
Kind: static method of Deck
Returns: Deck - deck with given name (or undefined if non-existent)
| Param | Type | Description |
|---|---|---|
| name | string |
name of deck |
Kind: static class of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| title | string |
title of the card. |
| description | string |
description for the Card |
| color | string |
color of the Card |
| category | string |
category of the card, not used by AnyBoard FrameWork |
| value | number |
value of the card, not used by AnyBoard FrameWork |
| type | string |
type of the card, not used by AnyBoard FrameWork |
| amount | number |
amount of this card its deck |
| deck | Deck |
deck that this card belongs to |
| playListeners | Array.<playDrawCallback> |
holds functions to be called upon play of this spesific card (before potential playListeners on its belonging deck) |
| drawListeners | Array.<playDrawCallback> |
holds functions to be called upon draw of this spesific card (before potential drawListeners on its belonging deck) |
| properties | object |
dictionary that holds custom attributes |
- .Card
- new AnyBoard.Card(deck, options)
- instance
- .onPlay(func)
- .onDraw(callback)
- .toString() ⇒
string
- static
Represents a single Card Should be instantiated in bulk by calling the deck constructor
| Param | Type | Default | Description |
|---|---|---|---|
| deck | Deck |
deck to which the card belongs | |
| options | object |
options for the card | |
| options.title | string |
title of the card. | |
| options.description | string |
description for the Card | |
| [options.color] | string |
(optional) color of the Card | |
| [options.category] | string |
(optional) category of the card, not used by AnyBoard FrameWork | |
| [options.value] | number |
(optional) value of the card, not used by AnyBoard FrameWork | |
| [options.type] | string |
(optional) type of the card, not used by AnyBoard FrameWork | |
| [options.amount] | number |
1 |
amount of this card in the deck |
| [options.yourAttributeHere] | any |
custom attributes, as well as specified ones, are all placed in card.properties. E.g. 'heat' would be placed in card.properties.heat. |
Adds functions to be executed upon a play of this card
Kind: instance method of Card
| Param | Type | Description |
|---|---|---|
| func | playDrawCallback |
callback function to be executed upon play of card from this deck |
Adds functions to be executed upon a draw of this card
Kind: instance method of Card
| Param | Type | Description |
|---|---|---|
| callback | playDrawCallback |
function to be executed upon play of card from this deck |
Returns a string representation of the card.
Kind: instance method of Card
Card.get(cardTitleOrID) ⇒ Card
Returns card with given id
Kind: static method of Card
Returns: Card - card with given id (or undefined if non-existent)
| Param | Type | Description |
|---|---|---|
| cardTitleOrID | number | string |
id or title of card |
Kind: static class of AnyBoard
- .Dice
- new AnyBoard.Dice([eyes], [numOfDice])
- .roll() ⇒
number - .rollEach() ⇒
Array
Represents a set of game dices that can be rolled to retrieve a random result.
| Param | Type | Default | Description |
|---|---|---|---|
| [eyes] | number |
6 |
number of max eyes on a roll with this dice |
| [numOfDice] | number |
1 |
number of dices |
Example
// will create 1 dice, with 6 eyes
var dice = new AnyBoard.Dice();
// will create 2 dice, with 18 eyes
var dice = new AnyBoard.Dice(18, 2);Roll the dices and returns a the sum
Kind: instance method of Dice
Returns: number - combined result of rolls for all dices
Example
var dice = new AnyBoard.Dice();
// returns random number between 1 and 6
dice.roll()Example
var dice = new AnyBoard.Dice(12, 2);
// returns random number between 2 and 24
dice.roll()Roll the dices and returns an array of results for each dice
Kind: instance method of Dice
Returns: Array - list of results for each dice
Example
var dice = new AnyBoard.Dice(8, 2);
// returns an Array of numbers
var resultArray = dice.rollEach()
// result of first dice, between 1-8
resultArray[0]
// result of second dice, between 1-8
resultArray[1]Kind: static class of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| hand | Hand |
hand of cards (Quests) |
| faction | string |
faction (Sp[ecial abilities or perks) |
| class | string |
class (Special abilities or perks) |
| holds | ResourceSet |
the resources belonging to this player |
| color | string |
color representation of player |
- .Player
- new AnyBoard.Player(name, [options])
- instance
- .pay(resources, [receivingPlayer]) ⇒
boolean - .trade(giveResources, receiveResources, [player]) ⇒
boolean - .recieve(resourceSet)
- .draw(deck, [options]) ⇒
Card - .play(card, [customOptions]) ⇒
boolean - .toString() ⇒
string
- .pay(resources, [receivingPlayer]) ⇒
- static
Represents a Player (AnyBoard.Player)
| Param | Type | Description |
|---|---|---|
| name | string |
name of the player |
| [options] | object |
(optional) options for the player |
| [options.color] | string |
(optional) color representing the player |
| [options.faction] | string |
(optional) faction representing the player |
| [options.class] | string |
(optional) class representing the player |
| [options.yourAttributeHere] | any |
(optional) custom attributes, as well as specified ones, are all placed in player.properties. E.g. 'age' would be placed in player.properties.age. |
Take resources from this player and give to receivingPlayer.
Kind: instance method of Player
Returns: boolean - whether or not transaction was completed (false if Player don't hold enough resources)
| Param | Type | Description |
|---|---|---|
| resources | ResourceSet |
dictionary of resources |
| [receivingPlayer] | Player |
(optional) Who shall receive the resources. Omit if not to anyone (e.g. give to "the bank") |
Trade resources between players/game
Kind: instance method of Player
Returns: boolean - whether or not transaction was completed (false if Player don't hold enough resources)
| Param | Type | Description |
|---|---|---|
| giveResources | ResourceSet |
resources this player shall give |
| receiveResources | ResourceSet |
resources this player receieves |
| [player] | Player |
(optional) Who shall be traded with. Omit if not to a player, but to "the bank". |
Example
new AnyBoard.Resource("gold");
new AnyBoard.Resource("silver");
var startTreasure = new AnyBoard.ResourceSet({"gold": 6, "silver": 42});
var goldTreasure = new AnyBoard.ResourceSet({"gold": 2});
var silverTreasure = new AnyBoard.ResourceSet({"silver": 12});
var dr1 = new AnyBoard.Player("firstDoctor");
var dr2 = new AnyBoard.Player("secondDoctor");
dr1.receive(startTreasure);
dr2.receive(startTreasure);
// returns true. dr1 will now own {"gold": 4, "silver": 54}. dr2 owns {"gold": 8, "silver": 30}
dr1.trade(goldTreasure, silverTreasure, dr2)Example
// returns true. dr1 will now own {"gold": 2, "silver": 66}. dr2 still owns {"gold": 8, "silver": 30}
dr1.trade(goldTreasure, silverTreasure)Example
var firstOverlappingTreasure = new AnyBoard.ResourceSet({"silver": 115, "gold": "6"});
var secondOverlappingTreasure= new AnyBoard.ResourceSet({"silver": 100, "gold": "7"});
// returns true. The trade nullifies the similarities, so that the trade can go through even though
// dr1 has < 100 silver
dr1.trade(firstOverlappingTreasure, secondOverlappingTreasure)Receive resource from bank/game. Use pay() when receiving from players.
Kind: instance method of Player
| Param | Type | Description |
|---|---|---|
| resourceSet | ResourceSet |
resources to be added to this players bank |
Example
new AnyBoard.Resource("gold");
new AnyBoard.Resource("silver");
var startTreasure = new AnyBoard.ResourceSet({"gold": 6, "silver": 42});
var secondTresure = new AnyBoard.ResourceSet({"silver": 12, "copper": 122});
var dr1 = new AnyBoard.Player("firstDoctor"); // player owns nothing initially
dr1.receive(startTreasure); // owns {"gold": 6, "silver": 42}
dr1.receive(secondTresure); // owns {"gold": 6, "silver": 54, "copper": 122}player.draw(deck, [options]) ⇒ Card
Draws a card from a deck and puts it in the hand of the player
Kind: instance method of Player
Returns: Card - card that is drawn
| Param | Type | Description |
|---|---|---|
| deck | Deck |
deck to be drawn from |
| [options] | object |
(optional) parameters to be sent to the drawListeners on the deck |
Example
var dr1 = new AnyBoard.Player("firstDoctor"); // player has no cards initially
// Now has one card
dr1.draw(deck);
// Now has two cards. option parameter is being passed on to any drawListeners (See Deck/Card)
dr1.draw(deck, options);Plays a card from the hand. If the hand does not contain the card, the card is not played and the hand unchanged.
Kind: instance method of Player
Returns: boolean - whether or not the card was played
| Param | Type | Description |
|---|---|---|
| card | Card |
card to be played |
| [customOptions] | object |
(optional) custom options that the play should be played with |
Example
var DrWho = new AnyBoard.Player("firstDoctor"); // player has no cards initially
// Store the card that was drawn
var card = DrWho.draw(existingDeck);
// Play that same card
DrWho.play(card)Returns a string representation of the player
Kind: instance method of Player
Player.get(name) ⇒ Player
Returns player with given name
Kind: static method of Player
Returns: Player - player with given name (or undefined if non-existent)
| Param | Type | Description |
|---|---|---|
| name | string |
name of player |
Kind: static class of AnyBoard
Represents a Hand of a player, containing cards. Players are given one Hand in Person constructor.
| Param | Type | Description |
|---|---|---|
| player | Player |
player to which this hand belongs |
| [options] | object |
(optional) custom properties added to this hand |
Checks whether or not a player has an amount card in this hand.
Kind: instance method of Hand
Returns: boolean - hasCard whether or not the player has that amount or more of that card in this hand
| Param | Type | Default | Description |
|---|---|---|---|
| card | Card |
card to be checked if is in hand | |
| [amount] | number |
1 |
amount of card to be checked if is in hand |
Example
var DrWho = new AnyBoard.Player("firstDoctor"); // player has no cards initially
// Store the card that was drawn
var tardis = DrWho.draw(tardisDeck);
// returns true
DrWho.hand.has(card)
// returns false, as he has only one
DrWho.hand.has(card, 3)Discard the entire hand of the player, leaving him with no cards
Kind: instance method of Hand
Discard a card from the hand of the player
Kind: instance method of Hand
| Param | Type | Description |
|---|---|---|
| card | Card |
card to be discarded. |
Returns a string representation of the hand
Kind: instance method of Hand
Kind: static class of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| name | string |
name of resource |
| properties | any |
custom options added to resource |
Represents a simple resource (AnyBoard.Resource)
| Param | Type | Description |
|---|---|---|
| name | string |
name representing the resource |
| [properties] | object |
(optional) custom properties of this resource |
Example
var simpleGold = new AnyBoard.Resource("gold");
// The optional properties parameter can be of any type.
var advancedPowder = new AnyBoard.Resource("powder", {"value": 6, "color": "blue"});
// 6
advancedPowder.properties.valueResource.get(name) ⇒ Resource
Returns resource with given name
Kind: static method of Resource
Returns: Resource - resource with given name (or undefined if non-existent)
| Param | Type | Description |
|---|---|---|
| name | string |
name of resource |
Example
var simpleGold = new AnyBoard.Resource("gold");
// returns simpleGold
AnyBoard.Resource.get("gold");Kind: static class of AnyBoard
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| resources | object |
(optional) a set of initially contained resources | |
| allowNegative | boolean |
false |
whether or not to allow being subtracted resources to below 0 (dept) |
Creates a ResourceSet
| Param | Type | Default | Description |
|---|---|---|---|
| [resources] | object |
(optional) a set of initially contained resources | |
| [allowNegative] | boolean |
false |
whether or not to allow being subtracted resources to below 0 (dept) |
Example
// Returns a resourceset that can be deducted below 0
var debtBank = new AnyBoard.ResourceSet({}, true);Whether or not a ResourceSet contains another ResourceSet
Kind: instance method of ResourceSet
Returns: boolean - true if this ResourceSet contains reqResource, else false
| Param | Type | Description |
|---|---|---|
| reqResource | ResourceSet |
ResourceSet to be compared against |
Example
new AnyBoard.Resource("gold");
new AnyBoard.Resource("silver");
var myTreasure = new AnyBoard.ResourceSet({"gold": 6, "silver": 42});
var minorDebt = new AnyBoard.ResourceSet({"gold": 1, "silver": 3});
var hugeDebt = new AnyBoard.ResourceSet({"gold": 12, "silver": 41});
// returns true
myTreasure.contains(minorDebt);
// returns false
myTreasure.contains(hugeDebt);Adds a ResourceSet to this one
Kind: instance method of ResourceSet
| Param | Type | Description |
|---|---|---|
| resourceSet | ResourceSet |
ResourceSet to be added to this one |
Example
new AnyBoard.Resource("gold");
new AnyBoard.Resource("silver");
var myTreasure = new AnyBoard.ResourceSet({"gold": 6, "silver": 42});
var minorGift = new AnyBoard.ResourceSet({"silver": 2});
myTreasure.add(minorGift);
// myTreasure is now {"gold": 6, "silver": 45}Subtracts a dictionary of resources and amounts to a ResourceSet
Kind: instance method of ResourceSet
Returns: boolean - whether or not resources were subtracted successfully
| Param | Type | Description |
|---|---|---|
| resourceSet | ResourceSet |
set of resources to be subtracted |
Example
new AnyBoard.Resource("gold");
new AnyBoard.Resource("silver");
var myTreasure = new AnyBoard.ResourceSet({"gold": 6, "silver": 42});
var minorGift = new AnyBoard.ResourceSet({"silver": 2});
var debtBank = new AnyBoard.ResourceSet({}, true);
var cosyBank = new AnyBoard.ResourceSet();
// returns true. myTreasure becomes {"gold": 6, "silver": 40}
myTreasure.subtract(minorGift);
// returns true. debtbank becomes {"silver": -2}
debtBank.subtract(minorGift);
// returns false and leaves cosyBank unchanged
cosyBank.subtract(minorGift);Returns the common resources and minimum amount between a dictionary of resources and amounts, and this ResourceSet
Kind: instance method of ResourceSet
Returns: object - similarities dictionary of common resources and amounts
| Param | Type | Description |
|---|---|---|
| resourceSet | ResourceSet |
dictionary of resources and amounts to be compared against |
Example
new AnyBoard.Resource("gold");
new AnyBoard.Resource("silver");
var myTreasure = new AnyBoard.ResourceSet({"gold": 6, "silver": 42});
var otherTresure = new AnyBoard.ResourceSet({"silver": 2, "bacon": 12});
// returns {"silver": 2}
myTreasure.similarities(otherTresure);Kind: static class of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| name | string |
name of the token |
| address | string |
address of the token found when scanned |
| connected | boolean |
whether or not the token is connected |
| device | object |
driver spesific data. |
| listeners | object |
functions to be executed upon certain triggered events |
| sendQueue | Array.<function()> |
queue for communicating with |
| cache | object |
key-value store for caching certain communication calls |
| driver | Driver |
driver that handles communication |
- .BaseToken
- new AnyBoard.BaseToken(name, address, device, [driver])
- instance
- .isConnected() ⇒
boolean - .connect([win], [fail])
- .disconnect()
- .trigger(eventName, [eventOptions])
- .on(eventName, callbackFunction)
- .once(eventName, callbackFunction)
- .send(data, [win], [fail])
- .print(value, [win], [fail])
- .getFirmwareName([win], [fail])
- .getFirmwareVersion([win], [fail])
- .getFirmwareUUID([win], [fail])
- .hasLed([win], [fail])
- .hasLedColor([win], [fail])
- .hasVibration([win], [fail])
- .hasColorDetection([win], [fail])
- .hasLedScreen([win], [fail])
- .hasRfid([win], [fail])
- .hasNfc([win], [fail])
- .hasAccelometer([win], [fail])
- .hasTemperature([win], [fail])
- .ledOn(value, [win], [fail])
- .ledBlink(value, [win], [fail])
- .ledOff([win], [fail])
- .toString() ⇒
string
- .isConnected() ⇒
- static
- .setDefaultDriver(driver) ⇒
boolean
- .setDefaultDriver(driver) ⇒
Base class for tokens. Should be used by communication driver upon AnyBoard.TokenManager.scan()
| Param | Type | Default | Description |
|---|---|---|---|
| name | string |
name of the token | |
| address | string |
address of the token found when scanned | |
| device | object |
device object used and handled by driver | |
| [driver] | Driver |
AnyBoard.BaseToken._defaultDriver |
token driver for handling communication with it. |
Returns whether or not the token is connected
Kind: instance method of BaseToken
Returns: boolean - true if connected, else false
Attempts to connect to token. Uses TokenManager driver, not its own, since connect needs to happen before determining suitable driver.
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdNoParamCallback |
(optional) function to be executed upon success |
| [fail] | stdErrorCallback |
(optional) function to be executed upon failure |
Disconnects from the token.
Kind: instance method of BaseToken
Trigger an event on a token. Also used to trigger special events (Token, Token-Token and Token-Eonstraint-events) by specifying 'meta-eventType' = 'token', 'token-token' or 'token-constraint' in eventOptions.
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event |
| [eventOptions] | object |
(optional) dictionary of parameters and values |
Example
var onTimeTravelCallback = function (options) {console.log("The tardis is great!")};
existingToken.on('timeTravelled', onTimeTravelCallback);
// Triggers the function, and prints praise for the tardis
existingToken.trigger('timeTravelled');
existingToken.trigger('timeTravelled'); // prints again
existingToken.trigger('timeTravelled'); // prints againAdds a callbackFunction to be executed always when event is triggered
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | simpleEventCallback |
function to be executed |
Example
var onTimeTravelCallback = function () {console.log("The tardis is great!")};
existingToken.on('timeTravelled', onTimeTravelCallback);
// Triggers the function, and prints praise for the tardis
existingToken.trigger('timeTravelled');
existingToken.trigger('timeTravelled'); // prints again
existingToken.trigger('timeTravelled'); // prints againExample
var onTimeTravelCallback = function (options) {
// Options can be left out of a trigger. You should therefore check
// that input is as expected, throw an error or give a default value
var name = (options && options.name ? options.name : "You're");
console.log(options.name + " is great!");
};
existingToken.on('timeTravelled', onTimeTravelCallback);
// prints "Dr.Who is great!"
existingToken.trigger('timeTravelled', {"name": "Dr.Who"});
// prints "You're great!"
existingToken.trigger('timeTravelled');Adds a callbackFunction to be executed next time an event is triggered
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | simpleEventCallback |
function to be executed |
Example
var onTimeTravelCallback = function (options) {console.log("The tardis is great!")};
existingToken.once('timeTravelled', onTimeTravelCallback);
// Triggers the function, and prints praise for the tardis
existingToken.trigger('timeTravelled');
// No effect
existingToken.trigger('timeTravelled');Sends data to the token. Uses either own driver, or (if not set) TokenManager driver
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| data | Uint8Array | ArrayBuffer | String |
data to be sent |
| [win] | stdNoParamCallback |
(optional) function to be executed upon success |
| [fail] | stdErrorCallback |
(optional) function to be executed upon error |
Prints to Token
String can have special tokens to signify some printer command, e.g. ##n = newLine. Refer to the individual driver for token spesific implementation and capabilites
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| value | string |
|
| [win] | stdNoParamCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Gets the name of the firmware type of the token
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdStringCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Example
// Function to be executed upon name retrieval
var getNameCallback = function (name) {console.log("Firmware name: " + name)};
// Function to be executed upon failure to retrieve name
var failGettingNameCallback = function (name) {console.log("Couldn't get name :(")};
existingToken.getFirmwareName(getNameCallback, failGettingNameCallback);
// Since it's asyncronous, this will be printed before the result
console.log("This comes first!")Gets the version of the firmware type of the token
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdStringCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Gets a uniquie ID the firmware of the token
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdStringCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has simple LED
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has colored LEDs
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has vibration
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has ColorDetection
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has LedSceen
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has RFID reader
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has NFC reader
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has Accelometer
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Checks whether or not the token has temperature measurement
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdBoolCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon failure |
Sets color on token
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| value | string | Array |
string with color name or array of [red, green, blue] values 0-255 |
| [win] | stdNoParamCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon |
Example
// sets Led to white
existingToken.ledOn([255, 255, 255]);
// sets Led to white (See driver implementation for what colors are supported)
existingToken.ledOn("white");tells token to blink its led
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| value | string | Array |
string with color name or array of [red, green, blue] values 0-255 |
| [win] | stdNoParamCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon |
Example
// blinks red
existingToken.ledBlink([255, 0, 0]);
// blinks blue
existingToken.ledBlink("blue");Turns LED off
Kind: instance method of BaseToken
| Param | Type | Description |
|---|---|---|
| [win] | stdNoParamCallback |
(optional) callback function to be called upon successful execution |
| [fail] | stdErrorCallback |
(optional) callback function to be executed upon |
Representational string of class instance.
Kind: instance method of BaseToken
Sets a new default driver to handle communication for tokens without specified driver. The driver must have implement a method send(win, fail) in order to discover tokens.
Kind: static method of BaseToken
Returns: boolean - whether or not driver was successfully set
| Param | Type | Description |
|---|---|---|
| driver | Driver |
driver to be used for communication |
Manager of drivers.
Kind: static property of AnyBoard
- .Drivers :
Object- .get(name) ⇒
Driver|undefined - .getCompatibleDriver(type, compatibility) ⇒
Driver
- .get(name) ⇒
Drivers.get(name) ⇒ Driver | undefined
Returns driver with given name
Kind: static method of Drivers
Returns: Driver | undefined - driver with given name (or undefined if non-existent)
| Param | Type | Description |
|---|---|---|
| name | string |
name of driver |
Example
var discoveryBluetooth = new AnyBoard.Driver({
name: 'theTardisMachine',
description: 'bla bla',
version: '1.0',
type: ['bluetooth-discovery', 'bluetooth'],
compatibility: ['tardis', 'pancakes']
});
// Returns undefined
AnyBoard.Drivers.get("non-existant-driver")
// Returns driver
AnyBoard.Drivers.get("theTardisMachine")Drivers.getCompatibleDriver(type, compatibility) ⇒ Driver
Returns first driver of certain type that matches the given compatibility.
Kind: static method of Drivers
Returns: Driver - compatible driver (or undefined if non-existent)
| Param | Type | Description |
|---|---|---|
| type | string |
name of driver |
| compatibility | string | object |
name of driver |
Example
var discoveryBluetooth = new AnyBoard.Driver({
name: 'theTardisMachine',
description: 'bla bla',
version: '1.0',
type: ['bluetooth-discovery', 'bluetooth'],
compatibility: ['tardis', {"show": "Doctor Who"}]
});
// Returns undefined (right type, wrong compatibility)
AnyBoard.Drivers.getCompatibleDriver('bluetooth', 'weirdCompatibility');
// Returns undefined (wrong type, right compatibility)
AnyBoard.Drivers.getCompatibleDriver('HTTP, {"service": "iCanTypeAnyThingHere"});
// Returns discoveryBluetooth driver
AnyBoard.Drivers.getCompatibleDriver('bluetooth', 'tardis');A token manager. Holds all tokens. Discovers and connects to them.
Kind: static property of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| tokens | object |
dictionary of connect tokens that maps id to object |
| driver | Driver |
driver for communication with tokens. Set with setDriver(driver); |
- .TokenManager
- .setDriver(driver)
- .scan([win], [fail], [timeout])
- .get(address) ⇒
BaseToken - .onTokenTokenEvent(eventName, callbackFunction)
- .onceTokenTokenEvent(eventName, callbackFunction)
- .onTokenConstraintEvent(eventName, callbackFunction)
- .onceTokenConstraintEvent(eventName, callbackFunction)
- .onTokenEvent(eventName, callbackFunction)
- .onceTokenEvent(eventName, callbackFunction)
Sets a new default driver to handle communication for tokens without specified driver. The driver must have implemented methods scan(win, fail, timeout) connect(token, win, fail) and disconnect(token, win, fail), in order to discover tokens.
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| driver | Driver |
driver to be used for communication |
Scans for tokens nearby and stores in discoveredTokens property
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| [win] | onScanCallback |
(optional) function to be executed when devices are found (called for each device found) |
| [fail] | stdErrorCallback |
(optional) function to be executed upon failure |
| [timeout] | number |
(optional) amount of milliseconds to scan before stopping. Driver has a default. |
Example
var onDiscover = function(token) { console.log("I found " + token) };
// Scans for tokens. For every token found, it prints "I found ...")
TokenManager.scan(onDiscover);TokenManager.get(address) ⇒ BaseToken
Returns a token handled by this TokenManager
Kind: static method of TokenManager
Returns: BaseToken - token if handled by this tokenManager, else undefined
| Param | Type | Description |
|---|---|---|
| address | string |
identifer of the token found when scanned |
Adds a callbackFunction to be executed always when a token-token event is triggered
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | tokenTokenEventCallback |
function to be executed |
Example
var cb = function (initToken, resToken, event, options) {
console.log(initToken + " " + event + " " + resToken);
};
TokenManager.onTokenTokenEvent("MOVE_NEXT_TO", cb);
// prints "existingToken MOVE_NEXT_TO anotherToken";
existingToken.trigger("MOVE_NEXT_TO", {"meta-eventType": "token", "token": anotherToken};
// prints "existingToken MOVE_NEXT_TO oldToken";
existingToken.trigger("MOVE_NEXT_TO", {"meta-eventType": "token", "token": anotherToken};Adds a callbackFunction to be executed next time a token-token event is triggered
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | tokenTokenEventCallback |
function to be executed |
Example
var cb = function (initToken, resToken, event, options) {
console.log(initToken + " " + event + " " + resToken);
};
TokenManager.onceTokenTokenEvent("MOVE_NEXT_TO", cb);
// prints "existingToken MOVE_NEXT_TO anotherToken";
existingToken.trigger("MOVE_NEXT_TO", {"meta-eventType": "token-token", "token": anotherToken};
// no effect
existingToken.trigger("MOVE_NEXT_TO", {"meta-eventType": "token-token", "token": anotherToken};Adds a callbackFunction to be executed always when a token-constraint event is triggered. A token-constraint event is a physical token interaction with a game constraint, e.g. moving a pawn within a board.
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | tokenConstraintEventCallback |
function to be executed |
Example
var cb = function (initToken, constraint, event, options) {
console.log(initToken + " " + event + " " + constraint);
};
TokenManager.onTokenConstraintEvent("MOVE", cb);
// prints "existingToken MOVE Tile-5";
existingToken.trigger("MOVE", {"meta-eventType": "token-constraint", "constraint": "Tile-5"};
// prints "existingToken MOVE Tile-5";
existingToken.trigger("MOVE", {"meta-eventType": "token-constraint", "constraint": "Tile-5"};Adds a callbackFunction to be executed next time a token-constraint event is triggered
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | tokenConstraintEventCallback |
function to be executed |
Example
var cb = function (initToken, constraint, event, options) {
console.log(initToken + " " + event + " " + constraint);
};
TokenManager.onceTokenConstraintEvent("MOVE", cb);
// prints "existingToken MOVE Tile-5";
existingToken.trigger("MOVE", {"meta-eventType": "token-constraint"", "constraint": "Tile-5"};
// no effect
existingToken.trigger("MOVE", {"meta-eventType": "token-constraint""};Adds a callbackFunction to be executed always when a token event is triggered. A token event is an physical interaction with a single token.
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | tokenEventCallback |
function to be executed |
Example
var cb = function (initToken, event, options) {
console.log(initToken + " was " + event + "'ed ");
};
TokenManager.onTokenEvent("LIFT", cb);
// prints "existingToken was LIFT'ed"
existingToken.trigger("LIFT", {"meta-eventType": "token"};
// prints "existingToken was LIFT'ed"
existingToken.trigger("LIFT", {"meta-eventType": "token"};Adds a callbackFunction to be executed next time a token event is triggered
Kind: static method of TokenManager
| Param | Type | Description |
|---|---|---|
| eventName | string |
name of event to listen to |
| callbackFunction | tokenEventCallback |
function to be executed |
Example
var cb = function (initToken, event, options) {
console.log(initToken + " was " + event + "'ed ");
};
TokenManager.onceTokenEvent("LIFT", cb);
// prints "existingToken was LIFT'ed"
existingToken.trigger("LIFT", {"meta-eventType": "token"};
// No effect
existingToken.trigger('LIFT');Static logger object that handles logging. Will log using hyper.log if hyper is present (when using Evothings). Will then log all events, regardless of severity
Kind: static property of AnyBoard
Properties
| Name | Type | Description |
|---|---|---|
| threshold | number |
(default: 10) threshold on whether or not to log an event. Any message with level above or equal threshold will be logged |
| debugLevel | number |
(value: 0) sets a threshold for when a log should be considered a debug log event. |
| normalLevel | number |
(value: 10) sets a threshold for when a log should be considered a normal log event. |
| warningLevel | number |
(value: 20) sets a threshold for when a log should be considered a warning. |
| errorLevel | number |
(value: 30) sets a threshold for when a log should be considered a fatal error. |
| loggerObject | object |
(default: console) logging method. Must have implemented .debug(), .log(), .warn() and .error() |
logs a warning. Ignored if threshold > this.warningLevel (default: 20)
Kind: static method of Logger
| Param | Type | Description |
|---|---|---|
| message | string |
event to be logged |
| [sender] | object |
(optional) sender of the message |
logs an error. Will never be ignored.
Kind: static method of Logger
| Param | Type | Description |
|---|---|---|
| message | string |
event to be logged |
| [sender] | object |
(optional) sender of the message |
logs a normal event. Ignored if threshold > this.normalLevel (default: 10)
Kind: static method of Logger
| Param | Type | Description |
|---|---|---|
| message | string |
event to be logged |
| [sender] | object |
(optional) sender of the message |
logs debugging information. Ignored if threshold > this.debugLevel (default: 0)
Kind: static method of Logger
| Param | Type | Description |
|---|---|---|
| message | string |
event to be logged |
| [sender] | object |
(optional) sender of the message |
Sets threshold for logging
Kind: static method of Logger
| Param | Type | Description |
|---|---|---|
| severity | number |
a message has to have before being logged |
Example
// By default, debug doesn't log
AnyBoard.debug("Hi") // does not logExample
// But you can lower the thresholdlevel
AnyBoard.Logger.setThreshold(AnyBoard.Logger.debugLevel)
AnyBoard.debug("I'm here afterall!") // logsExample
// Or increase it to avoid certain logging
AnyBoard.Logger.setThreshold(AnyBoard.Logger.errorLevel)
AnyBoard.warn("The tardis has arrived!") // does not logExample
// But you can never avoid errors
AnyBoard.Logger.setThreshold(AnyBoard.Logger.errorLevel+1)
AnyBoard.error("The Doctor is dead!!") // logsUtility functions for AnyBoard
Kind: static property of AnyBoard
Returns whether or not two objects are equal. Works with objects, dictionaries, and arrays as well.
Kind: static method of Utils
Returns: boolean - whether or not the items were equal
| Param | Type | Description |
|---|---|---|
| a | object | Array | String | number | boolean |
item to compare |
| b | object | Array | String | number | boolean |
item to compare against a |
| [aStack] | Array |
(optional) array of items to further compare |
| [bStack] | Array |
(optional) array of items to further compare |
Example
var tardis = {"quality": "awesome"}
var smardis = {"quality": "shabby"}
var drWhoCar = {"quality": "awesome"}
// Returns true
AnyBoard.Utils.isEqual(tardis, drWhoCar)
// Returns false
AnyBoard.Utils.isEqual(tardis, smardis)This type of callback will be called when card is drawn or played
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| card | Card |
that is played |
| player | Player |
that played the card |
| [options] | object |
(optional) custom options as extra parameter when AnyBoard.Player.play was called |
Type of callback called upon triggering of events
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| [options] | object |
(optional) options called with the triggering of that event |
Type of callback called upon token-token events, i.e. when two tokens interact with eachother, wuch as 'STACK_ON', 'NEXT_TO'
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| initiatingToken | BaseToken |
token whose interaction with has triggered the event |
| respondingToken | BaseToken |
token that initiatingToken has interacted with |
| [options] | object |
(optional) options called with the triggering of that event |
Type of callback called upon triggering of a Token event, i.e. events triggered by the physical interaction with tokens, such as 'LIFT', 'SHAKE', 'TURN'
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| token | BaseToken |
token that has been interacted with |
| [options] | object |
(optional) options called with the triggering of that event |
Type of callback called upon triggering of a Token-Constraint event, i.e. events triggered by the physical interaction of a token upon a constraint, such as 'MOVED_TO'
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| token | BaseToken |
token that triggered the event |
| constraint | string |
constraint that has been interacted with. Currently only a string representation. |
| [options] | object |
(optional) options called with the triggering of that event |
Generic callback returning a string param
Kind: global typedef
| Param | Type |
|---|---|
| string | string |
Generic callback returning a bool param
Kind: global typedef
| Param | Type |
|---|---|
| boolean | boolean |
Generic callback without params
Type of callback called upon detecting a token
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| token | BaseToken |
discovered token |
This type of callback will be called upon failure to complete a function
Kind: global typedef
| Param | Type |
|---|---|
| errorMessage | string |