Git Product home page Git Product logo

quakestats's Introduction

Quake Stats

PyPI PyPI - Wheel

Quake 3 logs / Quake Live events processing project.

Allows to retrieve, process, analyze, store and present Quake matches.

The project doesn't aim to give global stats like qlstats it's rather meant to store statistics from some server group (server domain). The origins of Quake Stats come from a group of players who occasionally play together and want to keep track of their matches... and to have fun from some custom made medals (badges) :)

Overview

Supported features:

  • processing Quake 3 logs (log parsing, transforming to QL)
  • processing Quake Live event streams (zmq listen on QL server stat endpoint)
  • translating (to some extent) Quake 3 logs into Quake Live events
  • analysing matches
  • storing matches in Database backend (Mongo DB)
  • presenting match results through a web application

Supported mods and game modes

Unfortunately only OSP FFA from Quake 3 is well tested as it was the main use case

mods

  • - OSP (http://www.orangesmoothie.org/tourneyQ3A/index.html)
  • - Quake Live - most of event processing is implemented
  • - Edawn - requires 1.6.3+ (enchanced logging)
  • - vanilla Q3 not supported (need workaround for missing ServerTime)
  • - CPMA not supported (need workaround for missing ServerTime)

modes

  • - DUEL
  • - FFA
  • - CA - partially implemented
  • - TDM
  • - CTF

Custom medals

Are described here resources.js

Examples

The stats are presented with fancy charts, custom medals, etc. See the examples below.

Total badges/medals board

home1

Total kills & deaths

home2

Single match Kill Death Ratio, Worst Enemy, Score over Time chart

match1

Requirements

  • Python 3.6+
  • Instance of Mongo DB (pointed by settings.py)
  • Modern web browser (requires css grid-layout)

How to setup

In order to setup the application you need to have python 3.6+ (virtualenv recommended) and an instance of mongo DB.

Installation

Install from pip package

pip install quakestats

Install from source code (optional)

Is also needed install quakestats package (in virtualenv if you are using it). To do that you could install it directly

pip install -r requirements.txt
python setup.py install

Configuration file

The application is configured by setting QUAKESTATS_SETTINGS environment variable to path to configuration file. See example settings.py

Verify if everything is properly set up

Quake Stats provide a simple CLI with a command to verify an environment

quakestats status

Example output:

(venv) [user@pc quakestats]$ quakestats status
app -> version: 0.9.61
settings -> env var: /opt/quakestats/settings.py
settings -> RAW_DATA_DIR: /opt/quakestats/data
db -> ping: {'ok': 1.0}
webapp -> loadable: Quakestats webapp is loadable

Run Quake Stats web app

You can setup Quake Stats web app with any websever you want (as long as it supports python, e.g. mod wsgi, uwsgi). This documentation covers only running in twisted webserver

Run in twistd (example)

You can launch Quake Stats web application using twistd webserver. Just make sure to install twisted framework first. Also make sure to use some recent version of twisted (tested with 18.7.0 installed by pip).

pip install twisted
FLASK_APP="quakestats.web"; QUAKESTATS_SETTINGS=`pwd`/settings.py; twistd web --wsgi quakestats.web.app

User/Admin guide

Setup admin user

Admin user is used by web application to access some additional administrative operations. For now it's only setting map sizes. Just to have a list of recently used maps and their sizes. Nothing more at the moment.

# you need to run the command in proper python environment
# use "quakestats status" to check your environment
quakestats set-admin-pwd <yourpassword>

Collecting Quake Live stats

Quake Live exposes stats server through tcp socket (zmq) authenticated with password. CLI can gather stats from multiple QL servers and process them automatically. Use following config file

[server-1]
ip = 5.6.7.8
port = 27967
password = password1

[server-1]
ip = 1.2.3.4
port = 27967
password = password2

Use following CLI to start collecting events (assuming your config file is named collector.cfg)

quakestats collect-ql collector.cfg

Uploading Quake 3 log file

In order to process some data you need to send your match log file to web api endpoint /api/v2/upload. By default mod osp is assumed. Mod specific endpoint is served under /api/v2/upload/<mod>, e.g. /api/v2/upload/edawn You need an ADMIN_TOKEN set in configuration.

curl -X POST --form file=@/path/to/your/games.log --form token=adminsecrettoken host:port/api/v2/upload

To send vanila q3 log use

curl -X POST --form file=@/path/to/your/games.log --form token=adminsecrettoken host:port/api/v2/upload/baseq3

To send edawn log use

curl -X POST --form file=@/path/to/your/games.log --form token=adminsecrettoken host:port/api/v2/upload/edawn

All log files with extracted matches are stored in directory determined by RAW_DATA_DIR config entry

Using automated script to send logs

TODO, deprecated

Rebuilding database

You can rebuild your database using files stored in RAW_DATA_DIR with simple web api call or CLI.

curl -X POST host:port/api/v2/admin/rebuild --form token=adminsecrettoken
# you need to run the command in proper python environment
# use "quakestats status" to check your environment
quakestats rebuild-db

If you implement some new Medals or any other backend related feature this API call will clear previous data stored in DB and process all matches from data directory once again.

Merging player results

Unfortunately the only way to distinguish players in Quake 3 servers is to use player nickname. When player changes his nickname between matches he will be treated as new unique player. In such cases admin can merge results of two specific players. Use with caution as it will rewrite history of all matches stored in database.

curl -X POST host:port/api/v2/admin/players/merge --form token=admintoken --form source_player_id=297f6272f79d4918c4efe098 --form target_player_id=df55e5cd4582d6f14cd20746

It will merge all results from player with id 297f6272f79d4918c4efe098 into player with id df55e5cd4582d6f14cd20746. To find out how player ID is build see the development section.

Importing preprocessed match log

Preprocessed match logs stored in RAW_DATA_DIR can be imported using admin match import API. This can be particularly useful when e.g. debugging some bugs on dev infra.

curl -X POST --form [email protected] --form token=admintoken host:port/api/v2/admin/match/import

Development

Tech stack

Python, Flask, MongoDB, d3.js, riot.js, zmq

How does it work with Quake 3 Players

Quake 3 players don't have unique ID's so it's hard to distinguish players between matches. In order to overcome this problem each player has player_id assigned during match analysis. The ID is constructed as hash of SERVER_DOMAIN and player nickname as a result it's consistent between matches as long as player keeps his nickname and there is no nickname clash. Perhaps there is some better way? Server side auth?

Web

Web application related components

  • api - web API used by frontend and to retrieve Quake 3 logs
  • views - typical flask views

Extending

How to add new medal

Running tests

make test

Assets

Medals, icons, etc. Some of the assets are missing it would be nice to find some free ones or draw them ;)

How to release new version

bumpversion <major|minor|patch> --commit --tag

Troubleshooting

Can't use mongodb 5.0+ without AVX on Ubuntu 20+

This problem occurs on older hardware when mongodb 5.0+ is being used. You can't use official mongodb packages with version higher than 4.x. 4.x series is the last one not using AVX. BUT it requires libssl1.1 and it's no longer shipped with Ubuntu. Fortunately it's possible to install libssl1.1 from http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/. Then just install mongodb 4.x.

quakestats's People

Contributors

brabiega avatar kmrosek avatar krzysztofsmokowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

quakestats's Issues

add new medal - Weltschmerz

The medal would be added when the worst enemy of a player is the world.

If multiple players met the condition then:

  • prefer player with most deaths from the world
  • prefer player who was killed by the world closer to the end of game

Add support for vanilla q3

At the moment only enchanced logs from OSP are supported.
The difference between log format in OSP and vanilla Q3 lies in:

  • log format:
# vanilla q3 (minutes:seconds)
0:00 ClientConnect: 0

# osp (seconds.tenths of seconds)
0.4 ClientConnect: 0
  • OSP introduces new event in lgos:
0.0 ServerTime: 20200319210429  21:04:29 (19 Mar 2020)

This is the only way to know when the match actually happened.
It's good to know when a match happens if single log file consists multiple matches.
Also thanks to server time quakestats currently ignores duplicates (e.g. the same log uploaded for parsing multiple times).

So there are two problems to solve for vanilla q3 support:

  1. How to ignore matches from log file which was already parsed in the past?
  2. What was the date and time when the match happened?

add new medal - mind the gap please

Assigned at the end of the match if any player on the score list has score 2x lower than player before him.

Example.

3rd player has 60 frags
4th player has 30 frags

4th player get's "Mind the gap" Badge

Final scores table sort is incorrect

Probably there is no score timestamp taken under consideration.

So two players having the same score are sorted in non-deterministic way.

Always sort scores so last score timestamp counts.

add new medal - Marauder

Special score would be assigned on killing opponents which are before you.

Player with highest and latest score get's the badge

Rudy 102 badge

User with most 'damage dealt' who is still in 1-4 places should get it.

setup.py shouldn't use easy_install

After invocation of setup.py develop i have faced an issue that it wants to compile some modules, it should be installed from the wheel file. It seems that we have to use pip instead of easy_install

Add event marks on chart

E.g when headhunter was earned.

Would be nice to show it on score chart.
Might not be trivial to implement

add new medal - eye to eye

Player B is killed by player A but within next 3 seconds player B kills player A.
(E.g. player B died but managed to shoot a rocket and killed player A)

Add support for event matches

E.g. would be nice to tag matches with some 'event'.

The main goal would be to create set of 1v1 tournament matches ideally with ladder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.