create account

steemmonsters, a new command line tool for battling opponents with your cards by holger80

View this thread on: hive.blogpeakd.comecency.com
· @holger80 · (edited)
$98.55
steemmonsters, a new command line tool for battling opponents with your cards
#### Repository
https://github.com/holgern/steemmonsters

### steemmonsters - a new command line tool for python

Steem monsters is a fully decentralized trading card game on the steem blockchain. This new toolbox can be used to play ranked matches and to stream currently played matches.


## Installation
```
pip install steemmonsters
```
Copy https://github.com/holgern/steemmonsters/blob/master/config.json to a directory and adapt it. Start `steemmonsters` in the directory with the `config.json`.

### Windows user
clone the github
```
git clone https://github.com/holgern/steemmonsters.git
```

## Commands
The steem monsters shell can be started with
```
steemmonsters
```
`config.json` must be available in the current directory of the terminal.

When cloned the github instead of using pip (e.g. on windows with the anaconda terminal):
```
python steemmonsters.py
```


### Available commands inside the tool

```
sm> stream
```
![image.png](https://ipfs.busy.org/ipfs/QmTUKeF2hLXKyC4CaggkFp6GwGBaDcFjn8zTPxiBJKRqJN)

This command shows the current battles and which player are participating

```
sm> play deck_name
```

`deck_name` is one of the stored decks defined in `config.json`. E.g. `death1`:
![image.png](https://ipfs.busy.org/ipfs/QmbQrtwL2aohc2YQTgxGsXYU4WkcqWm7krcW8FQiMRjg29)


```
sm> play random 
```
selects randomly a deck.

```
sm> show_deck deck_name 
```
shows deck `deck_name`.
![image.png](https://ipfs.busy.org/ipfs/QmbQRkUHGCHgxShzCzmyTkTsfPT8mooEcaPyjq9oQ337A3)


## Setup the beem wallet
Create a new wallet, when not already done.
```
beempy createwallet
```
Add the posting key of the player by:
```
beempy addkey
```


## Configuration
A file `config.json` must  exist in the current directory with the following content:
```
{
    "wallet_password": "123",
    "account": "holger80",
    "mana_cap": 23,
    "ruleset": "Standard",
    "match_type": "Ranked",
    "decks": {
                "death1": ["Zintar Mortalis", "Haunted Spirit", "Skeleton Assassin", "Twisted Jester", "Haunted Spider", "Screaming Banshee", "Undead Priest"],
                "water1": ["Alric Stormbringer", "Naga Warrior", "Medusa", "Mischievous Mermaid", "Pirate Captain", "Crustacean King"],
                "fire1": ["Malric Inferno", "Serpentine Soldier", "Elemental Phoenix", "Goblin Shaman", "Fire Demon"],
    },
    "play_counter": 1
}
```

* `wallet_password` is the `beempy` wallet password
* `account`: steem user name of the player
* `mana_cap`: current mana cap
* `ruleset`: current rule set
* `match_type`: match type
* `decks` contains the different pre defined decks. There is no mana_cap check
* `play_counter` diffens how often a deck is played

## How does it work
The package uses beem for broadcasting the necessary custom_json and finding the transation id.
### Play a match
At first a deck is build from the `config.json`. Therefore, all cards of the player are fetched by 
the `get_collection` function from the Api class. The card names are than matched and the card uid is selected. It is always the card with the highest level selected.

In the next step, a secret is created:
```
''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
```
and the team hash is calculated:
```
    m = hashlib.md5()
    m.update((summoner+',' + ','.join(monsters)+ ','+secret).encode("utf-8"))
    team_hash = m.hexdigest()
```
The first custom_json with id `sm_find_match` can then be broadcasted:
```
json_data = {"match_type":match_type, "mana_cap":mana_cap,"team_hash":team_hash,"summoner_level":summoner_level,"ruleset":ruleset}
trx = self.stm.custom_json('sm_find_match', json_data, required_posting_auths=[acc["name"]])
```
All custom_json are now streamed until a custom_json with the correct team_hash is found:
```
for h in self.b.stream(opNames=["custom_json"]):
     if h["id"] == 'sm_find_match':
         if json.loads(h['json'])["team_hash"] == team_hash:
             found = True
             break
```
The `trx_id` is then stored into the `deck` dict:
```
deck["trx_id"] =  h['trx_id']
```
It is now checked that a opponent wants to play with the `get_from_block` function from the steemmonsters api.

When at least one player also searches for a match, the second custom_json is send
```
json_data = deck
trx = self.stm.custom_json('sm_team_reveal', json_data, required_posting_auths=[acc["name"]])
```
Now the battle result is checked:
```
response = requests.get("https://steemmonsters.com/transactions/lookup?trx_id=%s" % deck["trx_id"])
```
and printed.
### Roadmap
* Improved config file handling
* Show more details about the battle
* Fetch currently played decks and allow using them for the next battle

#### How to contribute
Please create issues in https://github.com/holgern/steemmonsters when something does no work or for a feature wish or improvement. Pull requests are welcome.

You can contact me also in discord holger80 [Witness]#3688


#### GitHub Account
https://github.com/holgern/
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 98 others
properties (23)
authorholger80
permlinksteemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks
categoryutopian-io
json_metadata"{"community": "busy", "app": "beempy/0.23.10", "format": "markdown", "tags": ["utopian-io", "development", "steemmonsters", "python", "busy"], "links": ["https://github.com/holgern/steemmonsters", "https://github.com/holgern/steemmonsters/blob/master/config.json", "https://github.com/holgern/"], "image": ["https://ipfs.busy.org/ipfs/QmTUKeF2hLXKyC4CaggkFp6GwGBaDcFjn8zTPxiBJKRqJN", "https://ipfs.busy.org/ipfs/QmbQrtwL2aohc2YQTgxGsXYU4WkcqWm7krcW8FQiMRjg29", "https://ipfs.busy.org/ipfs/QmbQRkUHGCHgxShzCzmyTkTsfPT8mooEcaPyjq9oQ337A3"], "canonical_url": "https://hive.blog/utopian-io/@holger80/steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks"}"
created2018-10-19 22:02:27
last_update2020-05-23 14:46:30
depth0
children11
last_payout2018-10-26 22:02:27
cashout_time1969-12-31 23:59:59
total_payout_value75.158 HBD
curator_payout_value23.389 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,976
author_reputation358,857,509,568,825
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,647,280
net_rshares82,585,368,685,416
author_curate_reward""
vote details (162)
@emrebeyler ·
$9.50
That looks great Holger.

A couple of notes:

- Why don't you follow PEP8? Long lines of source codes really hurts readability. :) I suggest using [flake8](http://flake8.pycqa.org/en/latest/), and adding it as a git commit hook. (locally)

- You already know the questionnaire as a long time Utopian contributor, but I had to score low on the "commit messages" evaluation.

***
Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/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](https://review.utopian.io/result/3/2212232).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , ,
properties (23)
authoremrebeyler
permlinkre-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181020t190218197z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["http://flake8.pycqa.org/en/latest/","https://join.utopian.io/guidelines","https://review.utopian.io/result/3/2212232","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-10-20 19:02:18
last_update2018-10-20 19:02:18
depth1
children1
last_payout2018-10-27 19:02:18
cashout_time1969-12-31 23:59:59
total_payout_value7.184 HBD
curator_payout_value2.316 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length867
author_reputation448,528,959,341,273
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,705,223
net_rshares8,016,135,118,995
author_curate_reward""
vote details (13)
@utopian-io ·
Thank you for your review, @emrebeyler!

So far this week you've reviewed 3 contributions. Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181020t190218197z-20181024t103522z
categoryutopian-io
json_metadata"{"app": "beem/0.20.1"}"
created2018-10-24 10:35:24
last_update2018-10-24 10:35:24
depth2
children0
last_payout2018-10-31 10:35:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length113
author_reputation152,955,367,999,756
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,950,929
net_rshares0
@geekpowered ·
This is awesome! I already installed it but I guess I'll wait until the morning to try playing it, since I need to create that json file.
properties (22)
authorgeekpowered
permlinkre-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181020t061101092z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-10-20 06:11:00
last_update2018-10-20 06:11:00
depth1
children0
last_payout2018-10-27 06:11:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length137
author_reputation99,319,261,112,097
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,666,943
net_rshares0
@jarvie ·
very cool to see some other applications playing with the steemmonsters API and protocols!
πŸ‘  
properties (23)
authorjarvie
permlinkre-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181019t221724173z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"steempeak","app":"steempeak"}
created2018-10-19 22:17:27
last_update2018-10-19 22:17:27
depth1
children0
last_payout2018-10-26 22:17:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length90
author_reputation388,481,133,440,824
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,647,942
net_rshares12,671,116,086
author_curate_reward""
vote details (1)
@masterthematrix ·
Great insight into your work with Steemmonsters code. Looking forward to more statistics from you. Keep up the good work!

Posted using [Partiko Android](https://steemit.com/@partiko-android)
properties (22)
authormasterthematrix
permlinkmasterthematrix-re-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181019t224113967z
categoryutopian-io
json_metadata{"app":"partiko"}
created2018-10-19 22:41:15
last_update2018-10-19 22:41:15
depth1
children0
last_payout2018-10-26 22:41:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length191
author_reputation9,868,666,626,842
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,648,953
net_rshares0
@oliverschmid ·
No Al? I'm disappointed.
*Kidding*. **This is great!**
properties (22)
authoroliverschmid
permlinkre-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181020t052444556z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-10-20 05:24:45
last_update2018-10-20 05:24:45
depth1
children1
last_payout2018-10-27 05:24:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length54
author_reputation108,456,372,075,578
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,664,844
net_rshares0
@schlafhacking ·
$0.04
code an AI if you need one :D
πŸ‘  
properties (23)
authorschlafhacking
permlinkre-oliverschmid-re-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181020t080318670z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-10-20 08:03:15
last_update2018-10-20 08:03:15
depth2
children0
last_payout2018-10-27 08:03:15
cashout_time1969-12-31 23:59:59
total_payout_value0.029 HBD
curator_payout_value0.009 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length29
author_reputation15,067,517,752,330
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,671,611
net_rshares32,660,086,389
author_curate_reward""
vote details (1)
@steem-ua ·
#### Hi @holger80!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your **UA** account score is currently 7.011 which ranks you at **#84** across all Steem accounts.
Your rank has not changed in the last three days.

In our last Algorithmic Curation Round, consisting of 225 contributions, your post is ranked at **#6**.
##### Evaluation of your UA score:

* Your follower network is great!
* The readers appreciate your great work!
* Good user engagement!


**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181020t173727z
categoryutopian-io
json_metadata"{"app": "beem/0.20.7"}"
created2018-10-20 17:37:30
last_update2018-10-20 17:37:30
depth1
children0
last_payout2018-10-27 17:37:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length595
author_reputation23,214,230,978,060
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,700,335
net_rshares0
@steemitboard ·
Congratulations @holger80! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png)](http://steemitboard.com/@holger80) Award for the number of upvotes received

<sub>_Click on the badge to view your Board of Honor._</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Do not miss the last post from @steemitboard:**
<table><tr><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-ranking-update-resteem-and-resteemed-added"><img src="https://steemitimages.com/64x128/https://cdn.steemitimages.com/DQmfRVpHQhLDhnjDtqck8GPv9NPvNKPfMsDaAFDE1D9Er2Z/header_ranking.png"></a></td><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-ranking-update-resteem-and-resteemed-added">SteemitBoard Ranking update - Resteem and Resteemed added</a></td></tr></table>

> Support [SteemitBoard's project](https://steemit.com/@steemitboard)! **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-holger80-20181021t110401000z
categoryutopian-io
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-10-21 11:04:00
last_update2018-10-21 11:04:00
depth1
children0
last_payout2018-10-28 11:04:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,209
author_reputation38,975,615,169,260
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,742,812
net_rshares0
@travoved ·
Hmm it looks interesting I want to check it!

Posted using [Partiko Android](https://steemit.com/@partiko-android)
properties (22)
authortravoved
permlinktravoved-re-holger80-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181020t034155326z
categoryutopian-io
json_metadata{"app":"partiko"}
created2018-10-20 03:42:00
last_update2018-10-20 03:42:00
depth1
children0
last_payout2018-10-27 03:42:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length114
author_reputation48,422,674,105,375
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,660,804
net_rshares0
@utopian-io ·
Hey, @holger80!

**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](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

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

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-steemmonsters-a-new-command-line-tool-for-battling-opponents-with-your-decks-20181026t090512z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-10-26 09:05:15
last_update2018-10-26 09:05:15
depth1
children0
last_payout2018-11-02 09:05:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length590
author_reputation152,955,367,999,756
root_title"steemmonsters, a new command line tool for battling opponents with your cards"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,080,924
net_rshares0