SquadJS/squad-server/log-parser/round-ended.js
2023-04-14 23:45:11 -04:00

22 lines
708 B
JavaScript

/**
* Matches when Map state Changes to PostMatch (ScoreBoard)
*
* Emits winner and loser from eventstore
*
* winner and loser may be null if the match ends with a draw
*/
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogGameState: Match State Changed from InProgress to WaitingPostMatch/,
onMatch: (args, logParser) => {
const data = {
winner: logParser.eventStore.ROUND_WINNER ? logParser.eventStore.ROUND_WINNER : null,
loser: logParser.eventStore.ROUND_LOSER ? logParser.eventStore.ROUND_LOSER : null,
time: args[1]
};
delete logParser.eventStore.ROUND_WINNER;
delete logParser.eventStore.ROUND_LOSER;
logParser.emit('ROUND_ENDED', data);
}
};