Batch-scout script for Rabona

in Programming & Dev3 years ago (edited)

I'm a fan of automating. I really hate doing things manually if there is a way to automate them. And if you're playing a blockchain game, then there are a lot of actions that can be automated.

The scouting aspect in the game is one of them. I scout a lot, like really a lot. Every time I click the scout button, I wait for the game to process, then check the player stats, then repeat. This is very time-consuming if you scout let's say, fifty players at a time.

This python script automates these actions:

  • creates a custom JSON op to trigger scout
  • waits until the game processes the transaction
  • prints the player stats if os > 60

import argparse
import json
import time

from lighthive.client import Client
from lighthive.datastructures import Operation
from rabona_python import RabonaClient

rabona_client = RabonaClient()

PLAYER_TYPE_GOAL_KEEPER = "1"
PLAYER_TYPE_DEFENDER = "2"
PLAYER_TYPE_MIDFIELDER = "3"
PLAYER_TYPE_ATTACKER = "4"

PLAYER_TYPE_MAP = {
    PLAYER_TYPE_GOAL_KEEPER: "goal keeper",
    PLAYER_TYPE_DEFENDER: "defender",
    PLAYER_TYPE_MIDFIELDER: "midfielder",
    PLAYER_TYPE_ATTACKER: "attacker",
}


def create_custom_json_op(username):
    scout_json = json.dumps(
        {
            "username": username,
            "type": "scout_players",
            "command": {"tr_var1": username}
        }
    )

    train_op = Operation('custom_json', {
        'required_auths': [],
        'required_posting_auths': [username, ],
        'id': 'rabona',
        'json': scout_json,
    })
    return train_op


def get_signable_player(trx_id):
    signable_players = rabona_client.signable_player(trx=trx_id)
    if not signable_players.get("players", []):
        time.sleep(3)
        return get_signable_player(trx_id)

    return signable_players.get("players")[0]


def scout(total, username, pkey):
    lighthive_client = Client(keys=[pkey, ])
    print('> Will scout %s players for %s.' % (total, username))
    for i in range(total):
        op = create_custom_json_op(username)
        trx_id = lighthive_client.broadcast_sync(op).get("id")
        time.sleep(3)
        signable_player = get_signable_player(trx_id)
        if signable_player.get("overall_strength") > 60:
            print("> Scouted: %s. Type: %s, OS: %s, TP: %s" % (
                signable_player.get("name"),
                PLAYER_TYPE_MAP.get(signable_player.get("type")),
                signable_player.get("overall_strength"),
                signable_player.get("teamplayer"),
            ))


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Batch scout tool')
    parser.add_argument('username', metavar='U', type=str,
                        help='Your team\'s username')
    parser.add_argument('count', metavar='N', type=int,
                        help='How many players do you want to scout?')
    parser.add_argument('posting_key', metavar='P', type=str,
                        help='Private posting key')
    args = parser.parse_args()
    scout(args.count, args.username, args.posting_key)

Example output:



Screenshot 2021-02-10 at 11.08.30.png


Requires Python3.6. lighthive, rabona_client python libraries must be installed.

You can run it like:

$ python main.py <username> <amount_of_players> <private_posting_key>

Sort:  

.

good suggestion but not sure if the game backend parse the custom jsons like that :)

!!!!!! THIS IS THE WAY !!!!!! I love it!

Really seem to be into this game

yeah, it's a kind of challenge for me. :)

QuoteRequires Python3.6. lighthive, rabona_python python libraries must be installed.

Right?

Hi @emrebeyler ,
I have a problem with a certain plugin, you can see it in the pic below.
Can you help me please?
image.png