mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-02-18 09:51:26 +00:00
New picking system (#133)
* Changed picking system to 1-1-1-2-1-1-2-1 * removed code committed by accident from customizable picking system branch * changes picking order logic to handle cases where teams are larger than 6v6 * add a safety check on the picking logic to prevent a team ever growing beyond the team size limit regardless of the picking order defined * add a safety check on the picking logic to prevent a team ever growing beyond the team size limit regardless of the picking order defined
This commit is contained in:
parent
3d3323fe13
commit
a6a945281a
1 changed files with 29 additions and 11 deletions
|
@ -256,19 +256,37 @@ Gather.prototype.modifyGatherer = function (user, callback){
|
|||
};
|
||||
|
||||
// Determines picking order of teams
|
||||
// Marine 1 pick first
|
||||
// 2 picks for each team subsequently
|
||||
|
||||
// Marine pick first
|
||||
Gather.prototype.pickingTurn = function () {
|
||||
if (this.current !== 'selection') return null;
|
||||
let alienCount = this.aliens().length;
|
||||
let marineCount = this.marines().length;
|
||||
let total = marineCount + alienCount;
|
||||
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";
|
||||
return "alien"; // after aliens picked two whenever numbers are equal its aliens turn again
|
||||
|
||||
const captainCount = 2;
|
||||
const alienCount = this.aliens().length;
|
||||
const marineCount = this.marines().length;
|
||||
const alreadyPickedCount = (marineCount + alienCount) - captainCount;
|
||||
const pickingPattern = [ // 1-1-1-2-1-1-2-1
|
||||
"marine",
|
||||
"alien",
|
||||
"marine",
|
||||
"alien",
|
||||
"alien",
|
||||
"marine",
|
||||
"alien",
|
||||
"marine",
|
||||
"marine",
|
||||
"alien",
|
||||
];
|
||||
|
||||
const pickingTurn = alreadyPickedCount % pickingPattern.length;
|
||||
|
||||
// prevent any team from growing beyond the team size limit
|
||||
if (marineCount >= this.teamSize) {
|
||||
return "alien";
|
||||
} else if (alienCount >= this.teamSize) {
|
||||
return "marine";
|
||||
}
|
||||
|
||||
return pickingPattern[pickingTurn];
|
||||
};
|
||||
|
||||
// Moves player to marine
|
||||
|
|
Loading…
Reference in a new issue