tableflip/scrabble-score-keeper

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

scrabble-score-keeper

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)
Options
points.board
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.

points.letter
ScoreKeeper({
ints: {
letter: {
  A: 1,
  B: 2,
  /* ... */
}


An object with letter => points mapping.

API
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.

Events
play
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.

undo

The undo event is emitted after the last play has been undone.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.