Skip to content

Commit

Permalink
Merge branch 'master' of github.com:0rtis/dfk
Browse files Browse the repository at this point in the history
merge 1eea69d with local changes
  • Loading branch information
0rtis committed Jul 17, 2022
2 parents cf50b25 + 1eea69d commit 3d2497f
Show file tree
Hide file tree
Showing 7 changed files with 451 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,9 @@ Meditation circle contract is accessible with [meditation/meditation.py](https:/
Use `start_meditation` and `complete_meditation` to level up a hero. Make sure to have enough rune for the hero's level with `get_required_runes`


### Duel
All duel contracts are located in module [duel](dfktools/duel)

#### Quickstart
[duel_example.py](dfktools/duel_example.py)

Empty file added dfktools/duel/__init__.py
Empty file.
359 changes: 359 additions & 0 deletions dfktools/duel/duel.py

Large diffs are not rendered by default.

Empty file added dfktools/duel/utils/__init__.py
Empty file.
38 changes: 38 additions & 0 deletions dfktools/duel/utils/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
type = {
'solo': 1,
'squad': 3,
'war': 9
}

background = {
'desert': 0,
'forest': 2,
'plains': 4,
'island': 6,
'swamp': 8,
'mountains': 10,
'city': 12,
'arctic': 14
}

stat = {
'strength': 0,
'agility': 2,
'intelligence': 4,
'wisdom': 6,
'luck': 8,
'vitality': 10,
'endurance': 12,
'dexterity': 14
}


def string2id(attr, label):
if attr == "type":
return type.get(label, None)
elif attr == 'background':
return background.get(label, None)
elif attr == 'stat':
return stat.get(label, None)

return None
50 changes: 50 additions & 0 deletions dfktools/duel_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import logging
import json
import sys
import duel.duel as duels
from web3 import Web3

if __name__ == "__main__":
log_format = '%(asctime)s|%(name)s|%(levelname)s: %(message)s'

logger = logging.getLogger("DFK-duel")
logger.setLevel(logging.DEBUG)
logging.basicConfig(level=logging.INFO, format=log_format, stream=sys.stdout)

rpc_server = 'https://api.harmony.one'
logger.info("Using RPC server " + rpc_server)

result = duels.get_duel(1,rpc_server)
logger.info(json.dumps(result, indent=4, sort_keys=False))


private_key = "" # set private key
account_address = "0x" # set account address
gas_price_gwei = 35
tx_timeout_seconds = 30
w3 = Web3(Web3.HTTPProvider(rpc_server))


# start ranked duel
'''
Ranked match jewel fees
Solo: 0.1, 0.5, 1
Squad: 0.3, 1.5, 3
War: 1, 5, 10
'''
duels.enter_duel_lobby('solo', [241730], 0.1, 'forest', 'dexterity',
private_key, w3.eth.getTransactionCount(account_address),
gas_price_gwei, tx_timeout_seconds, rpc_server, logger)

# start private duel
duels.start_private_duel('solo', [241730], '0x', 'forest', 'dexterity',
private_key, w3.eth.getTransactionCount(account_address),
gas_price_gwei, tx_timeout_seconds, rpc_server, logger)

# complete duel
duels.complete_duel(40331,
private_key, w3.eth.getTransactionCount(account_address),
gas_price_gwei, tx_timeout_seconds, rpc_server, logger)

# result = duels.getDuelTurns(1,rpc_server) # get duels details based on Duel ID
# result = duels.get_total_open_duel_entries(3, rpc_server) # 1-Solo,3-Squad,9-War
File renamed without changes.

0 comments on commit 3d2497f

Please sign in to comment.