Skip to content

Commit

Permalink
Refactor json readability
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLWM committed May 11, 2019
1 parent 45fcd58 commit 874292f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ class CSGOGSI extends EventEmitter {
}

process(data) {
if (typeof data.map !== "undefined") {
this.emit("gameMap", data.map.name);
this.emit("gamePhase", data.map.phase); //warmup etc
this.emit("gameRounds", data.map.round);
this.emit("gameCTscore", data.map.team_ct_score);
this.emit("gameTscore", data.map.team_t_score);
if (typeof data["map"] !== "undefined") {
this.emit("gameMap", data["map"]["name"]);
this.emit("gamePhase", data["map"]["phase"]); //warmup etc
this.emit("gameRounds", data["map"]["round"]);
this.emit("gameCTscore", data["map"]["team_ct_score"]);
this.emit("gameTscore", data["map"]["team_t_score"]);
}

if (typeof data.player !== "undefined") {
this.emit("player", data.player);
if (typeof data["player"] !== "undefined") {
this.emit("player", data["player"]);
}

if (typeof data.round !== "undefined") {
if (typeof data["round"] !== "undefined") {
let maxTime = 0;
this.emit("roundPhase", data.round.phase);
switch (data.round.phase) {
this.emit("roundPhase", data["round"]["phase"]);
switch (data["round"]["phase"]) {
case "live":
maxTime = 115;
break;
Expand All @@ -69,17 +69,17 @@ class CSGOGSI extends EventEmitter {
this.stopC4Countdown();
}

this.emit("roundWinTeam", data.round.win_team);
this.emit("roundWinTeam", data["round"]["win_team"]);
break;
}

if (typeof data.round.bomb !== "undefined") {
this.emit("bombState", data.round.bomb);
switch (data.round.bomb) {
if (typeof data["round"]["bomb"] !== "undefined") {
this.emit("bombState", data["round"]["bomb"]);
switch (data["round"]["bomb"]) {
case "planted":
if (!this.isBombPlanted) {
this.isBombPlanted = true;
let timeleft = this.bombTime - (new Date().getTime() / 1000 - data.provider.timestamp);
let timeleft = this.bombTime - (new Date().getTime() / 1000 - data["provider"]["timestamp"]);
this.emit("bombTimeStart", timeleft);
this.startC4Countdown(timeleft);
}
Expand Down

0 comments on commit 874292f

Please sign in to comment.