mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-10 15:21:56 +00:00
Changed picking rotation
* Teams are now picked 1-2-1-1-1-1-1-1-1-1
This commit is contained in:
parent
422b87d18a
commit
ec17c604b9
1 changed files with 21 additions and 21 deletions
|
@ -9,7 +9,7 @@
|
|||
* - Selection (Selecting teams)
|
||||
* - Done
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
const Gatherer = require("./gatherer");
|
||||
const StateMachine = require("javascript-state-machine");
|
||||
|
@ -22,14 +22,14 @@ function Gather (options) {
|
|||
}
|
||||
this.gatherers = [];
|
||||
let noop = () => {};
|
||||
this.onDone = (typeof options.onDone === 'function') ?
|
||||
this.onDone = (typeof options.onDone === 'function') ?
|
||||
options.onDone : noop;
|
||||
this.onEvent = (typeof options.onEvent === 'function') ?
|
||||
this.onEvent = (typeof options.onEvent === 'function') ?
|
||||
options.onEvent : noop;
|
||||
this.done = {
|
||||
time: null
|
||||
};
|
||||
|
||||
|
||||
this.teamSize = options.teamSize || 6;
|
||||
|
||||
// Store cooldown times for gather leaves
|
||||
|
@ -43,7 +43,7 @@ function Gather (options) {
|
|||
this.name = options.name || "Classic Gather";
|
||||
|
||||
this.description = options.description || "No player requirements";
|
||||
|
||||
|
||||
this.election = {
|
||||
INTERVAL: 60000, // 1 Minute
|
||||
startTime: null,
|
||||
|
@ -65,10 +65,10 @@ StateMachine.create({
|
|||
{ name: "selectLeader", from: "election", to: "selection" },
|
||||
{ name: "electionTimeout", from: "election", to: "selection" },
|
||||
{ name: "confirmSelection", from: "selection", to: "done" },
|
||||
{
|
||||
name: "removeGatherer",
|
||||
from: ["gathering", "election", "selection"],
|
||||
to: "gathering"
|
||||
{
|
||||
name: "removeGatherer",
|
||||
from: ["gathering", "election", "selection"],
|
||||
to: "gathering"
|
||||
},
|
||||
{
|
||||
name: "regather",
|
||||
|
@ -88,13 +88,13 @@ StateMachine.create({
|
|||
if (this.failsTest(user)) return false;
|
||||
this.addUser(user);
|
||||
if (!this.lobbyFull()) {
|
||||
if(this.gatherers.length > this.teamSize &&
|
||||
if(this.gatherers.length > this.teamSize &&
|
||||
(null === discordBot.spamProtection.fillStatus ||
|
||||
((new Date()).getTime() - discordBot.spamProtection.fillStatus.getTime())/1000 > 180)) {
|
||||
discordBot.notifyChannel("Join the gather at https://gathers.ensl.org | " + this.gatherers.length + " players are already waiting!");
|
||||
discordBot.spamProtection.fillStatus = new Date();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
@ -115,7 +115,7 @@ StateMachine.create({
|
|||
this.cancelElectionCountdown();
|
||||
},
|
||||
|
||||
// Selection State
|
||||
// Selection State
|
||||
onenterselection: function () {
|
||||
// Remove all leaders and teams
|
||||
this.gatherers.forEach(gatherer => {
|
||||
|
@ -231,7 +231,7 @@ Gather.prototype.containsUser = function (user) {
|
|||
return this.gatherers.some(gatherer => {
|
||||
return gatherer.id === user.id;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Gather.prototype.addUser = function (user) {
|
||||
if (this.containsUser(user)) return null;
|
||||
|
@ -259,11 +259,11 @@ Gather.prototype.pickingTurn = function () {
|
|||
let alienCount = this.aliens().length;
|
||||
let marineCount = this.marines().length;
|
||||
let total = marineCount + alienCount;
|
||||
if (alienCount + marineCount === 2) return "marine";
|
||||
if (marineCount > alienCount) return "alien";
|
||||
if (total === 2) return "marine"; // first pick for marines
|
||||
if (total === 4) return "alien"; // first pick round aliens got to picks
|
||||
if (marineCount > alienCount) return "alien"; // applies only after first pick
|
||||
if (marineCount < alienCount) return "marine";
|
||||
if (total % 4 === 0) return "alien";
|
||||
return "marine";
|
||||
return "alien"; // after aliens picked two whenever numbers are equal its aliens turn again
|
||||
};
|
||||
|
||||
// Moves player to marine
|
||||
|
@ -274,7 +274,7 @@ Gather.prototype.moveToMarine = function (user, mover) {
|
|||
|
||||
if (mover && this.containsUser(mover)) {
|
||||
let leader = this.getGatherer(mover);
|
||||
if (leader.team !== "marine" ||
|
||||
if (leader.team !== "marine" ||
|
||||
!leader.leader ||
|
||||
this.pickingTurn() !== "marine") return;
|
||||
|
||||
|
@ -295,7 +295,7 @@ Gather.prototype.moveToAlien = function (user, mover) {
|
|||
|
||||
if (mover && this.containsUser(mover)) {
|
||||
let leader = this.getGatherer(mover);
|
||||
if (leader.team !== "alien" ||
|
||||
if (leader.team !== "alien" ||
|
||||
!leader.leader ||
|
||||
this.pickingTurn() !== "alien") return;
|
||||
|
||||
|
@ -304,7 +304,7 @@ Gather.prototype.moveToAlien = function (user, mover) {
|
|||
}
|
||||
}
|
||||
|
||||
return this.modifyGatherer(user, gatherer => gatherer.team = "alien");
|
||||
return this.modifyGatherer(user, gatherer => gatherer.team = "alien");
|
||||
};
|
||||
|
||||
Gather.prototype.moveToLobby = function (user) {
|
||||
|
@ -328,7 +328,7 @@ Gather.prototype.marines = function () {
|
|||
};
|
||||
|
||||
Gather.prototype.electionStartTime = function () {
|
||||
return (this.election.startTime === null) ?
|
||||
return (this.election.startTime === null) ?
|
||||
null : this.election.startTime.toISOString();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue