mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-26 06:10:58 +00:00
Adding progmod gathers (#124)
* basic implementation of filtered servers and progmod gathers, need to refactor the changes ive done to servers, want to add them to the gather object instead of that ugly copy on the frontend * refactored server list by attaching them to the gather object allowing them to be filtered by gather type rather than a global list * fixed issue where page would crash if there were fewer than 2 server options
This commit is contained in:
parent
23c96196f8
commit
4b2d67f524
5 changed files with 43 additions and 22 deletions
|
@ -447,7 +447,6 @@ const ServerVoting = React.createClass({
|
|||
socket: React.PropTypes.object.isRequired,
|
||||
gather: React.PropTypes.object.isRequired,
|
||||
thisGatherer: React.PropTypes.object,
|
||||
servers: React.PropTypes.array.isRequired,
|
||||
},
|
||||
|
||||
voteHandler(serverId) {
|
||||
|
@ -472,7 +471,7 @@ const ServerVoting = React.createClass({
|
|||
render() {
|
||||
let self = this;
|
||||
let thisGatherer = self.props.thisGatherer;
|
||||
let servers = self.props.servers.sort((a, b) => {
|
||||
let servers = self.props.gather.servers.sort((a, b) => {
|
||||
const aVotes = self.votesForServer(a);
|
||||
const bVotes = self.votesForServer(b);
|
||||
return bVotes - aVotes;
|
||||
|
@ -576,7 +575,6 @@ const Gather = exports.Gather = React.createClass({
|
|||
propTypes: {
|
||||
thisGatherer: React.PropTypes.object,
|
||||
maps: React.PropTypes.array.isRequired,
|
||||
servers: React.PropTypes.array.isRequired,
|
||||
socket: React.PropTypes.object.isRequired,
|
||||
gather: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
@ -586,7 +584,6 @@ const Gather = exports.Gather = React.createClass({
|
|||
const gather = this.props.gather;
|
||||
const thisGatherer = this.props.thisGatherer;
|
||||
const soundController = this.props.soundController;
|
||||
const servers = this.props.servers;
|
||||
const maps = this.props.maps;
|
||||
const user = this.props.user;
|
||||
if (gather === null) return <div></div>;
|
||||
|
@ -602,15 +599,13 @@ const Gather = exports.Gather = React.createClass({
|
|||
socket={socket} thisGatherer={thisGatherer} />
|
||||
</div>
|
||||
<div className="col-sm-6">
|
||||
<ServerVoting gather={gather} servers={servers}
|
||||
<ServerVoting gather={gather}
|
||||
socket={socket} thisGatherer={thisGatherer} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
voting = <GatherVotingResults gather={gather}
|
||||
servers={servers}
|
||||
maps={maps} />;
|
||||
voting = <GatherVotingResults gather={gather} maps={maps} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1002,13 +997,11 @@ const CompletedGather = exports.CompletedGather = React.createClass({
|
|||
let gatherInfo = [];
|
||||
let gather = this.props.gather;
|
||||
let maps = this.props.maps;
|
||||
let servers = this.props.servers;
|
||||
let gatherName = gather.name || "Classic Gather";
|
||||
if (this.state.show) {
|
||||
gatherInfo.push(<GatherTeams gather={gather} key="gatherteams" />);
|
||||
gatherInfo.push(<GatherVotingResults gather={gather}
|
||||
maps={maps} key="gathervotingresults"
|
||||
servers={servers} />);
|
||||
maps={maps} key="gathervotingresults" />);
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
|
@ -1041,7 +1034,7 @@ const GatherVotingResults = React.createClass({
|
|||
},
|
||||
|
||||
selectedServers() {
|
||||
return rankVotes(this.countVotes('serverVote'), this.props.servers).slice(0, 2);
|
||||
return rankVotes(this.countVotes('serverVote'), this.props.gather.servers).slice(0, 2);
|
||||
},
|
||||
|
||||
serverTable(server, primary) {
|
||||
|
@ -1069,8 +1062,15 @@ const GatherVotingResults = React.createClass({
|
|||
render() {
|
||||
let maps = this.selectedMaps();
|
||||
let servers = this.selectedServers();
|
||||
let mainServer = servers[0];
|
||||
let altServer = servers[1];
|
||||
let mainServer;
|
||||
if (servers[0]) {
|
||||
mainServer = this.serverTable(servers[0], true);
|
||||
}
|
||||
|
||||
let altServer;
|
||||
if (servers[1]) {
|
||||
altServer = this.serverTable(servers[1]);
|
||||
}
|
||||
return (
|
||||
<div className="panel panel-primary">
|
||||
<div className="panel-heading">
|
||||
|
@ -1087,11 +1087,11 @@ const GatherVotingResults = React.createClass({
|
|||
</div>
|
||||
<div className="col-md-4">
|
||||
<h4>Primary Server</h4>
|
||||
{this.serverTable(mainServer, true)}
|
||||
{mainServer}
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<h4>Fallback Server</h4>
|
||||
{this.serverTable(altServer)}
|
||||
{altServer}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -252,7 +252,6 @@ const GatherPage = React.createClass({
|
|||
gatherPool[type] = data.gather;
|
||||
self.setState({
|
||||
maps: data.maps,
|
||||
servers: data.servers,
|
||||
gatherPool: gatherPool
|
||||
});
|
||||
this.updateTitle();
|
||||
|
@ -502,7 +501,6 @@ const GatherPage = React.createClass({
|
|||
maps={this.state.maps}
|
||||
user={this.state.user}
|
||||
gather={this.currentGather()}
|
||||
servers={this.state.servers}
|
||||
thisGatherer={this.thisGatherer()}
|
||||
soundController={this.state.soundController} />
|
||||
{eventsPanel}
|
||||
|
|
|
@ -31,7 +31,6 @@ const emitGather = (socket, gather) => {
|
|||
gather: gather ? gather.toJson() : null,
|
||||
type: gather ? gather.type : null,
|
||||
maps: Map.list,
|
||||
servers: Server.list
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -84,7 +83,6 @@ module.exports = function (namespace) {
|
|||
gather: gatherManager.current ? gatherManager.current.toJson() : null,
|
||||
type: gatherManager.current ? gatherManager.current.type : null,
|
||||
maps: Map.list,
|
||||
servers: Server.list
|
||||
});
|
||||
}, 200, {
|
||||
leading: true,
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
const Gatherer = require("./gatherer");
|
||||
const StateMachine = require("javascript-state-machine");
|
||||
const Server = require("./server");
|
||||
// const discordBot = require("../discord/bot")();
|
||||
|
||||
function Gather (options) {
|
||||
|
@ -54,6 +55,10 @@ function Gather (options) {
|
|||
this.membershipTest = options.membershipTest.bind(this);
|
||||
}
|
||||
|
||||
if (typeof options.serverMembershipTest === 'function') {
|
||||
this.serverMembershipTest = options.serverMembershipTest.bind(this);
|
||||
}
|
||||
|
||||
this.initState();
|
||||
}
|
||||
|
||||
|
@ -338,6 +343,7 @@ Gather.prototype.toJson = function () {
|
|||
description: this.description,
|
||||
type: this.type,
|
||||
gatherers: this.gatherers,
|
||||
servers: this.getServers(),
|
||||
state: this.current,
|
||||
pickingTurn: this.pickingTurn(),
|
||||
election: {
|
||||
|
@ -421,6 +427,11 @@ Gather.prototype.needsToCoolOff = function (user) {
|
|||
Gather.prototype.failsTest = function (user) {
|
||||
if (!this.membershipTest) return false;
|
||||
return !this.membershipTest(user);
|
||||
}
|
||||
};
|
||||
|
||||
Gather.prototype.getServers = function () {
|
||||
if (!this.serverMembershipTest) return Server.list;
|
||||
return Server.list.filter(this.serverMembershipTest);
|
||||
};
|
||||
|
||||
module.exports = Gather;
|
||||
|
|
|
@ -20,7 +20,18 @@ const GATHER_CONFIGS = [
|
|||
{
|
||||
type: "classic",
|
||||
name: "Classic Gather",
|
||||
description: "No Requirements"
|
||||
description: "No Requirements",
|
||||
serverMembershipTest: function (server) {
|
||||
return server.name.toLowerCase().indexOf("promod") === -1;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "progmod",
|
||||
name: "Progressive Mod Gather",
|
||||
description: "No Requirements",
|
||||
serverMembershipTest: function (server) {
|
||||
return server.name.toLowerCase().indexOf("promod") !== -1;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "invitational",
|
||||
|
@ -29,6 +40,9 @@ const GATHER_CONFIGS = [
|
|||
// Grant invite if on list
|
||||
membershipTest: function (user) {
|
||||
return InvitationalGather.list.some(m => m.id === user.id);
|
||||
},
|
||||
serverMembershipTest: function (server) {
|
||||
return server.name.toLowerCase().indexOf("promod") === -1;
|
||||
}
|
||||
}
|
||||
// {
|
||||
|
|
Loading…
Reference in a new issue