Add revive and flag parsing

pull/15/head
Florian Hartwich 2017-10-21 10:41:49 +02:00
parent f1449e5047
commit db48cd8ef6
1 changed files with 41 additions and 7 deletions

View File

@ -12,7 +12,6 @@ const parseWarLog = (lineArray, war) => {
const flag = [];
const transport = [];
const playerNames = [];
const addPlayerIfNotExists = (playerName) => {
if (playerName !== 'Error: No unit' && !arrayContains(playerNames, playerName)) {
playerNames.push(playerName);
@ -45,7 +44,18 @@ const parseWarLog = (lineArray, war) => {
if (line.includes("Fahne")) {
clean.push(line);
const playerName = line.substring(line.lastIndexOf("t von ") + 6, line.lastIndexOf(" :OPT LOG END"));
const flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR';
const capture = !!line.includes('Flagge erobert');
flag.push({
warId: 'sdf89uiz786',
time: getDateTime(line.split(" ")[5]),
player: playerName,
flagFraction: flagFraction,
capture: capture
});
addPlayerIfNotExists(playerName);
}
if (line.includes("Punkte")) {
@ -71,7 +81,29 @@ const parseWarLog = (lineArray, war) => {
if (line.includes("Revive")) {
clean.push(line);
//console.log(line);
const stabilized = !!line.includes('stabilisiert');
const medicName = line.substring(line.lastIndexOf("wurde von ") + 10, line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt'));
const medicNameArray = medicName.split(" ");
const medicFraction = medicNameArray[medicNameArray.length - 1] === "(WEST)" ? "BLUFOR" : "OPFOR";
const sanitizedMedicName = medicName.substring(0, medicName.indexOf(medicNameArray[medicNameArray.length - 1]) - 1);
const patientName = line.substring(line.lastIndexOf("|| ") + 3, line.lastIndexOf(" wurde von"));
const patientNameArray = patientName.split(" ");
const patientFraction = patientNameArray[patientNameArray.length - 1] === "(WEST)" ? "BLUFOR" : "OPFOR";
const sanitizedPatientName = patientName.substring(0, patientName.indexOf(patientNameArray[patientNameArray.length - 1]) - 1);
revive.push({
warId: 'asfddf',
time: getDateTime(line.split(" ")[5]),
stabilized: stabilized,
medic: sanitizedMedicName,
patient: sanitizedPatientName
});
addPlayerIfNotExists(sanitizedMedicName);
addPlayerIfNotExists(sanitizedPatientName);
}
if (line.includes("Transport ||")) {
@ -89,6 +121,7 @@ const parseWarLog = (lineArray, war) => {
transport.push({
war: "blablub7z8",
time: getDateTime(line.split(" ")[5]),
driver: sanitizedDriverName,
passenger: sanitizedPassengerName,
distance: distance
@ -99,7 +132,8 @@ const parseWarLog = (lineArray, war) => {
}
});
//
playerNames.forEach(budg => console.log(budg));
// revive.forEach(budg => console.log(budg));
// console.log(revive.length)
};
function getRespawnEntry(respawn, playerName) {