Challenge

1. Tasks

1.1. Log parser

Create a project to parse the Quake log file.

The log file was generated by a Quake 3 Arena server, including a great deal of information about every match.

The project should implement the following functionalities:

  • Read the log file
  • Group the game data of each match
  • Collect kill data

Example

21:42 Kill: 1022 2 22: <world> killed Isgalamido by MOD_TRIGGER_HURT

The player "Isgalamido" died because he was wounded and fell from a height enough to kill him.

2:22 Kill: 3 2 10: Isgalamido killed Dono da Bola by MOD_RAILGUN

The player "Isgalamido" killed the player "Dono da Bola" using the Railgun weapon.

Example of grouped information for each match:

"game_1": {
"total_kills": 45,
"players": ["Dono da bola", "Isgalamido", "Zeh"],
"kills": {
  "Dono da bola": 5,
  "Isgalamido": 18,
  "Zeh": 20
  }
}

Additional notes:

  1. When <world> kill a player, that player loses -1 kill score.
  2. Since <world> is not a player, it should not appear in the list of players or the dictionary of kills.
  3. The counter total_kills includes player and world deaths.

1.2. Report

Create a script that prints a report (grouped information) for each match and a player ranking.

1.3. Plus

Generate a report of deaths grouped by death cause for each match.

Death causes (extracted from source code)

Example

"game-1": {
  "kills_by_means": {
    "MOD_SHOTGUN": 10,
    "MOD_RAILGUN": 2,
    "MOD_GAUNTLET": 1,
    ...
  }
}

Solution


Setup

To run the project will be necessary to install the Node Javascript Runtime version >= 16.15.1. After that, clone this repository and open its folder. To install the dependencies, run the following command at the terminal

npm install

Run

-- Log file --

The program will default search for the file with the name qgames.log in the root directory. If you want to change this behavior, open up src/index.ts and change where *** Log file name *** is like the example below.

(async (): Promise<void> => {
  const logFile = path.resolve('*** Log file name***')
  .
  .
)  

After choosing the log file to be parsed run the code below to execute each task asked.

npm run start