mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-29 15:42:18 +00:00
Remove captain confirmation
This commit is contained in:
parent
934b707434
commit
973015e927
9 changed files with 177 additions and 103 deletions
|
@ -13,9 +13,10 @@
|
||||||
* gather:vote - Assigns vote to map, leader or server
|
* gather:vote - Assigns vote to map, leader or server
|
||||||
* gather:leave - Leave gather
|
* gather:leave - Leave gather
|
||||||
* gather:select - Select player for team
|
* gather:select - Select player for team
|
||||||
* gather:select:confirm - Confirm selected team
|
|
||||||
* gather:refresh - Refresh gather for client
|
* gather:refresh - Refresh gather for client
|
||||||
*
|
*
|
||||||
|
* gather:reset - Resets gather (ADMIN)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Map = require("./map");
|
var Map = require("./map");
|
||||||
|
@ -24,8 +25,8 @@ var Gather = require("./gather");
|
||||||
var gather = new Gather();
|
var gather = new Gather();
|
||||||
|
|
||||||
// ***** Generate Test Users *****
|
// ***** Generate Test Users *****
|
||||||
// var helper = require("./helper");
|
var helper = require("./helper");
|
||||||
// helper.createTestUsers({ gather: gather });
|
helper.createTestUsers({ gather: gather });
|
||||||
|
|
||||||
module.exports = function (namespace) {
|
module.exports = function (namespace) {
|
||||||
var refreshGather = function () {
|
var refreshGather = function () {
|
||||||
|
@ -83,14 +84,11 @@ module.exports = function (namespace) {
|
||||||
var method = (team === 'alien') ? gather.moveToAlien : gather.moveToMarine;
|
var method = (team === 'alien') ? gather.moveToAlien : gather.moveToMarine;
|
||||||
method.call(gather, selectedPlayer.user);
|
method.call(gather, selectedPlayer.user);
|
||||||
|
|
||||||
refreshGather();
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on("gather:select:confirm", function () {
|
|
||||||
var user = socket._user;
|
|
||||||
if (gather.can("confirmSelection")) {
|
if (gather.can("confirmSelection")) {
|
||||||
gather.confirmSelection(user);
|
gather.confirmSelection(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshGather();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("disconnect", function () {
|
socket.on("disconnect", function () {
|
||||||
|
@ -113,6 +111,13 @@ module.exports = function (namespace) {
|
||||||
refreshGather();
|
refreshGather();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on("gather:reset", function () {
|
||||||
|
if (socket._user.admin) {
|
||||||
|
gather = Gather();
|
||||||
|
refreshGather();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
refreshGather();
|
refreshGather();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,14 +23,6 @@ function Gather () {
|
||||||
this.initState();
|
this.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Gather.prototype.confirmTeam = function (user) {
|
|
||||||
this.modifyGatherer(user, function (gatherer) {
|
|
||||||
if (!gatherer.leader) return gatherer
|
|
||||||
gatherer.confirm = true;
|
|
||||||
return gatherer;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Gather.prototype.alienLeader = function () {
|
Gather.prototype.alienLeader = function () {
|
||||||
return this.gatherers.reduce(function (acc, gatherer) {
|
return this.gatherers.reduce(function (acc, gatherer) {
|
||||||
if (gatherer.team === "alien" && gatherer.leader) acc.push(gatherer);
|
if (gatherer.team === "alien" && gatherer.leader) acc.push(gatherer);
|
||||||
|
@ -229,7 +221,6 @@ StateMachine.create({
|
||||||
// Remove all leaders and teams
|
// Remove all leaders and teams
|
||||||
this.gatherers.forEach(function (gatherer, index, array) {
|
this.gatherers.forEach(function (gatherer, index, array) {
|
||||||
array[index].leader = false;
|
array[index].leader = false;
|
||||||
array[index].confirm = false;
|
|
||||||
array[index].team = "lobby";
|
array[index].team = "lobby";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -254,10 +245,7 @@ StateMachine.create({
|
||||||
this.assignMarineLeader(parseInt(rank.pop().candidate, 0));
|
this.assignMarineLeader(parseInt(rank.pop().candidate, 0));
|
||||||
},
|
},
|
||||||
onbeforeconfirmSelection: function (event, from, to, leader) {
|
onbeforeconfirmSelection: function (event, from, to, leader) {
|
||||||
this.confirmTeam(leader);
|
return (this.aliens().length === this.TEAM_SIZE
|
||||||
return (this.marineLeader().confirm
|
|
||||||
&& this.alienLeader().confirm
|
|
||||||
&& this.aliens().length === this.TEAM_SIZE
|
|
||||||
&& this.marines().length === this.TEAM_SIZE);
|
&& this.marines().length === this.TEAM_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,23 +39,6 @@ var VoteButton = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var JoinGatherButton = React.createClass({
|
|
||||||
joinGather: function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
socket.emit("gather:join", {});
|
|
||||||
},
|
|
||||||
render: function () {
|
|
||||||
var message = this.props.buttonName || "Join Gather";
|
|
||||||
var buttonClass = "btn btn-success";
|
|
||||||
if (this.props.buttonClass) {
|
|
||||||
buttonClass += " " + this.props.buttonClass;
|
|
||||||
}
|
|
||||||
return (<button
|
|
||||||
onClick={this.joinGather}
|
|
||||||
className={buttonClass}>{message}</button>)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var SelectPlayerButton = React.createClass({
|
var SelectPlayerButton = React.createClass({
|
||||||
selectPlayer: function (e) {
|
selectPlayer: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -231,6 +214,10 @@ var GatherProgress = React.createClass({
|
||||||
});
|
});
|
||||||
|
|
||||||
var GatherActions = React.createClass({
|
var GatherActions = React.createClass({
|
||||||
|
joinGather: function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
socket.emit("gather:join");
|
||||||
|
},
|
||||||
leaveGather: function (e) {
|
leaveGather: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
socket.emit("gather:leave");
|
socket.emit("gather:leave");
|
||||||
|
@ -241,6 +228,7 @@ var GatherActions = React.createClass({
|
||||||
},
|
},
|
||||||
inviteToGather: function (e) {
|
inviteToGather: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
alert("Boop!");
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var joinButton;
|
var joinButton;
|
||||||
|
@ -248,8 +236,12 @@ var GatherActions = React.createClass({
|
||||||
joinButton = (<li><button
|
joinButton = (<li><button
|
||||||
onClick={this.leaveGather}
|
onClick={this.leaveGather}
|
||||||
className="btn btn-danger">Leave Gather</button></li>);
|
className="btn btn-danger">Leave Gather</button></li>);
|
||||||
} else {
|
} else if (this.props.gather.state === 'gathering') {
|
||||||
joinButton = (<li><JoinGatherButton /></li>);
|
joinButton = (
|
||||||
|
<button
|
||||||
|
onClick={this.joinGather}
|
||||||
|
className="btn btn-success">Join Gather</button>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var confirmTeam;
|
var confirmTeam;
|
||||||
|
@ -428,7 +420,7 @@ var Gather = React.createClass({
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
if (this.props.gather.state === 'done') {
|
if (this.props.gather.state === 'done') {
|
||||||
return (<h1>Gather Completed! Now restart the app</h1>);
|
return (<CompletedGather {...this.props} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
var voting;
|
var voting;
|
||||||
|
@ -459,8 +451,8 @@ var Gather = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
<GatherProgress gather={this.props.gather} />
|
<GatherProgress gather={this.props.gather} />
|
||||||
<Gatherers gather={this.props.gather} currentGatherer={this.props.currentGatherer} />
|
<Gatherers gather={this.props.gather} currentGatherer={this.props.currentGatherer} />
|
||||||
{voting}
|
|
||||||
{gatherTeams}
|
{gatherTeams}
|
||||||
|
{voting}
|
||||||
<GatherActions {...this.props} />
|
<GatherActions {...this.props} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -468,6 +460,10 @@ var Gather = React.createClass({
|
||||||
});
|
});
|
||||||
|
|
||||||
var Gatherers = React.createClass({
|
var Gatherers = React.createClass({
|
||||||
|
joinGather: function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
socket.emit("gather:join");
|
||||||
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var gatherers = this.props.gather.gatherers.map(function (gatherer) {
|
var gatherers = this.props.gather.gatherers.map(function (gatherer) {
|
||||||
|
@ -529,12 +525,49 @@ var Gatherers = React.createClass({
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<div className="panel-body text-center join-hero">
|
<div className="panel-body text-center join-hero">
|
||||||
<JoinGatherButton buttonClass="btn-lg" buttonName="Start a Gather" />
|
<button
|
||||||
|
onClick={this.joinGather}
|
||||||
|
className="btn btn-success btn-lg">Start a Gather</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var CompletedGather = React.createClass({
|
||||||
|
votedMaps: function () {
|
||||||
|
var maps = this.props.maps;
|
||||||
|
var mapVotes = this.props.gather.gatherers.map(function (gatherer) {
|
||||||
|
return gatherer.mapVote;
|
||||||
|
}).filter(function (elem) {
|
||||||
|
return elem !== null;
|
||||||
|
}).map(function (mapId) {
|
||||||
|
var result;
|
||||||
|
maps.forEach(function (map) {
|
||||||
|
if (map.id === mapId) result = map;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
votedServer: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
render: function () {
|
||||||
|
return (
|
||||||
|
<div className="panel panel-default">
|
||||||
|
<div className="panel-heading">
|
||||||
|
<strong>Gather Completed</strong>
|
||||||
|
</div>
|
||||||
|
<div className="panel-body">
|
||||||
|
<h3>Join Up:</h3>
|
||||||
|
<p>{this.votedMaps()
|
||||||
|
.map(function (map) {return map.name})
|
||||||
|
.join(",")}</p>
|
||||||
|
</div>
|
||||||
|
<GatherTeams gather={this.props.gather} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,4 +47,5 @@ function initialiseComponents () {
|
||||||
React.render(<Chatroom />, document.getElementById('chatroom'));
|
React.render(<Chatroom />, document.getElementById('chatroom'));
|
||||||
React.render(<Gather />, document.getElementById('gathers'));
|
React.render(<Gather />, document.getElementById('gathers'));
|
||||||
React.render(<CurrentUser />, document.getElementById('currentuser'));
|
React.render(<CurrentUser />, document.getElementById('currentuser'));
|
||||||
|
React.render(<AdminPanel />, document.getElementById('admin-menu'));
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,6 +89,28 @@ var UserMenu = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var AdminPanel = React.createClass({
|
||||||
|
handleGatherReset: function () {
|
||||||
|
socket.emit("gather:reset");
|
||||||
|
},
|
||||||
|
render: function () {
|
||||||
|
return (
|
||||||
|
<ul className="nav" id="admin-menu">
|
||||||
|
<li>
|
||||||
|
<div className="admin-panel">
|
||||||
|
<h5>Admin</h5>
|
||||||
|
<button
|
||||||
|
className="btn btn-danger"
|
||||||
|
onClick={this.handleGatherReset}>
|
||||||
|
Reset Gather</button>
|
||||||
|
<p className="text-center"><small>Only responds for admins on staging.ensl.org</small></p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var CurrentUser = React.createClass({
|
var CurrentUser = React.createClass({
|
||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
margin: 0px 10px;
|
margin: 0px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.admin-panel {
|
||||||
|
margin: 10px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.dot {
|
.dot {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
|
|
100
public/js/app.js
100
public/js/app.js
|
@ -39,23 +39,6 @@ var VoteButton = React.createClass({displayName: "VoteButton",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var JoinGatherButton = React.createClass({displayName: "JoinGatherButton",
|
|
||||||
joinGather: function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
socket.emit("gather:join", {});
|
|
||||||
},
|
|
||||||
render: function () {
|
|
||||||
var message = this.props.buttonName || "Join Gather";
|
|
||||||
var buttonClass = "btn btn-success";
|
|
||||||
if (this.props.buttonClass) {
|
|
||||||
buttonClass += " " + this.props.buttonClass;
|
|
||||||
}
|
|
||||||
return (React.createElement("button", {
|
|
||||||
onClick: this.joinGather,
|
|
||||||
className: buttonClass}, message))
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var SelectPlayerButton = React.createClass({displayName: "SelectPlayerButton",
|
var SelectPlayerButton = React.createClass({displayName: "SelectPlayerButton",
|
||||||
selectPlayer: function (e) {
|
selectPlayer: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -231,6 +214,10 @@ var GatherProgress = React.createClass({displayName: "GatherProgress",
|
||||||
});
|
});
|
||||||
|
|
||||||
var GatherActions = React.createClass({displayName: "GatherActions",
|
var GatherActions = React.createClass({displayName: "GatherActions",
|
||||||
|
joinGather: function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
socket.emit("gather:join");
|
||||||
|
},
|
||||||
leaveGather: function (e) {
|
leaveGather: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
socket.emit("gather:leave");
|
socket.emit("gather:leave");
|
||||||
|
@ -241,6 +228,7 @@ var GatherActions = React.createClass({displayName: "GatherActions",
|
||||||
},
|
},
|
||||||
inviteToGather: function (e) {
|
inviteToGather: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
alert("Boop!");
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var joinButton;
|
var joinButton;
|
||||||
|
@ -248,8 +236,12 @@ var GatherActions = React.createClass({displayName: "GatherActions",
|
||||||
joinButton = (React.createElement("li", null, React.createElement("button", {
|
joinButton = (React.createElement("li", null, React.createElement("button", {
|
||||||
onClick: this.leaveGather,
|
onClick: this.leaveGather,
|
||||||
className: "btn btn-danger"}, "Leave Gather")));
|
className: "btn btn-danger"}, "Leave Gather")));
|
||||||
} else {
|
} else if (this.props.gather.state === 'gathering') {
|
||||||
joinButton = (React.createElement("li", null, React.createElement(JoinGatherButton, null)));
|
joinButton = (
|
||||||
|
React.createElement("button", {
|
||||||
|
onClick: this.joinGather,
|
||||||
|
className: "btn btn-success"}, "Join Gather")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var confirmTeam;
|
var confirmTeam;
|
||||||
|
@ -428,7 +420,7 @@ var Gather = React.createClass({displayName: "Gather",
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
if (this.props.gather.state === 'done') {
|
if (this.props.gather.state === 'done') {
|
||||||
return (React.createElement("h1", null, "Gather Completed! Now restart the app"));
|
return (React.createElement(CompletedGather, React.__spread({}, this.props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
var voting;
|
var voting;
|
||||||
|
@ -459,8 +451,8 @@ var Gather = React.createClass({displayName: "Gather",
|
||||||
),
|
),
|
||||||
React.createElement(GatherProgress, {gather: this.props.gather}),
|
React.createElement(GatherProgress, {gather: this.props.gather}),
|
||||||
React.createElement(Gatherers, {gather: this.props.gather, currentGatherer: this.props.currentGatherer}),
|
React.createElement(Gatherers, {gather: this.props.gather, currentGatherer: this.props.currentGatherer}),
|
||||||
voting,
|
|
||||||
gatherTeams,
|
gatherTeams,
|
||||||
|
voting,
|
||||||
React.createElement(GatherActions, React.__spread({}, this.props))
|
React.createElement(GatherActions, React.__spread({}, this.props))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -468,6 +460,10 @@ var Gather = React.createClass({displayName: "Gather",
|
||||||
});
|
});
|
||||||
|
|
||||||
var Gatherers = React.createClass({displayName: "Gatherers",
|
var Gatherers = React.createClass({displayName: "Gatherers",
|
||||||
|
joinGather: function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
socket.emit("gather:join");
|
||||||
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var gatherers = this.props.gather.gatherers.map(function (gatherer) {
|
var gatherers = this.props.gather.gatherers.map(function (gatherer) {
|
||||||
|
@ -529,13 +525,50 @@ var Gatherers = React.createClass({displayName: "Gatherers",
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
React.createElement("div", {className: "panel-body text-center join-hero"},
|
React.createElement("div", {className: "panel-body text-center join-hero"},
|
||||||
React.createElement(JoinGatherButton, {buttonClass: "btn-lg", buttonName: "Start a Gather"})
|
React.createElement("button", {
|
||||||
|
onClick: this.joinGather,
|
||||||
|
className: "btn btn-success btn-lg"}, "Start a Gather")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var CompletedGather = React.createClass({displayName: "CompletedGather",
|
||||||
|
votedMaps: function () {
|
||||||
|
var maps = this.props.maps;
|
||||||
|
var mapVotes = this.props.gather.gatherers.map(function (gatherer) {
|
||||||
|
return gatherer.mapVote;
|
||||||
|
}).filter(function (elem) {
|
||||||
|
return elem !== null;
|
||||||
|
}).map(function (mapId) {
|
||||||
|
var result;
|
||||||
|
maps.forEach(function (map) {
|
||||||
|
if (map.id === mapId) result = map;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
votedServer: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
render: function () {
|
||||||
|
return (
|
||||||
|
React.createElement("div", {className: "panel panel-default"},
|
||||||
|
React.createElement("div", {className: "panel-heading"},
|
||||||
|
React.createElement("strong", null, "Gather Completed")
|
||||||
|
),
|
||||||
|
React.createElement("div", {className: "panel-body"},
|
||||||
|
React.createElement("h3", null, "Join Up:"),
|
||||||
|
React.createElement("p", null, this.votedMaps()
|
||||||
|
.map(function (map) {return map.name})
|
||||||
|
.join(","))
|
||||||
|
),
|
||||||
|
React.createElement(GatherTeams, {gather: this.props.gather})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -588,6 +621,7 @@ function initialiseComponents () {
|
||||||
React.render(React.createElement(Chatroom, null), document.getElementById('chatroom'));
|
React.render(React.createElement(Chatroom, null), document.getElementById('chatroom'));
|
||||||
React.render(React.createElement(Gather, null), document.getElementById('gathers'));
|
React.render(React.createElement(Gather, null), document.getElementById('gathers'));
|
||||||
React.render(React.createElement(CurrentUser, null), document.getElementById('currentuser'));
|
React.render(React.createElement(CurrentUser, null), document.getElementById('currentuser'));
|
||||||
|
React.render(React.createElement(AdminPanel, null), document.getElementById('admin-menu'));
|
||||||
};
|
};
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -828,6 +862,28 @@ var UserMenu = React.createClass({displayName: "UserMenu",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var AdminPanel = React.createClass({displayName: "AdminPanel",
|
||||||
|
handleGatherReset: function () {
|
||||||
|
socket.emit("gather:reset");
|
||||||
|
},
|
||||||
|
render: function () {
|
||||||
|
return (
|
||||||
|
React.createElement("ul", {className: "nav", id: "admin-menu"},
|
||||||
|
React.createElement("li", null,
|
||||||
|
React.createElement("div", {className: "admin-panel"},
|
||||||
|
React.createElement("h5", null, "Admin"),
|
||||||
|
React.createElement("button", {
|
||||||
|
className: "btn btn-danger",
|
||||||
|
onClick: this.handleGatherReset},
|
||||||
|
"Reset Gather"),
|
||||||
|
React.createElement("p", {className: "text-center"}, React.createElement("small", null, "Only responds for admins on staging.ensl.org"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var CurrentUser = React.createClass({displayName: "CurrentUser",
|
var CurrentUser = React.createClass({displayName: "CurrentUser",
|
||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -123,21 +123,14 @@ describe("Gather Model:", function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it ("transitions to 'done' when players selected and leaders confirm", function () {
|
it ("transitions to 'done' when players selected", function () {
|
||||||
assert.equal(gather.current, "selection");
|
gather.confirmSelection();
|
||||||
gather.confirmSelection(leaderA);
|
|
||||||
assert.equal(gather.current, "selection");
|
|
||||||
gather.confirmSelection(leaderB);
|
|
||||||
assert.equal(gather.current, "done");
|
assert.equal(gather.current, "done");
|
||||||
});
|
});
|
||||||
it ("does not transition to 'done' unless all players selected", function () {
|
it ("does not transition to 'done' unless all players selected", function () {
|
||||||
var lobbyPlayer = gather.gatherers[11];
|
var lobbyPlayer = gather.gatherers[11];
|
||||||
gather.moveToLobby(lobbyPlayer);
|
gather.moveToLobby(lobbyPlayer);
|
||||||
assert.equal(gather.current, "selection");
|
assert.equal(gather.current, "selection");
|
||||||
gather.confirmSelection(leaderA);
|
|
||||||
assert.equal(gather.current, "selection");
|
|
||||||
gather.confirmSelection(leaderB);
|
|
||||||
assert.equal(gather.current, "selection");
|
|
||||||
});
|
});
|
||||||
it ("transitions to picking if a player leaves", function () {
|
it ("transitions to picking if a player leaves", function () {
|
||||||
var leaver = gather.gatherers[11];
|
var leaver = gather.gatherers[11];
|
||||||
|
@ -388,33 +381,4 @@ describe("Gather Model:", function () {
|
||||||
assert.equal(gatherer.serverVote, serverId);
|
assert.equal(gatherer.serverVote, serverId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("confirmTeam", function () {
|
|
||||||
var leader;
|
|
||||||
beforeEach(function () {
|
|
||||||
gatherers.forEach(function (gatherer) {
|
|
||||||
gather.addGatherer(gatherer);
|
|
||||||
});
|
|
||||||
leader = gather.gatherers[0];
|
|
||||||
gather.assignMarineLeader(leader.id);
|
|
||||||
});
|
|
||||||
it ("marks leader as confirmed", function () {
|
|
||||||
gather.confirmTeam(leader);
|
|
||||||
gather.gatherers.forEach(function (gatherer) {
|
|
||||||
if (gatherer.leader) {
|
|
||||||
assert.isTrue(gatherer.confirm);
|
|
||||||
} else {
|
|
||||||
assert.isFalse(gatherer.confirm);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it ("does nothing if user is not leader", function () {
|
|
||||||
var player = gather.gatherers[1];
|
|
||||||
assert.isFalse(player.leader);
|
|
||||||
gather.confirmTeam(player);
|
|
||||||
gather.gatherers.forEach(function (gatherer) {
|
|
||||||
assert.isFalse(gatherer.confirm);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
|
@ -64,6 +64,7 @@
|
||||||
<div class="navbar-default sidebar" role="navigation">
|
<div class="navbar-default sidebar" role="navigation">
|
||||||
<div class="sidebar-nav navbar-collapse">
|
<div class="sidebar-nav navbar-collapse">
|
||||||
<ul class="nav" id="side-menu"></ul>
|
<ul class="nav" id="side-menu"></ul>
|
||||||
|
<ul class="nav" id="admin-menu"></ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
Loading…
Reference in a new issue