Created
May 31, 2018 14:30
-
-
Save derozic/4baa71bf243c96f61adc6a60707f7477 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```# | |
# Card rarities | |
# - Epic = 5 | |
# - Legendary = 4 | |
# - Rare = 3 | |
# - Uncommon = 2 | |
# - Common = 1 | |
# | |
# Functions: | |
# | |
# create_card(name: int128, set: int128, rarity: int128) | |
# - Creates a card at given rarity, it becomes available for batch creation | |
# - Only genesis_men can create cards | |
# | |
# generate_booster_packs | |
# - Creates a batch of booster packs of given set name | |
# | |
# buy_booster_pack | |
# | |
owner: public(address) | |
# Only genesis_men can create_cards | |
#MAX_GENESIS_MEN = num(5) | |
genesis_men: public(address[5]) | |
cards: public({ | |
set_hash: bytes32, | |
rarity: int128, | |
}[bytes32]) | |
@public | |
def __init__(): | |
self.owner = msg.sender | |
self.genesis_men[0] = self.owner | |
@public | |
def set_genesis_man(_address: address, _index: int128): | |
assert self.owner == msg.sender | |
assert _index > 0 and _index < 5 | |
self.genesis_men[_index] = _address | |
@public | |
def create_card(_set_hash: bytes32, _card_hash: bytes32, _rarity: int128): | |
# Only genesis_men can create cards | |
assert msg.sender in self.genesis_men | |
# Card shouldn't exist yet | |
#assert _hash not in self.cards.keys() # does not work yet.... | |
self.cards[_card_hash] = {set_hash: _set_hash, rarity: _rarity}``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment