Skip to content
Permalink
Browse files

Anarchy scores now displayed on the client.

  • Loading branch information...
roncli committed Jul 10, 2015
1 parent b5bd66c commit d6e27095adbe19f1924332abaa3a81775dd217d6
Showing with 104 additions and 80 deletions.
  1. +1 −1 package.json
  2. +40 −34 public/js/ddsn.js
  3. +41 −0 public/templates/server-scoreboard.htm
  4. +0 −18 server.js
  5. +22 −27 websocket.js
@@ -18,7 +18,7 @@
"url": "https://github.com/roncli/descentDSNclient.git"
},
"dependencies": {
"descent3console": "0.1.6",
"descent3console": "0.1.7",
"descent3launcher": "0.1.3",
"descent3mn3tools": "0.1.2",
"express": "4.13.0",
@@ -580,6 +580,7 @@ var app = angular.module("ddsn", []),
};
}
server.players[killerNum].opponents[message.event.killed].kills++;
server.players[killerNum].kills++;
}

if (killedNum) {
@@ -591,11 +592,44 @@ var app = angular.module("ddsn", []),
};
}
server.players[killedNum].opponents[message.event.killer].deaths++;
server.players[killedNum].deaths++;
}

break;
case "suicide":
playerNum = getPlayerNum(server, message.event.player);

if (playerNum) {
server.players[playerNum].connected = true;
server.players[playerNum].suicides++;
}

break;
case "death":
playerNum = getPlayerNum(server, message.event.player);

if (playerNum) {
server.players[playerNum].connected = true;
server.players[playerNum].deaths++;
}

break;
case "robotdeath":
playerNum = getPlayerNum(server, message.event.player);

if (playerNum) {
server.players[playerNum].deaths++;
}

break;
case "monsterballblunder":
playerNum = getPlayerNum(server, message.event.player);

if (playerNum) {
server.players[playerNum].blunders++;
}

break;
case "flagscore":
playerNum = getPlayerNum(server, message.event.player);

@@ -671,10 +705,6 @@ var app = angular.module("ddsn", []),

if (playerNum) {
server.players[playerNum].points = message.points;
server.players[playerNum].blunders = message.blunders;
server.players[playerNum].kills = message.kills;
server.players[playerNum].deaths = message.deaths;
server.players[playerNum].suicides = message.suicides;
server.players[playerNum].ping = message.ping;
}

@@ -702,7 +732,12 @@ var app = angular.module("ddsn", []),
server.players[message.playerNum] = {
name: message.name,
connected: true,
opponents: {}
opponents: {},
kills: 0,
deaths: 0,
suicides: 0,
points: 0,
blunders: 0
};
}
server.playerNames[message.name] = message.playerNum;
@@ -751,38 +786,12 @@ var app = angular.module("ddsn", []),

if (playerNum) {
server.players[playerNum].points = message.points;
server.players[playerNum].kills = message.kills;
server.players[playerNum].deaths = message.deaths;
server.players[playerNum].suicides = message.suicides;
server.players[playerNum].ping = message.ping;
}

scope.$apply();
});
break;
case "server.playertotalscore":
getServer(message.port, function(server) {
if (!server) {
return;
}

var playerNum = getPlayerNum(server, message.player);

if (playerNum) {
server.players[playerNum].points = server.points;
server.players[playerNum].totalPoints = server.totalPoints;
server.players[playerNum].kills = server.kills;
server.players[playerNum].totalKills = server.totalKills;
server.players[playerNum].deaths = server.deaths;
server.players[playerNum].totalDeaths = server.totalDeaths;
server.players[playerNum].suicides = server.suicides;
server.players[playerNum].totalSuicides = server.totalSuicides;
server.players[playerNum].ping = server.ping;
}

scope.$apply();
});
break;
case "server.raw":
getServer(message.port, function(server) {
var serverConsole,
@@ -822,9 +831,6 @@ var app = angular.module("ddsn", []),
if (playerNum) {
server.players[playerNum].teamName = message.teamName;
server.players[playerNum].points = message.points;
server.players[playerNum].kills = message.kills;
server.players[playerNum].deaths = message.deaths;
server.players[playerNum].suicides = message.suicides;
server.players[playerNum].ping = message.ping;
}

@@ -0,0 +1,41 @@
<div ng-switch="data.currentServer.settings.game.scriptName.toLowerCase()">
<div ng-switch-when="anarchy">
<table class="table table-condensed">
<tr ng-class="'player' + player.playerNum.toString()" ng-repeat="player in data.currentServer.players | filter: {role: 'client', connected: true} | orderBy: '-points'">
<td class="h3" style="vertical-align: middle;">
{{player.name}}
</td>
<td class="h3 text-right" style="vertical-align: middle;">
{{player.points}}
</td>
<td class="text-center" style="vertical-align: middle;">
{{player.kills}} / {{player.deaths}} / {{player.suicides}}
</td>
<td class="text-right" style="vertical-align: middle;">
{{player.kills + player.deaths + player.suicides === 0 ? "0.00" : (player.kills * 100 / (player.kills + player.deaths + player.suicides)).toFixed(2)}}
</td>
<td class="text-right" style="vertical-align: middle;">
{{player.ping ? player.ping.toString() + " ms" : ""}}
</td>
</tr>
<tr class="muted" ng-repeat="player in data.currentServer.players | filter: {role: 'client', connected: false} | orderBy: '-points'">
<td>
{{player.name}}
</td>
<td>
{{player.points}}
</td>
<td class="text-center">
{{player.kills}} / {{player.deaths}} / {{player.suicides}}
</td>
<td class="text-right">
{{player.kills + player.deaths + player.suicides === 0 ? "0.00" : (player.kills * 100 / (player.kills + player.deaths + player.suicides)).toFixed(2)}}
</td>
<td></td>
</tr>
</table>
</div>
<div ng-switch-default>
There is no scoreboard available for this game mode.
</div>
</div>
@@ -228,24 +228,6 @@ Server.prototype.init = function() {
});
});

this.console.on("playertotalscore", function(player, points, totalPoints, kills, totalKills, deaths, totalDeaths, suicides, totalSuicides, ping) {
server.emit("playertotalscore", player, points, totalPoints, kills, totalKills, deaths, totalDeaths, suicides, totalSuicides, ping);
server.wss.broadcast({
message: "server.playertotalscore",
port: server.settings.server.port,
player: player,
points: points,
totalPoints: totalPoints,
kills: kills,
totalKills: totalKills,
deaths: deaths,
totalDeaths: totalDeaths,
suicides: suicides,
totalSuicides: totalSuicides,
ping: ping
});
});

this.console.on("monsterballscore", function(player, points, blunders, kills, deaths, suicides, ping) {
server.emit("monsterballscore", player, points, blunders, kills, deaths, suicides, ping);
server.wss.broadcast({
@@ -359,6 +359,7 @@ module.exports = function() {
};
}
serverData.players[killerNum].opponents[killed].kills++;
serverData.players[killerNum].kills++;
}

if (killedNum) {
@@ -370,6 +371,7 @@ module.exports = function() {
};
}
serverData.players[killedNum].opponents[killer].deaths++;
serverData.players[killedNum].deaths++;
}
});

@@ -378,6 +380,7 @@ module.exports = function() {

if (playerNum) {
serverData.players[playerNum].connected = true;
serverData.players[playerNum].suicides++;
}

addEvent({
@@ -391,6 +394,7 @@ module.exports = function() {

if (playerNum) {
serverData.players[playerNum].connected = true;
serverData.players[playerNum].deaths++;
}

addEvent({
@@ -400,6 +404,12 @@ module.exports = function() {
});

server.on("robotdeath", function(player) {
var playerNum = getPlayerNum(player);

if (playerNum) {
serverData.players[playerNum].deaths++;
}

addEvent({
event: "robotdeath",
player: player
@@ -415,6 +425,12 @@ module.exports = function() {
});

server.on("monsterballblunder", function(player, team) {
var playerNum = getPlayerNum(player);

if (playerNum) {
serverData.players[playerNum].blunders++;
}

addEvent({
event: "monsterballblunder",
player: player,
@@ -542,9 +558,6 @@ module.exports = function() {

if (playerNum) {
serverData.players[playerNum].points = points;
serverData.players[playerNum].kills = kills;
serverData.players[playerNum].deaths = deaths;
serverData.players[playerNum].suicides = suicides;
serverData.players[playerNum].ping = ping;
}
});
@@ -559,25 +572,6 @@ module.exports = function() {
if (playerNum) {
serverData.players[playerNum].teamName = teamName;
serverData.players[playerNum].points = points;
serverData.players[playerNum].kills = kills;
serverData.players[playerNum].deaths = deaths;
serverData.players[playerNum].suicides = suicides;
serverData.players[playerNum].ping = ping;
}
});

server.on("playertotalscore", function(player, points, totalPoints, kills, totalKills, deaths, totalDeaths, suicides, totalSuicides, ping) {
var playerNum = getPlayerNum(player);

if (playerNum) {
serverData.players[playerNum].points = points;
serverData.players[playerNum].totalPoints = totalPoints;
serverData.players[playerNum].kills = kills;
serverData.players[playerNum].totalKills = totalKills;
serverData.players[playerNum].deaths = deaths;
serverData.players[playerNum].totalDeaths = totalDeaths;
serverData.players[playerNum].suicides = suicides;
serverData.players[playerNum].totalSuicides = totalSuicides;
serverData.players[playerNum].ping = ping;
}
});
@@ -587,10 +581,6 @@ module.exports = function() {

if (playerNum) {
serverData.players[playerNum].points = points;
serverData.players[playerNum].blunders = blunders;
serverData.players[playerNum].kills = kills;
serverData.players[playerNum].deaths = deaths;
serverData.players[playerNum].suicides = suicides;
serverData.players[playerNum].ping = ping;
}
});
@@ -611,7 +601,12 @@ module.exports = function() {
serverData.players[playerNum] = {
name: name,
connected: true,
opponents: {}
opponents: {},
kills: 0,
deaths: 0,
suicides: 0,
points: 0,
blunders: 0
};
}
serverData.playerNames[name] = playerNum;

0 comments on commit d6e2709

Please sign in to comment.
You can’t perform that action at this time.