Longhorn-Riichi / InjusticeJudge

Announce to the world why your Mahjong Soul/tenhou.net/Riichi City losses are unjustified
2 stars 3 forks source link

InjusticeJudge

Analyzes your Mahjong Soul, tenhou.net, or Riichi City game to find instances of mahjong injustice. Currently, it checks for:

Note: This program was explicitly written to

1) be funny 2) demonstrate how common some of these perceived injustices are.

What appears as an injustice to you may be well justified from another player's perspective!

Skills

Newest feature on the block is skill detection. Skills are instances of pure mahjong skill. Examples include:

Skills are pretty common. There's usually several in every game, and InjusticeJudge will recognize your skills for what they are.

Installation

You need a pipenv and python 3.10+

pipenv install

Usage (standalone)

Clone this repository, install requrements and run with either:

where 0 = East, 1 = South, 2 = West, 3 = North.

Outputs injustices to console.

To output skills use -m skill:

To output both skills and injustice use -m both:

Usage (library)

import asyncio
from injustice_judge import analyze_game

# output injustices
asyncio.run(analyze_game("tenhou link")) # Use player from link
asyncio.run(analyze_game("tenhou link", {2})) # West player
asyncio.run(analyze_game("tenhou link", {0,1,2,3})) # All players

# output skills for each player
asyncio.run(analyze_game("tenhou link", look_for={"skill"})) # Use player from link
asyncio.run(analyze_game("tenhou link", {0,1,2,3}, look_for={"skill"})) # All players

# do both
asyncio.run(analyze_game("tenhou link", {0,1,2,3}, look_for={"injustice", "skill"}))

Setup for mahjong soul links

This is only required if you want to analyze mahjong soul logs. Create a config.env file and choose one option below:

Option 1: login to Chinese server with username and password

ms_username = "<your username>"
ms_password = "<your password>"

Option 2: login to EN server with uid and token

ms_uid = "<your uid>"
ms_token = "<your token>"

Both your UID (not friend code!) and token can be found by capturing the login request. To do this:

Setup for riichi city links

rc_sid = "<your sid>"

The sid can be found by capturing the cookies of any logged-in request. To do this:

Remember to close out of mitmweb and undo your proxy setting!