Add log parsing for transport data into player object (CC-33)

pull/51/head
HardiReady 2019-02-10 15:22:57 +01:00
parent b351301bea
commit 836da0c6d4
3 changed files with 41 additions and 10 deletions

View File

@ -14,6 +14,8 @@ Basic player statistic information object
+ respawn: 2 (number, required) - sum of respawns + respawn: 2 (number, required) - sum of respawns
+ flagTouch: 1 (number, required) - sum of flag captures + flagTouch: 1 (number, required) - sum of flag captures
+ revive: 0 (number, required) - sum of revives + revive: 0 (number, required) - sum of revives
+ travelDistance: 16535 (number, optional) - sum of transport meters as passenger
+ driverDistance: 1250 (number, optional) - sum of transport meters as pilot/driver
# WarPlayer (BasicPlayer) # WarPlayer (BasicPlayer)
@ -23,7 +25,6 @@ A player campaign statistics object
+ _id: `5ab68d42f547ed304064e5f7` (string, required) - unique id of the army member + _id: `5ab68d42f547ed304064e5f7` (string, required) - unique id of the army member
+ warId: `5abf65ae3fc5fa349ffd5ca3` (string, required) - war in which this player took part + warId: `5abf65ae3fc5fa349ffd5ca3` (string, required) - war in which this player took part
+ steamUUID: 76561192214911200 (number, optional) - unique ID for STEAM platform account + steamUUID: 76561192214911200 (number, optional) - unique ID for STEAM platform account
+ sort: 1 (number, required) - sorting number calculated by (kill + revive + flagTouch - friendlyFire - death - respawn)
+ performance: `5abf65ae3fc5fa349ffd5cs2` (string, optional) - id of corresponding performance log entry + performance: `5abf65ae3fc5fa349ffd5cs2` (string, optional) - id of corresponding performance log entry
+ timestamp: `2018-02-24T01:01:25.825Z` - the entity creation timestamp + timestamp: `2018-02-24T01:01:25.825Z` - the entity creation timestamp
+ updatedAt: `2018-02-24T01:01:25.825Z` - the version timestamp + updatedAt: `2018-02-24T01:01:25.825Z` - the version timestamp

View File

@ -72,11 +72,6 @@ const PlayerSchema = new Schema({
set: (v) => Math.round(v), set: (v) => Math.round(v),
required: true, required: true,
}, },
sort: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
},
steamUUID: { steamUUID: {
type: Number, type: Number,
get: (v) => Math.round(v), get: (v) => Math.round(v),
@ -87,7 +82,20 @@ const PlayerSchema = new Schema({
ref: 'LogServerFpsSchema', ref: 'LogServerFpsSchema',
required: false, required: false,
}, },
}, { travelDistance: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: false,
},
driverDistance: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: false,
},
},
{
collection: 'player', collection: 'player',
timestamps: {createdAt: 'timestamp'}, timestamps: {createdAt: 'timestamp'},
}); });

View File

@ -354,9 +354,31 @@ const parseWarLog = (lineArray, war) => {
stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length; stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length;
stats.players[i]['sort'] = stats.players[i]['kill'] + stats.players[i]['revive'] + let playerTravelDistance = stats.transport.filter((transport) => transport.passenger === playerName)
stats.players[i]['flagTouch'] .map((transport) => transport.distance)
- stats.players[i]['friendlyFire'] - stats.players[i]['death'] - stats.players[i]['respawn']; .reduce((total, num) => total + Math.round(num), 0);
if (playerTravelDistance > 0) {
stats.players[i]['travelDistance'] = playerTravelDistance;
}
let driverDistance = 0;
const driverTransports = stats.transport.filter((transport) => transport.driver === playerName);
for (let i = 0; i < driverTransports.length; i++) {
const curr = driverTransports[i];
if (i < driverTransports.length - 1) {
const next = driverTransports[i + 1];
if ((next.time.getTime() - curr.time.getTime()) < 2 * 60000) { // only track once in 2 min range
continue;
}
driverDistance += curr.distance;
} else {
driverDistance += curr.distance;
}
}
if (driverDistance > 0) {
stats.players[i]['driverDistance'] = driverDistance;
}
} }
stats.war.playersBlufor = stats.players.filter((player) => player.fraction === 'BLUFOR').length; stats.war.playersBlufor = stats.players.filter((player) => player.fraction === 'BLUFOR').length;