Skip to content

Commit

Permalink
Began working on ticketing support
Browse files Browse the repository at this point in the history
Also updated node-dota2
  • Loading branch information
MeLlamoPablo committed Jan 5, 2017
1 parent 5e56849 commit 54cec51
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 29 deletions.
71 changes: 43 additions & 28 deletions lib/modules/dotahandler/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const db = require("../dbhandler")
, Dota2 = require("dota2");

// ENUMS
const EServerRegion = Dota2.ServerRegion
, ESeriesType = Dota2.SeriesType
, EGameMode = Dota2.schema.lookupEnum("DOTA_GameMode")
, EGameVersion = Dota2.schema.lookupEnum("DOTAGameVersion")
, ECMPick = Dota2.schema.lookupEnum("DOTA_CM_PICK")
, EDotaTVDelay = Dota2.schema.lookupEnum("LobbyDotaTVDelay")
, EChatChannelType = Dota2.schema.lookupEnum("DOTAChatChannelType_t")
;

class DotaHandler {

constructor(dotaClient) {
Expand Down Expand Up @@ -48,46 +58,46 @@ class DotaHandler {

switch (inhouseProps.server) {
case "uswest":
server = Dota2.ServerRegion.USWEST;
server = EServerRegion.USWEST;
break;
case "useast":
server = Dota2.ServerRegion.USEAST;
server = EServerRegion.USEAST;
break;
case "luxembourg":
server = Dota2.ServerRegion.EUROPE;
server = EServerRegion.EUROPE;
break;
case "australia":
server = Dota2.ServerRegion.AUSTRALIA;
server = EServerRegion.AUSTRALIA;
break;
case "stockholm":
server = Dota2.ServerRegion.STOCKHOLM;
server = EServerRegion.STOCKHOLM;
break;
case "singapore":
server = Dota2.ServerRegion.SINGAPORE;
server = EServerRegion.SINGAPORE;
break;
case "dubai":
server = Dota2.ServerRegion.DUBAI;
server = EServerRegion.DUBAI;
break;
case "austria":
server = Dota2.ServerRegion.AUSTRIA;
server = EServerRegion.AUSTRIA;
break;
case "brazil":
server = Dota2.ServerRegion.BRAZIL;
server = EServerRegion.BRAZIL;
break;
case "southafrica":
server = Dota2.ServerRegion.SOUTHAFRICA;
server = EServerRegion.SOUTHAFRICA;
break;
case "chile":
server = Dota2.ServerRegion.CHILE;
server = EServerRegion.CHILE;
break;
case "peru":
server = Dota2.ServerRegion.PERU;
server = EServerRegion.PERU;
break;
case "india":
server = Dota2.ServerRegion.INDIA;
server = EServerRegion.INDIA;
break;
case "japan":
server = Dota2.ServerRegion.JAPAN;
server = EServerRegion.JAPAN;
break;
default:
return reject(new Error("Unknown server " + inhouseProps.server));
Expand All @@ -97,47 +107,52 @@ class DotaHandler {

switch (inhouseProps.gameMode) {
case "captainsmode":
gamemode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_CM;
gamemode = EGameMode.DOTA_GAMEMODE_CM;
break;
case "allpick":
gamemode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_AP;
gamemode = EGameMode.DOTA_GAMEMODE_AP;
break;
case "captainsdraft":
gamemode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_CD;
gamemode = EGameMode.DOTA_GAMEMODE_CD;
break;
case "randomdraft":
gamemode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_RD;
gamemode = EGameMode.DOTA_GAMEMODE_RD;
break;
case "singledraft":
gamemode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_SD;
gamemode = EGameMode.DOTA_GAMEMODE_SD;
break;
case "allrandom":
gamemode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_AR;
gamemode = EGameMode.DOTA_GAMEMODE_AR;
break;
case "rankedallpick":
gamemode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_ALL_DRAFT;
gamemode = EGameMode.DOTA_GAMEMODE_ALL_DRAFT;
break;
default:
return reject(new Error("Unknown game mode " + inhouseProps.gameMode));
}

this.client.createPracticeLobby(
// TODO make this work
// Can't continue working until https://github.com/Arcana/node-dota2/issues/414
// is resolved.
this.client.createTournamentLobby(
this.currentLobbyPassword,
/*tournament_game_id*/ 123456789,
/*tournament_id*/ 4187, /*https://es.dotabuff.com/esports/leagues/4187*/
{
"game_name": this.currentLobbyName,
"server_region": server,
"game_mode": gamemode,
"game_version": Dota2.schema.DOTAGameVersion.GAME_VERSION_STABLE,
"series_type": Dota2.SeriesType.NONE,
"cm_pick": Dota2.schema.DOTA_CM_PICK.DOTA_CM_RANDOM,
"game_version": EGameVersion.GAME_VERSION_STABLE,
"series_type": ESeriesType.NONE,
"cm_pick": ECMPick.DOTA_CM_RANDOM,
"allow_cheats": false,
"fill_with_bots": false,
"allow_spectating": true,
"pass_key": this.currentLobbyPassword,
"radiant_series_wins": 0,
"dire_series_wins": 0,
"allchat": false,
"dota_tv_delay": Dota2.schema.LobbyDotaTVDelay.LobbyDotaTV_120
"dota_tv_delay": EDotaTVDelay.LobbyDotaTV_120
},
err => {
if (!err) {
Expand All @@ -163,13 +178,13 @@ class DotaHandler {
sendMessageToLobby(message) {
this.client.joinChat(
this.currentLobbyChatChannel,
Dota2.schema.DOTAChatChannelType_t.DOTAChannelType_Lobby
EChatChannelType.DOTAChannelType_Lobby
);

this.client.sendMessage(
/*channel*/ this.currentLobbyChatChannel,
/*message*/ message,
/*channel_type*/ Dota2.schema.DOTAChatChannelType_t.DOTAChannelType_Lobby
/*channel_type*/ EChatChannelType.DOTAChannelType_Lobby
);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"clapp": "^1.1.0",
"discord.js": "^10.0.1",
"dota2": "git+https://github.com/tomasmck/node-dota2.git#dc3b70fc3efc575527eafc892346b07416fdfc9b",
"dota2": "git+https://github.com/Arcana/node-dota2.git#3033865a5296579f6deb560d298f6a812a2ec4d4",
"inquirer": "^1.2.2",
"knex": "^0.12.6",
"moment": "^2.15.1",
Expand Down

0 comments on commit 54cec51

Please sign in to comment.