Introducing Heisenberg, A Python framework to play Drugwars

in #utopian-io6 years ago (edited)


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.

Installation

Installation requires Python3.6 or a greater version. It's always recommended to install the library into a virtual Python environment.

$ pip install heisenberg_drugwars

Usage

from heisenberg.core import Heisenberg

h = Heisenberg(
    'emrebeyler',
    '<private_posting_key>'
)

Investing to heist

tx_data = h.heist(1000)
print(tx_data)

Recruting Units

tx_data = h.unit("bouncer", 1)
print(tx_data)

Upgrades with in-game resources

tx_data = h.upgrade("headquarters")
print(tx_data)

Attack to other players

Note: Battle system is disabled, at the moment.

 tx_data = h.attack(
     "<defender_username>",
     [{'unit': 'knifer', 'amount': 3}, {'unit': 'bouncer', 'amount': 2}]
))

Creating a char

Only once in the beginning.

h.char("1", referer="emrebeyler")

Example script (Auto Investing to Heist)

This script invests 420 DRUGs in every 5 minutes.


See the source in text format.

Heisenberg shell

Heisenberg has an interactive shell where you can set your account credentials and play the game via console.

Run it by typing heisenberg in your console:

$ heisenberg

Available commands:

  • set_credentials username private_posting_key
  • heist <amount>
  • unit <unit_name> <unit_type>

Notes

Even though, you can broadcast the custom jsons with this library, it may not have an affect in the game since @drugwars account is the authority point and they may refuse to pick up transactions if transactions are malformed or includes incorrect data.

For example, if you have 10k DRUGs and try investing 20k DRUGs, your transactions won't be picked up by the game since you don't have enough balance.

Also, if you didn't created your game account and want to try, consider registering with my reference link which will give me a %5 bonus on your earnings.

Roadmap

  • Bundle the game data (Buildings, Units, etc.) with the library to add validation on operations.

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.

Vote for my witness

I do my best to support the blockchain with my skills. If you like what I do, consider casting a vote on via Steemconnect or on steemit.com

Sort:  

I've been playing Drugwars a bit (I used to play a game called Tribal Wars which, could also be a interesting if implemented on the Steem blockchain imo), and it's pretty awesome how they made it in under a month. It's really cool to see you're already creating a Python package for it as well - hopefully you can keep it up to date with the many changes happening!

As for the code; overall the quality is very high as usual, and I could only spot a couple of issues, but here's some feedback anyway:

  • Think you could use @classmethod or @staticmethod for do_exit in shell.py.
  • Great that you included some tests, but you could move test.py to tests/ and imo pytest is a lot better to use than unittest. The person who converted me said this: "proverb of the modern python developer: life is too short to not use pytest." ;)
  • Don't need to assign a variable here (very minor, lol).

Keep up the great work, Emre! People should definitely be able to make some useful tools for Drugwars using this.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Ayyyeee a fellow Tribal Wars player!!!

A steem bases tribal wars would be awsome!

I loved tribal wars! I was actually thinking about doing something similar on the chain once I have more time/if I could find someone to help with front-end design

Was addicted to tribal wars :)

Thank you for your review, @amosbastian! Keep up the good work!

Sending custom_json is much easier using beem:

from beem import Steem
s = Steem()
s.wallet.unlock("my_wallet_password")
account = "holger80"
json_data =  {"username": account,"amount": "100"}
s.custom_json('dw-heist', json_data, required_posting_auths=[account])

You mean compared to steem-python? Because this one line in heisenberg :)

yes, compared to steem-python.

good work nigga, now next u gotta plug this into GRAND THEFT AUTO 5 MODDING COMMUNITY AHHHHHHHHHHHHHHHHHHHH

Imagine GTA5 Heists with REAL steem, it coudl be as easy as hiding private keys in the game or as complex as logging in with steemconnect to play the game with active keys and buying real weapons that deal real damage recorded on the chain, with real steem in the game that you can win like in drug wars, but GTA5 so you can REALLy play the fuycking game HOORAH im getting hard just THINKING about it

Hi @emrebeyler!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

This is good python lesson! ;)
Maybe I can become a coder again... after 25+ years after learning basic :D

lol no worries bro , if you would like to start coding so start with python it's easy language and it's easy to read too , i started learning it week ago , and finished the basics plus would like to learn more to make something for steem blockchain :)

thank you for this inspiration :)
maybe i'll follow your advice, because making something for steem sounds really great! and the feeling is probably even greater, knowing how it is to acomplish something... let me share my humble retro experience: http://trayan.info/category/digital/8bit/programming/

ohhh old days hehe :)

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.

Interesting Post, thank you.
Breaking Bad is the best series in my opinion.
It's highly addictive :)
I'm looking forward to the movie they're about to produce.

did you even read the post? lol

Thank's for this info! I'll try to use this :) Wish me luck!

Hey, @emrebeyler!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Interesting! I resteemed this article for Japanese Steemian. I am Japanese Steemian.

Posted using Partiko iOS

Coin Marketplace

STEEM 0.23
TRX 0.25
JST 0.038
BTC 95317.76
ETH 3302.38
USDT 1.00
SBD 3.31