Heisenberg is a Python command line application and a library to play drugwars without using the website.
Drugwars is a blockchain based game. That makes it possible for the blockchain accounts to play the game using off-site transactions. Heisenberg is a set of tools to make that easier in Python environments.
Before going into the details of new features, make sure you updated the library in your environment. All changes are backward compatible.
$ (sudo) pip install heisenberg_drugwars --upgrade
Rest Client
This is a new REST API from the drugwars team which serves handful endpoints about the game.
Get the RestClient instance:
from heisenberg.rest_client import RestClient
rest_client = RestClient()
Globals
globals = rest_client.dynamic_global_properties())
print(globals)
Example output:
{
'daily_percent': 3,
'heist_percent': 3,
'last_prod_update': '2019-03-04T13:37:09.151Z',
'drug_production_rate': 3675.5369999999757,
'heist_pool': 86728017,
'balance': '66467.641 STEEM',
'steemprice': 0.3736408799
}
Fights
Return the recent fights of a player.
fights = rest_client.fights(''))
print(fights)
Users
List players by production rate.
users = rest_client.users(max_production_rate=420))
print(users)
User data
Return the game data of a player/
player_data = rest_client.info(''))
print(player_data)
calculate_balance helper
Game doesn't update the balances on resources every second.
Example account data:
'drugs_balance': 420,
'drug_production_rate': 4.200,
'drug_storage': 420000,
'last_update': '2019-03-04T13:37:03.000Z',
That information means that the drug balance was 420 at the 2019-03-04T13:37:03.000Z. It's client's responsibility to calculate regeneration from that balance to calculate the actual, uptodate balance.
heisenberg.utils module has a helper to make that calculation. For example, this snippet will print the actual balance:
rest_client = RestClient()
account_data = rest_client.info('')
print(calculate_balance('drug', account_data))
Auto Invest to Heist script in the repository is also updated to use the available drug balance instead of a fixed -estimated- balance.
Related pull requests:
Updating Attack functionality
The first version of the battle system was designed like this:
With the recent changes on the game, it has changed into a new data structure:
Related changes are implemented to Heisenberg with the new version.
As a side note,the custom_json ID for the battles changed from dw-attack to drugwars. I think the development team plans to get all drugwars related actions into drugwars namespace.
Related Pull Request:
https://github.com/emre/heisenberg/pull/1
Disclaimer
Drugwars is on constant development progress. Custom JSON definitions on the game may change. I am planning to maintain and update the library as long as I play the game, however, make sure you always audit the code and use it on your own risk.