diff --git a/lib/gather/controller.js b/lib/gather/controller.js index 8fdca2e..9c1240e 100644 --- a/lib/gather/controller.js +++ b/lib/gather/controller.js @@ -143,6 +143,10 @@ module.exports = function (namespace) { gather.voteForServer(socket._user, data.server.id); } + if (typeof data.regather === 'boolean' && gather.can("regather")) { + gather.regather(socket._user, data.regather); + } + winston.info("Vote Data", JSON.stringify(socket._user), JSON.stringify(data)); diff --git a/lib/gather/gatherer.js b/lib/gather/gatherer.js index 3dde021..9a1724d 100644 --- a/lib/gather/gatherer.js +++ b/lib/gather/gatherer.js @@ -21,6 +21,7 @@ function Gatherer (user) { this.user = user; this.leader = false; this.team = "lobby"; + this.regatherVote = false; } Gatherer.prototype.voteForLeader = candidate => { @@ -33,4 +34,13 @@ Gatherer.prototype.voteForLeader = candidate => { this.leaderVote = candidate.id; }; +Gatherer.prototype.voteRegather = (vote) => { + if (vote !== undefined && typeof vote === 'boolean') { + return this.regatherVote = vote; + } else { + this.regatherVote = true; + } + return this.regatherVote; +}; + module.exports = Gatherer; \ No newline at end of file diff --git a/lib/react/gather.jsx b/lib/react/gather.jsx index f1f5a57..7c34961 100644 --- a/lib/react/gather.jsx +++ b/lib/react/gather.jsx @@ -298,14 +298,25 @@ var GatherActions = React.createClass({ socket.emit("gather:leave"); }, - confirmTeam(e) { - e.preventDefault(); - socket.emit("gather:select:confirm"); + voteRegather(e) { + e.preventDefault(e); + socket.emit("gather:vote", { + regather: (e.target.value === "true") + }); + }, + + regatherVotes() { + if (!this.props.gather) return 0; + return this.props.gather.gatherers.reduce((acc, gatherer) => { + if (gatherer.regatherVote) acc++; + return acc; + }, 0); }, render() { var joinButton; - if (this.props.currentGatherer) { + var currentGatherer = this.props.currentGatherer; + if (currentGatherer) { joinButton = (
); @@ -317,33 +328,21 @@ var GatherActions = React.createClass({ ); } - var confirmTeam; - if (this.props.currentGatherer && - this.props.currentGatherer.leader && - this.props.gather.state === 'selection' && - this.props.gather.gatherers.every(gatherer => gatherer.team !== 'lobby')) { - if (this.props.currentGatherer.confirm) { - confirmTeam = ( -