mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-02-18 09:51:26 +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,
|
socket: React.PropTypes.object.isRequired,
|
||||||
gather: React.PropTypes.object.isRequired,
|
gather: React.PropTypes.object.isRequired,
|
||||||
thisGatherer: React.PropTypes.object,
|
thisGatherer: React.PropTypes.object,
|
||||||
servers: React.PropTypes.array.isRequired,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
voteHandler(serverId) {
|
voteHandler(serverId) {
|
||||||
|
@ -472,7 +471,7 @@ const ServerVoting = React.createClass({
|
||||||
render() {
|
render() {
|
||||||
let self = this;
|
let self = this;
|
||||||
let thisGatherer = self.props.thisGatherer;
|
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 aVotes = self.votesForServer(a);
|
||||||
const bVotes = self.votesForServer(b);
|
const bVotes = self.votesForServer(b);
|
||||||
return bVotes - aVotes;
|
return bVotes - aVotes;
|
||||||
|
@ -576,7 +575,6 @@ const Gather = exports.Gather = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
thisGatherer: React.PropTypes.object,
|
thisGatherer: React.PropTypes.object,
|
||||||
maps: React.PropTypes.array.isRequired,
|
maps: React.PropTypes.array.isRequired,
|
||||||
servers: React.PropTypes.array.isRequired,
|
|
||||||
socket: React.PropTypes.object.isRequired,
|
socket: React.PropTypes.object.isRequired,
|
||||||
gather: 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 gather = this.props.gather;
|
||||||
const thisGatherer = this.props.thisGatherer;
|
const thisGatherer = this.props.thisGatherer;
|
||||||
const soundController = this.props.soundController;
|
const soundController = this.props.soundController;
|
||||||
const servers = this.props.servers;
|
|
||||||
const maps = this.props.maps;
|
const maps = this.props.maps;
|
||||||
const user = this.props.user;
|
const user = this.props.user;
|
||||||
if (gather === null) return <div></div>;
|
if (gather === null) return <div></div>;
|
||||||
|
@ -602,15 +599,13 @@ const Gather = exports.Gather = React.createClass({
|
||||||
socket={socket} thisGatherer={thisGatherer} />
|
socket={socket} thisGatherer={thisGatherer} />
|
||||||
</div>
|
</div>
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<ServerVoting gather={gather} servers={servers}
|
<ServerVoting gather={gather}
|
||||||
socket={socket} thisGatherer={thisGatherer} />
|
socket={socket} thisGatherer={thisGatherer} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
voting = <GatherVotingResults gather={gather}
|
voting = <GatherVotingResults gather={gather} maps={maps} />;
|
||||||
servers={servers}
|
|
||||||
maps={maps} />;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1002,13 +997,11 @@ const CompletedGather = exports.CompletedGather = React.createClass({
|
||||||
let gatherInfo = [];
|
let gatherInfo = [];
|
||||||
let gather = this.props.gather;
|
let gather = this.props.gather;
|
||||||
let maps = this.props.maps;
|
let maps = this.props.maps;
|
||||||
let servers = this.props.servers;
|
|
||||||
let gatherName = gather.name || "Classic Gather";
|
let gatherName = gather.name || "Classic Gather";
|
||||||
if (this.state.show) {
|
if (this.state.show) {
|
||||||
gatherInfo.push(<GatherTeams gather={gather} key="gatherteams" />);
|
gatherInfo.push(<GatherTeams gather={gather} key="gatherteams" />);
|
||||||
gatherInfo.push(<GatherVotingResults gather={gather}
|
gatherInfo.push(<GatherVotingResults gather={gather}
|
||||||
maps={maps} key="gathervotingresults"
|
maps={maps} key="gathervotingresults" />);
|
||||||
servers={servers} />);
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -1041,7 +1034,7 @@ const GatherVotingResults = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedServers() {
|
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) {
|
serverTable(server, primary) {
|
||||||
|
@ -1069,8 +1062,15 @@ const GatherVotingResults = React.createClass({
|
||||||
render() {
|
render() {
|
||||||
let maps = this.selectedMaps();
|
let maps = this.selectedMaps();
|
||||||
let servers = this.selectedServers();
|
let servers = this.selectedServers();
|
||||||
let mainServer = servers[0];
|
let mainServer;
|
||||||
let altServer = servers[1];
|
if (servers[0]) {
|
||||||
|
mainServer = this.serverTable(servers[0], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
let altServer;
|
||||||
|
if (servers[1]) {
|
||||||
|
altServer = this.serverTable(servers[1]);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="panel panel-primary">
|
<div className="panel panel-primary">
|
||||||
<div className="panel-heading">
|
<div className="panel-heading">
|
||||||
|
@ -1087,11 +1087,11 @@ const GatherVotingResults = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-4">
|
<div className="col-md-4">
|
||||||
<h4>Primary Server</h4>
|
<h4>Primary Server</h4>
|
||||||
{this.serverTable(mainServer, true)}
|
{mainServer}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-4">
|
<div className="col-md-4">
|
||||||
<h4>Fallback Server</h4>
|
<h4>Fallback Server</h4>
|
||||||
{this.serverTable(altServer)}
|
{altServer}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -252,7 +252,6 @@ const GatherPage = React.createClass({
|
||||||
gatherPool[type] = data.gather;
|
gatherPool[type] = data.gather;
|
||||||
self.setState({
|
self.setState({
|
||||||
maps: data.maps,
|
maps: data.maps,
|
||||||
servers: data.servers,
|
|
||||||
gatherPool: gatherPool
|
gatherPool: gatherPool
|
||||||
});
|
});
|
||||||
this.updateTitle();
|
this.updateTitle();
|
||||||
|
@ -502,7 +501,6 @@ const GatherPage = React.createClass({
|
||||||
maps={this.state.maps}
|
maps={this.state.maps}
|
||||||
user={this.state.user}
|
user={this.state.user}
|
||||||
gather={this.currentGather()}
|
gather={this.currentGather()}
|
||||||
servers={this.state.servers}
|
|
||||||
thisGatherer={this.thisGatherer()}
|
thisGatherer={this.thisGatherer()}
|
||||||
soundController={this.state.soundController} />
|
soundController={this.state.soundController} />
|
||||||
{eventsPanel}
|
{eventsPanel}
|
||||||
|
|
|
@ -31,7 +31,6 @@ const emitGather = (socket, gather) => {
|
||||||
gather: gather ? gather.toJson() : null,
|
gather: gather ? gather.toJson() : null,
|
||||||
type: gather ? gather.type : null,
|
type: gather ? gather.type : null,
|
||||||
maps: Map.list,
|
maps: Map.list,
|
||||||
servers: Server.list
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +83,6 @@ module.exports = function (namespace) {
|
||||||
gather: gatherManager.current ? gatherManager.current.toJson() : null,
|
gather: gatherManager.current ? gatherManager.current.toJson() : null,
|
||||||
type: gatherManager.current ? gatherManager.current.type : null,
|
type: gatherManager.current ? gatherManager.current.type : null,
|
||||||
maps: Map.list,
|
maps: Map.list,
|
||||||
servers: Server.list
|
|
||||||
});
|
});
|
||||||
}, 200, {
|
}, 200, {
|
||||||
leading: true,
|
leading: true,
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
const Gatherer = require("./gatherer");
|
const Gatherer = require("./gatherer");
|
||||||
const StateMachine = require("javascript-state-machine");
|
const StateMachine = require("javascript-state-machine");
|
||||||
|
const Server = require("./server");
|
||||||
// const discordBot = require("../discord/bot")();
|
// const discordBot = require("../discord/bot")();
|
||||||
|
|
||||||
function Gather (options) {
|
function Gather (options) {
|
||||||
|
@ -54,6 +55,10 @@ function Gather (options) {
|
||||||
this.membershipTest = options.membershipTest.bind(this);
|
this.membershipTest = options.membershipTest.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof options.serverMembershipTest === 'function') {
|
||||||
|
this.serverMembershipTest = options.serverMembershipTest.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
this.initState();
|
this.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +343,7 @@ Gather.prototype.toJson = function () {
|
||||||
description: this.description,
|
description: this.description,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
gatherers: this.gatherers,
|
gatherers: this.gatherers,
|
||||||
|
servers: this.getServers(),
|
||||||
state: this.current,
|
state: this.current,
|
||||||
pickingTurn: this.pickingTurn(),
|
pickingTurn: this.pickingTurn(),
|
||||||
election: {
|
election: {
|
||||||
|
@ -421,6 +427,11 @@ Gather.prototype.needsToCoolOff = function (user) {
|
||||||
Gather.prototype.failsTest = function (user) {
|
Gather.prototype.failsTest = function (user) {
|
||||||
if (!this.membershipTest) return false;
|
if (!this.membershipTest) return false;
|
||||||
return !this.membershipTest(user);
|
return !this.membershipTest(user);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Gather.prototype.getServers = function () {
|
||||||
|
if (!this.serverMembershipTest) return Server.list;
|
||||||
|
return Server.list.filter(this.serverMembershipTest);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = Gather;
|
module.exports = Gather;
|
||||||
|
|
|
@ -20,7 +20,18 @@ const GATHER_CONFIGS = [
|
||||||
{
|
{
|
||||||
type: "classic",
|
type: "classic",
|
||||||
name: "Classic Gather",
|
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",
|
type: "invitational",
|
||||||
|
@ -29,6 +40,9 @@ const GATHER_CONFIGS = [
|
||||||
// Grant invite if on list
|
// Grant invite if on list
|
||||||
membershipTest: function (user) {
|
membershipTest: function (user) {
|
||||||
return InvitationalGather.list.some(m => m.id === user.id);
|
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