Skip to content

xuequeen/rwrs

 
 

Repository files navigation

Running With Rifles Stats (RWRS)

Players statistics, servers list and more for the Running With Rifles (RWR) game and its Pacific DLC. Available at rwrstats.com.

Features

  • Players
    • Support stats for both the official invasion (vanilla RWR) servers and official Pacific servers
    • Search for a player
    • View player stats (as well as next rank progression, unlocks, on which server he's playing on, etc)
    • Compare two players stats
    • Friends list (easily know on which server your friends are playing on. There's no need to create a user account or whatever)
    • Players list (leaderboard)
  • Public servers
    • Real servers location
    • Real maps name
    • Official invasion (ranked) servers are highlighted
    • Game mode (coop, PvPvE, etc) and type (vanilla RWR, Pacific DLC, etc)
    • Public server details (players list with link to their profile, current map preview and minimap, etc)
    • Filtering capabilities
  • Online servers count (+ the active ones)
  • Total players count (+ online ones + number of playing friends)
  • Charts (for the past week)
    • Number of online players
    • Number of online servers (+ the active ones)
    • Number of players on a server
  • Root RWR servers status (online multiplayer)
  • Discord bot able to give several kind of information. Available on the RWR Discord Server. Commands documentation

Prerequisites

  • Should work on any Python 3.x version. Feel free to test with another Python version and give me feedback
  • A modern web browser (which optionally support localStorage)
  • (Optional, but recommended) A uWSGI-capable web server
  • (Optional) Running With Rifles, if you need to extract images

Installation

  1. Clone this repo somewhere
  2. pip install -r requirements.txt
  3. set FLASK_APP=rwrs.py
  4. flask db upgrade

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 value
  • DEBUG Enable/disable debug mode
  • SERVER_NAME The IP or hostname where RWRS will be available

More informations on the three above can be found here.

  • BETA Whether or not to enable the beta mode
  • GAUGES_SITE_ID A Gauges site 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)
  • BETA_USERS The credentials required to access the app when beta mode is enabled. You can specify multiple ones. It is highly recommended to serve RWRS through HTTPS because it uses HTTP basic auth
  • STEAM_API_KEY A Steam API key
  • PACIFIC_PLAYERS_RANKS_COUNTRY Ranks image / name to show for the Pacific players stats (us, jp)
  • DISCORD_BOT_TOKEN Authentication token used by the RWRS Discord bot
  • DISCORD_BOT_CHANNEL_ID The Discord channel ID the bot is allowed to talk in

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:

python local.py

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.

  1. pip install -r requirements-dev.txt
  2. set FLASK_APP=rwrs.py
  3. 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.

  1. set FLASK_APP=rwrs.py
  2. 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.

  1. pip install -r requirements-dev.txt
  2. set FLASK_APP=rwrs.py
  3. flask extract_minimaps --steamdir="{path to the Steam root directory}"

This command requires the game to be installed.

Clearing cache

  1. set FLASK_APP=rwrs.py
  2. flask cc

Clearing old graphs data

Data older than one week old will be deleted.

  1. set FLASK_APP=rwrs.py
  2. flask clean_players_count

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.

  1. set FLASK_APP=rwrs.py
  2. flask get_players_count

Migrating the database

  1. set FLASK_APP=rwrs.py
  2. flask db upgrade

Save RWR root servers status

Will ping RWR root servers and store their status (up or down).

  1. set FLASK_APP=rwrs.py
  2. flask get_root_rwr_servers_status

Run the RWRS Discord bot

  1. set FLASK_APP=rwrs.py
  2. flask run_discord_bot

Update the MaxMind GeoLite2 City database

sh scripts/geolite2_city_updater.sh

Update RWRS

sh scripts/rwrs_updater.sh [DOMAIN, default=rwrstats.com]

How it works

This project is mainly powered by Flask (Python) for the backend.

Data is fetched from the official servers list page (which sucks) as well from the official players list page (which sucks, too). Data is cached so there isn't many requests sent to the server who hosts these lists.

As the provided servers location is most of the time either missing or invalid, RWRS makes its own look up using a GeoLite2 database.

Credits

End words

If you have questions or problems, you can either:

About

Players statistics, servers list and more for the Running With Rifles (RWR) game and its Pacific DLC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.1%
  • HTML 29.0%
  • CSS 8.6%
  • JavaScript 7.2%
  • Other 1.1%