NivaldoFarias / quake-log-parser

TypeScript Log Parser for Quake 3 Arena Log Files

Home Page:https://github.com/NivaldoFarias/quake-log-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Logo

Quake Log Parser PoC

TypeScript Log Parser for Quake 3 Arena Log Files
Browse code» - Run parser locally»

Built With


jest coverage report badge  

Table of Contents

Tasks

Log Parser

The first given task was to create a project to parse the provided Quake 3 Arena log file, these were the requirements for implementation:

  • Read the log file
  • Group the Game data of each match
  • Collect kill data
  • Additional notes:
    • When <world> kills a player, the player loses 1 kill score.
    • Since <world> is not a player, it should not be listed in the dictionary of players or kills.
    • The counter total_kills includes players and <world> kills.

Report and Bonus

The second given task was to create a script that prints a report of the parsed data, there were no requirements for implementation.

As for the Bonus, the task was to include the death causes (means of death) for each match in the report, grouping them by the following categories that were extracted from source code:

// means of death
typedef enum {
  MOD_UNKNOWN,
  MOD_SHOTGUN,
  MOD_GAUNTLET,
  MOD_MACHINEGUN,
  MOD_GRENADE,
  MOD_GRENADE_SPLASH,
  MOD_ROCKET,
  MOD_ROCKET_SPLASH,
  MOD_PLASMA,
  MOD_PLASMA_SPLASH,
  MOD_RAILGUN,
  MOD_LIGHTNING,
  MOD_BFG,
  MOD_BFG_SPLASH,
  MOD_WATER,
  MOD_SLIME,
  MOD_LAVA,
  MOD_CRUSH,
  MOD_TELEFRAG,
  MOD_FALLING,
  MOD_SUICIDE,
  MOD_TARGET_LASER,
  MOD_TRIGGER_HURT,
#ifdef MISSIONPACK
  MOD_NAIL,
  MOD_CHAINGUN,
  MOD_PROXIMITY_MINE,
  MOD_KAMIKAZE,
  MOD_JUICED,
#endif
  MOD_GRAPPLE
} meansOfDeath_t;

Results

The Architecture and Development decisions were made with two essential aspects in mind:

  • Code Readabily/Open Source: maintain the Development Experience fluent and intuitive for any Developer that chooses to study or use the Code as basis or template in the future.
  • DRY/SOLID principles: Write a reusable, flexible and design-focused code. Inherit instruction decisions that intends to lessen the complexity of ambiguous, over-arching codes.

The following snippet is taken from the script's output JSON file:

{
  "games": [
    ...,
    {
      "id": 2,
      "total_kills": 11,
      "players": {
        "Isgalamido": {
          "kills": 0,
          "deaths": 10
        },
        "Dono da Bola": {
          "kills": 0,
          "deaths": 0
        },
        "Mocinha": {
          "kills": 0,
          "deaths": 1
        }
      },
      "items": {
        "weapon_rocketlauncher": 20,
        "ammo_rockets": 11,
        "item_armor_body": 6,
        "ammo_shells": 2,
        "item_health_large": 5,
        "item_quad": 1,
        "item_armor_shard": 11,
        "item_armor_combat": 3,
        "weapon_shotgun": 1,
        "item_health_mega": 1
      },
      "kills_by_means": {
        "MOD_TRIGGER_HURT": 7,
        "MOD_ROCKET_SPLASH": 3,
        "MOD_FALLING": 1
      },
      "elapsed_time": "5:31"
    },
    ...
  ]
}

Installation and Usage

Pre-requisites: Node.js ^18.12.0 (LTS)

Download the zip file and extract it in the root of a new project folder by running these commands:

wget https://github.com/NivaldoFarias/quake-log-parser/archive/main.zip

Then run the following command to install the project's dependencies:

npm install

That's it! You can run the scripts locally to create a new report file by running:

npm run report

The output JSON file will be created in the ./json folder. With relative path ./json/report.json.

About

TypeScript Log Parser for Quake 3 Arena Log Files

https://github.com/NivaldoFarias/quake-log-parser

License:MIT License


Languages

Language:TypeScript 94.1%Language:JavaScript 5.9%