2015-07-22 16:28:15 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implements Gatherer
|
|
|
|
*
|
|
|
|
* Stores necessary information including:
|
|
|
|
* - user data
|
|
|
|
* - voting preferences
|
|
|
|
* - leader status
|
2015-07-23 13:36:51 +00:00
|
|
|
* - Team: "lobby" "alien" "marine"
|
2015-07-22 16:28:15 +00:00
|
|
|
*/
|
|
|
|
|
2015-07-22 23:30:14 +00:00
|
|
|
var User = require("../user/user");
|
2015-07-22 16:28:15 +00:00
|
|
|
|
2015-07-22 23:30:14 +00:00
|
|
|
function Gatherer (user) {
|
2015-07-24 13:34:02 +00:00
|
|
|
this.leaderVote = null;
|
|
|
|
this.mapVote = null;
|
|
|
|
this.serverVote = null;
|
|
|
|
this.confirm = false;
|
2015-07-22 23:30:14 +00:00
|
|
|
this.id = user.id;
|
2015-07-23 13:36:51 +00:00
|
|
|
this.user = user;
|
2015-07-24 13:34:02 +00:00
|
|
|
this.leader = false;
|
2015-07-23 13:36:51 +00:00
|
|
|
this.team = "lobby";
|
2015-07-22 16:28:15 +00:00
|
|
|
}
|
|
|
|
|
2015-07-27 11:55:36 +00:00
|
|
|
Gatherer.prototype.voteForLeader = function (candidate) {
|
|
|
|
if (candidate === null) {
|
|
|
|
return this.leaderVote = null;
|
|
|
|
}
|
|
|
|
if (typeof candidate === 'number') {
|
|
|
|
return this.leaderVote = candidate;
|
|
|
|
}
|
|
|
|
this.leaderVote = candidate.id;
|
2015-07-24 13:34:02 +00:00
|
|
|
};
|
|
|
|
|
2015-07-22 16:28:15 +00:00
|
|
|
module.exports = Gatherer;
|