Running With Rifles Stats (RWRS)
Players statistics, servers list and more for the Running With Rifles (RWR) game as well as its Pacific and Edelweiss DLCs. Available at rwrstats.com.
Your everyday RWR companion tool!
Prerequisites
- Should work on any Python 3.x version
- A modern web browser
- A MySQL-compatible DBMS (MySQL, MariaDB, Percona, etc)
- (Optional, but recommended) A uWSGI-capable web server
- (Optional) Running With Rifles, if you need to extract data by using the commands below
Installation
- Clone this repo somewhere
- Copy
.env.local
to.env
pip install -r requirements-dev.txt
flask db upgrade
bash scripts/geolite2_city_updater.sh
Configuration
Copy the config.example.py
file to config.py
and fill in the configuration parameters.
Available configuration parameters are:
SECRET_KEY
Set this to a complex random valueSERVER_NAME
The IP or hostname where RWRS will be available
More informations on the two above can be found here.
DB_USERNAME
Username to access the DBMS (production env only)DB_PASSWORD
Password to access the DBMS (production env only)DB_UNIX_SOCKET
If set,DB_HOST
andDB_PORT
will be ignored in favor of using this Unix socket to communicate with the DBMS (production env only)DB_HOST
Host of the DBMS (production env only)DB_PORT
Port of the DBMS (production env only)DB_NAME
Name of the database to use (production env only)GA_TRACKING_ID
A Google Analytics tracking ID used to track visits on RWRS (optional)CACHE_THRESHOLD
The maximum number of items the cache will store before it starts deleting some (see here for more configuration parameters related to Flask-Cache)SERVERS_CACHE_TIMEOUT
Cache duration of the servers list (in seconds)PLAYERS_CACHE_TIMEOUT
Cache duration of the players list as well as data for a single player (in seconds)GRAPHS_DATA_CACHE_TIMEOUT
Cache duration of the graphs data, both the players and the servers ones (in seconds)STEAM_PLAYERS_CACHE_TIMEOUT
Cache duration of the total number of players (in seconds)STEAM_API_KEY
A Steam API keyMAX_NUM_OF_PLAYERS_TO_TRACK_STATS_FOR
How many players should RWRS track the stats for (top players storted by XP)DISCORD_CLIENT_ID
A Discord client IDDISCORD_PUBLIC_KEY
A Discord app public keyDISCORD_CLIENT_SECRET
A Discord client secretDISCORD_TESTING_GUILD
A Discord guild ID where to register commands into, for testing purposes (defaults to None)
I'll let you search yourself about how to configure a web server along uWSGI.
Usage
- Standalone
Run the internal web server, which will be accessible at http://localhost:8080
:
flask run
Edit this file and change the interface/port as needed.
- uWSGI
The uWSGI file you'll have to set in your uWSGI configuration is uwsgi.py
. The callable is app
.
- Others
You'll probably have to hack with this application to make it work with one of the solutions described here. Send me a pull request if you make it work.
Extracting ranks data and images
The Flask command flask extract-ranks
is used to extract and save all ranks data to a JSON file located at storage/data/ranks.json
.
It also retrieve, process (the actual images content isn't centered) and save all the RWR ranks images. They are saved
at static/images/ranks/{country}/{rank ID}.png
and static/images/ranks/{country}/{rank ID}_icon.png
.
pip install -r requirements-dev.txt
flask extract-ranks --steamdir="{path to the Steam root directory}"
This command requires the game to be installed.
Extracting maps data
The Flask command flask extract-maps-data
is used to extract and save all maps data to a JSON file located at storage/data/maps.json
.
flask extract-maps-data --steamdir="{path to the Steam root directory}"
This command requires the game to be installed.
Extracting minimaps
The Flask command flask extract-minimaps
is used to extract minimaps (the ones displayed when pressing on
TAB). They are saved at static/images/maps/minimap/{map ID}.png
and static/images/maps/minimap/{map ID}_thumb.png
.
pip install -r requirements-dev.txt
flask extract-minimaps --steamdir="{path to the Steam root directory}"
This command requires the game to be installed.
Clearing cache
flask cc
Updating commands in Discord
flask update-discord-commands
Clearing old graphs data
Data older than one week old will be deleted.
flask clean-players-count
Computing promotions for all players
flask compute-promotions
Storing actual number of players (for graphs)
Will save the current number of Steam players which have RWR running, and the current number of players playing online.
flask get-players-count
Migrating the database
flask db upgrade
Updating the MaxMind GeoLite2 City database
More information in the script comments.
bash scripts/geolite2_city_updater.sh
Updating RWRS
More information in the script comments.
bash scripts/rwrs_updater.sh [TYPE, default=fast, fast|full]
Generating RWRS REST API documentation
More information in the script comments.
bash scripts/api_doc_generator.sh
Retrieve and save the players stats in DB
flask save-players-stats [--reset]
Retrieve and save the ranked servers moderators
flask save-ranked-servers-mods
Import rwrtrack data
flask import-rwrtrack-data --directory="{path to the rwrtrack data directory}" [--reset]
Credits
You'll find credits and legal mentions here.
Feedback
If you have suggestions or problems you can submit an issue here on GitHub or head over here.