mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-01-19 16:11:01 +00:00
Added gather name and description
This commit is contained in:
parent
59b889f1d7
commit
356bd7fe85
2 changed files with 11 additions and 2 deletions
|
@ -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
|
||||
|
@ -36,6 +37,10 @@ function Gather (options) {
|
|||
|
||||
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
|
||||
startTime: null,
|
||||
|
@ -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(),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue