Skip to content

Commit

Permalink
Added CM Pick option (Needs testing)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeLlamoPablo committed Jan 16, 2017
1 parent 35c3bfd commit dc4989e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
28 changes: 28 additions & 0 deletions lib/commands/general/add-inhouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module.exports = new Clapp.Command({
inhouseProps.gameMode = argv.flags.gamemode.toLowerCase().replace(" ", "");
inhouseProps.server = argv.flags.server.toLowerCase().replace(" ", "");
inhouseProps.autoBalance = !argv.flags.nobalance;
if (inhouseProps.gameMode === "captainsmode") {
inhouseProps.cmPick = argv.flags.cmpick.toLowerCase().replace(" ", "");
}

db.events.addInhouse(event, inhouseProps).then(() => {
// Kick every user that hasn't linked their Steam from the event
Expand Down Expand Up @@ -131,6 +134,31 @@ module.exports = new Clapp.Command({
}
]
}),
new Clapp.Flag({
name: "cmpick",
desc: "Determines who gets the first pick, in Captains Mode.\n" +
"Can be either \"Radiant\", \"Dire\", or \"Random\"",
type: "string",
default: "Random",
alias: "p",
validations: [
{
errorMessage: "Type --help for a list of supported values",
validate: val => {
let value = val.toLowerCase().replace(" ", "");

switch (value) {
case "random":
case "radiant":
case "dire":
return true;
default:
return false;
}
}
}
]
}),
new Clapp.Flag({
name: "nobalance",
desc: "Disable automatic team balance.",
Expand Down
14 changes: 12 additions & 2 deletions lib/modules/dotahandler/DotaClientX.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,21 @@ class DotaClientX extends Dota2.Dota2Client {
return reject(new Error("Unknown server " + inhouseProps.server));
}

let gamemode;
let gamemode; let cmpick = ECMPick.DOTA_CM_RANDOM;

switch (inhouseProps.gameMode) {
case "captainsmode":
gamemode = EGameMode.DOTA_GAMEMODE_CM;

switch (inhouseProps.cmPick) {
case "radiant":
cmpick = ECMPick.DOTA_CM_GOOD_GUYS;
break;
case "dire":
cmpick = ECMPick.DOTA_CM_BAD_GUYS;
break;
}

break;
case "allpick":
gamemode = EGameMode.DOTA_GAMEMODE_AP;
Expand Down Expand Up @@ -158,7 +168,7 @@ class DotaClientX extends Dota2.Dota2Client {
"game_mode": gamemode,
"game_version": EGameVersion.GAME_VERSION_STABLE,
"series_type": ESeriesType.NONE,
"cm_pick": ECMPick.DOTA_CM_RANDOM,
"cm_pick": cmpick,
"allow_cheats": false,
"fill_with_bots": false,
"allow_spectating": true,
Expand Down
19 changes: 19 additions & 0 deletions lib/modules/summaryhandler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class SummaryHandler {
let inhouseProps = values[1];
let lobbyStatus = values[2];

console.log(inhouseProps);

let summary = "";
let status = event.getStatus();

Expand Down Expand Up @@ -86,6 +88,19 @@ class SummaryHandler {
switch (inhouseProps.gameMode) {
case "captainsmode":
inhouseProps.gameMode = "Captains Mode";

switch (inhouseProps.cmPick) {
case "radiant":
inhouseProps.cmPick = "Radiant";
break;
case "dire":
inhouseProps.cmPick = "Dire";
break;
case "random":
inhouseProps.cmPick = "Random";
break;
}

break;
case "allpick":
inhouseProps.gameMode = "All Pick";
Expand Down Expand Up @@ -154,6 +169,8 @@ class SummaryHandler {

inhouseProps.autoBalance = inhouseProps.autoBalance ? "Enabled" : "Disabled";

console.log(inhouseProps);

switch (status) {
case "pending":
summary += "That's " + event.time.fromNow() + ".\n\n";
Expand Down Expand Up @@ -186,6 +203,8 @@ class SummaryHandler {
summary += "**Lobby details**\n\n" +

"- Game mode: *" + inhouseProps.gameMode + "*\n" +
(inhouseProps.gameMode !== "Captains Mode" ? "" :
"- First pick: *" + inhouseProps.cmPick + "*\n") +
"- Server: *" + inhouseProps.server + "*\n" +
"- Automatic team balance: *" + inhouseProps.autoBalance + "*\n\n";
}
Expand Down

0 comments on commit dc4989e

Please sign in to comment.