Added gather name and description

This commit is contained in:
Chris Blanchard 2016-03-18 14:41:06 +00:00
parent 59b889f1d7
commit 356bd7fe85
2 changed files with 11 additions and 2 deletions

View File

@ -15,14 +15,15 @@ const Gatherer = require("./gatherer");
const StateMachine = require("javascript-state-machine");
function Gather (options) {
if (options === undefined) options = {};
if (!(this instanceof Gather)) {
return new Gather(options);
}
this.gatherers = [];
let noop = () => {};
this.onDone = (options && typeof options.onDone === 'function') ?
this.onDone = (typeof options.onDone === 'function') ?
options.onDone : noop;
this.onEvent = (options && typeof options.onEvent === 'function') ?
this.onEvent = (typeof options.onEvent === 'function') ?
options.onEvent : noop;
this.done = {
time: null
@ -35,6 +36,10 @@ function Gather (options) {
this.COOLDOWN_TIME = 60 * 3;// 3 Minutes
this.REGATHER_THRESHOLD = 8;
this.name = options.gatherName || "Public Gather";
this.description = options.description || "6 v 6 - No player requirements";
this.election = {
INTERVAL: 60000, // 1 Minute
@ -308,6 +313,8 @@ Gather.prototype.electionStartTime = function () {
Gather.prototype.toJson = function () {
return {
name: this.name,
description: this.description,
gatherers: this.gatherers,
state: this.current,
pickingTurn: this.pickingTurn(),

View File

@ -223,6 +223,8 @@ describe("Gather Model:", function () {
describe("toJson", function () {
it ("returns a json representation of the gather instance", function () {
var output = gather.toJson();
assert.isString(output.name);
assert.isString(output.description);
assert.isArray(output.gatherers);
assert.isString(output.state);
assert.isNull(output.election.startTime);