Name: scrabble-score-keeper
Owner: TABLEFLIP
Description: Module for keeping track of scrabble scores
Created: 2015-06-14 07:15:37.0
Updated: 2016-01-06 13:00:41.0
Pushed: 2015-06-17 12:18:08.0
Homepage: null
Size: 101
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
ScoreKeeper = require('scrabble-score-keeper')
keeper = new ScoreKeeper()
points = keeper.play([
har: 'B', x: 0, y: 0},
har: 'I', x: 1, y: 0},
har: 'G', x: 2, y: 0}
Player1')
ole.log('Points for word BIG: ', points)
ScoreKeeper({
ints: {
board: [
[{LS: 1, WS: 3}, /* ... */],
/* ... */
]
An array of rows/columns representing the scrabble board. Each item is an object with letter/word scores in scrabble-board format.
ScoreKeeper({
ints: {
letter: {
A: 1,
B: 2,
/* ... */
}
An object with letter => points mapping.
ScoreKeeper.play(letters[, player])
Place an array of letters on the board. Letters Look like this:
r: 'A', x: 0, y, 0}
char
is the letter to play, x
is the column, y
is the row.
It returns the total points for the letters played and will cause a play
event to be emitted.
ScoreKeeper.undo()
Undo the last play, returning details of the play that was undone. Play details look like:
ters: [{char: 'A', x: 0, y: 0}, /* ... */], points: 13, player: 'team1'}
It causes a undo
event to be emitted.
ScoreKeeper.score([player])
Get the total score, or the total score for a particular player if passed.
ScoreKeeper = require('scrabble-score-keeper')
keeper = new ScoreKeeper()
er.on('play', function (play) {
nsole.log(play.player, 'played', play.letters, 'and scored', play.points, 'points')
The play
event is emitted after a play has been made.
The undo
event is emitted after the last play has been undone.