Add log time save with decimal
parent
b266d6f972
commit
3ccdbe4da3
|
@ -10,7 +10,7 @@ const LogBudgetSchema = new Schema({
|
|||
required: true
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
fraction: {
|
||||
|
|
|
@ -10,7 +10,7 @@ const LogFlagSchema = new Schema({
|
|||
required: true
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
player: {
|
||||
|
|
|
@ -10,7 +10,7 @@ const LogKillSchema = new Schema({
|
|||
required: true
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
shooter: {
|
||||
|
|
|
@ -10,7 +10,7 @@ const LogKillSchema = new Schema({
|
|||
required: true
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
ptBlufor: {
|
||||
|
|
|
@ -10,7 +10,7 @@ const LogRespawnSchema = new Schema({
|
|||
required: true
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
player: {
|
||||
|
|
|
@ -10,7 +10,7 @@ const LogReviveSchema = new Schema({
|
|||
required: true
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
medic: {
|
||||
|
|
|
@ -10,7 +10,7 @@ const LogTransportSchema = new Schema({
|
|||
required: true
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
driver: {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const timeStringToDecimal = require('../tools/util').timeStringToDecimal;
|
||||
const arrayContains = require('./util').arrayContains;
|
||||
|
||||
const parseWarLog = (lineArray, war) => {
|
||||
|
@ -46,7 +47,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
|
||||
stats.kills.push({
|
||||
war: war._id,
|
||||
time: getDateTime(line.split(' ')[5]),
|
||||
time: timeStringToDecimal(line.split(' ')[5]),
|
||||
shooter: shooter ? shooter.name : null,
|
||||
target: target.name,
|
||||
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
|
||||
|
@ -85,7 +86,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
|
||||
stats.flag.push({
|
||||
war: war._id,
|
||||
time: getDateTime(line.split(' ')[5]),
|
||||
time: timeStringToDecimal(line.split(' ')[5]),
|
||||
player: playerName,
|
||||
flagFraction: flagFraction,
|
||||
capture: capture
|
||||
|
@ -132,7 +133,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
|
||||
stats.revive.push({
|
||||
war: war._id,
|
||||
time: getDateTime(line.split(' ')[5]),
|
||||
time: timeStringToDecimal(line.split(' ')[5]),
|
||||
stabilized: stabilized,
|
||||
medic: medic.name,
|
||||
patient: patient.name,
|
||||
|
@ -155,7 +156,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
|
||||
stats.transport.push({
|
||||
war: war._id,
|
||||
time: getDateTime(line.split(' ')[5]),
|
||||
time: timeStringToDecimal(line.split(' ')[5]),
|
||||
driver: driver.name,
|
||||
passenger: passenger ? passenger.name : null,
|
||||
fraction: driver.fraction,
|
||||
|
@ -187,7 +188,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
const getRespawnEntry = (respawn, playerName, warId) => {
|
||||
return {
|
||||
war: warId,
|
||||
time: getDateTime(respawn[5]),
|
||||
time: timeStringToDecimal(respawn[5]),
|
||||
player: playerName
|
||||
}
|
||||
};
|
||||
|
@ -195,7 +196,7 @@ const getRespawnEntry = (respawn, playerName, warId) => {
|
|||
const getPointsEntry = (pt, line, warId) => {
|
||||
return {
|
||||
war: warId,
|
||||
time: getDateTime(pt[5]),
|
||||
time: timeStringToDecimal(pt[5]),
|
||||
ptBlufor: parseInt(pt[12]),
|
||||
ptOpfor: parseInt(pt[15].slice(0, -1)),
|
||||
fraction: line.includes('no Domination') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
|
||||
|
@ -205,7 +206,7 @@ const getPointsEntry = (pt, line, warId) => {
|
|||
const getBudgetEntry = (budg, warId) => {
|
||||
return {
|
||||
war: warId,
|
||||
time: getDateTime(budg[5]),
|
||||
time: timeStringToDecimal(budg[5]),
|
||||
fraction: budg[9] === 'NATO' ? 'BLUFOR' : 'OPFOR',
|
||||
oldBudget: transformMoneyString(budg[11]),
|
||||
newBudget: transformMoneyString(budg[14])
|
||||
|
@ -231,9 +232,4 @@ const transformMoneyString = (budgetString) => {
|
|||
|
||||
};
|
||||
|
||||
const getDateTime = (timeString) => {
|
||||
const timeZone = 'Z';
|
||||
return new Date('1999-01-01T0' + timeString + timeZone);
|
||||
};
|
||||
|
||||
module.exports = parseWarLog;
|
||||
|
|
|
@ -24,5 +24,27 @@ const playerArrayContains = (arr, item) => {
|
|||
return matchFound;
|
||||
};
|
||||
|
||||
const timeStringToDecimal = (timeString) => {
|
||||
const timeArray = timeString.split(':');
|
||||
const hour = parseInt(timeArray[0]);
|
||||
const sek = parseInt(timeArray[1]) * 60 + parseInt(timeArray[2]);
|
||||
|
||||
return hour + sek * (1 / 3600);
|
||||
};
|
||||
|
||||
|
||||
const decimalToTimeString = (decimal) => {
|
||||
const hours = parseInt(decimal.toString().split(".")[0]);
|
||||
const minutesFloat = ((decimal % 1) * 3600) / 60;
|
||||
const minutes = parseInt(minutesFloat.toString().split(".")[0]);
|
||||
const seconds = Math.round((minutesFloat - parseInt(minutes)) * 60);
|
||||
|
||||
return (hours < 10 ? '0' + hours : hours) + ':' +
|
||||
(minutes < 10 ? '0' + minutes : minutes) + ':' +
|
||||
(seconds < 10 ? '0' + seconds : seconds);
|
||||
};
|
||||
|
||||
exports.sortCollection = sortCollectionBy;
|
||||
exports.arrayContains = playerArrayContains;
|
||||
exports.timeStringToDecimal = timeStringToDecimal;
|
||||
exports.decimalToTimeString = decimalToTimeString;
|
||||
|
|
|
@ -33,8 +33,7 @@ export class WarDetailComponent {
|
|||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private warService: WarService,
|
||||
private logsService: LogsService) {
|
||||
private warService: WarService) {
|
||||
Object.assign(this, this.playerChart)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue