diff --git a/api/routes/players.js b/api/routes/players.js
index dd0d962..a3ee5a5 100644
--- a/api/routes/players.js
+++ b/api/routes/players.js
@@ -14,6 +14,9 @@ const CampaignModel = require('../models/campaign');
const PlayerModel = require('../models/player');
const WarModel = require('../models/war');
+// Util
+const isSteamUUID = require('../tools/util').isSteamUUID;
+
const campaignPlayer = express.Router();
// routes **********************
@@ -86,7 +89,7 @@ campaignPlayer.route('/ranking/:campaignId')
routerHandling.httpMethodNotAllowed
);
-campaignPlayer.route('/single/:campaignId/:playerName')
+campaignPlayer.route('/single/:campaignId/:playerId')
.get((req, res, next) => {
CampaignModel.findById(req.params.campaignId, (err, campaign) => {
if (err) return next(err);
@@ -95,17 +98,24 @@ campaignPlayer.route('/single/:campaignId/:playerName')
const warIds = wars.map((obj) => {
return obj._id;
});
- PlayerModel.find({name: req.params.playerName, warId: {"$in": warIds}})
+
+ // find by player name until v1.6.12, afterwards by SteamUUID
+ const playerId = req.params.playerId;
+ const filter = {};
+ filter[isSteamUUID(playerId) ? 'steamUUID' : 'name'] = playerId;
+ filter['warId'] = {"$in": warIds};
+
+ PlayerModel.find(filter)
.populate('warId')
.exec((err, items) => {
if (err) return next(err);
if (!items || items.length === 0) {
- const err = new Error('Unknown player name');
+ const err = new Error('Unknown player id');
err.status = codes.notfound;
return next(err)
}
res.locals.items = {
- name: req.params.playerName,
+ name: items[items.length - 1].name,
campaign: campaign,
players: items
};
diff --git a/api/tools/util.js b/api/tools/util.js
index e0ebbe7..7fd901b 100644
--- a/api/tools/util.js
+++ b/api/tools/util.js
@@ -1,5 +1,11 @@
"use strict";
+const isSteamUUID = (input) => {
+ const steamUIDPattern = new RegExp("[0-9]{17}");
+ return steamUIDPattern.test(input)
+};
+
+
const sortCollectionBy = (collection, key) => {
collection.sort((a, b) => {
a = a[key].toLowerCase();
@@ -48,3 +54,4 @@ exports.sortCollection = sortCollectionBy;
exports.playerArrayContains = playerArrayContains;
exports.timeStringToDecimal = timeStringToDecimal;
exports.decimalToTimeString = decimalToTimeString;
+exports.isSteamUUID = isSteamUUID;
diff --git a/static/src/app/statistic/highscore/highscore.component.css b/static/src/app/statistic/highscore/highscore.component.css
index 50ecc49..fb0eac8 100644
--- a/static/src/app/statistic/highscore/highscore.component.css
+++ b/static/src/app/statistic/highscore/highscore.component.css
@@ -72,5 +72,4 @@ ngx-datatable {
background: #4b4b4b;
-webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5);
}
-
/* Table Scrollbar END */
diff --git a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html
index 167bba9..6d16c41 100644
--- a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html
+++ b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html
@@ -31,13 +31,16 @@
-
-
-
+
+
+
-
-
- Gesamt
+
+
+
+ Gesamt
+
diff --git a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts
index 20c354b..2f2676c 100644
--- a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts
+++ b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts
@@ -1,6 +1,7 @@
import {Component, ElementRef, EventEmitter, SimpleChanges} from "@angular/core";
import {War} from "../../../models/model-interfaces";
import {Fraction} from "../../../utils/fraction.enum";
+import {PlayerUtils} from "../../../utils/player-utils";
@Component({
selector: 'scoreboard',
@@ -17,6 +18,8 @@ export class ScoreboardComponent {
war: War;
+ isSteamUUID = PlayerUtils.isSteamUUID;
+
fractionFilterSelected: string;
cellHeight = 40;
@@ -33,8 +36,11 @@ export class ScoreboardComponent {
constructor(private elRef: ElementRef) {
}
- selectPlayerDetail(view: number, playerName: string) {
- this.playerTabSwitch.emit({view: view, player: playerName})
+ selectPlayerDetail(view: number, player) {
+ this.playerTabSwitch.emit({
+ view: view,
+ player: player
+ })
}
ngOnChanges(changes: SimpleChanges) {
diff --git a/static/src/app/utils/player-utils.ts b/static/src/app/utils/player-utils.ts
new file mode 100644
index 0000000..94b0f79
--- /dev/null
+++ b/static/src/app/utils/player-utils.ts
@@ -0,0 +1,7 @@
+export class PlayerUtils {
+
+ public static isSteamUUID(input: string): boolean {
+ const steamUIDPattern = new RegExp("[0-9]{17}");
+ return steamUIDPattern.test(input)
+ }
+}