What is the best way to go about making user defined classes (monsters, items, loot, armor, weapons, spell types, etc) and then calling them later during an encounter? Looking at the entire card list for a trading card game is intimidating, and I would love some advice on tackling this before I go about it the wrong way.
class Card(object):
def __init__(self, name, value, type, power):
self.name = name
self.value = value
self.type = type
self.power = power
self.expan = 'Base'
class Monster(Card):
def __init__(self, name, value, type, power):
self.active = False
Card.__init__(self, name, value, type, power)
#monsterlist.append((self.name, self.value, self.type, self.power))
Is it ideal to just make a random number and create the monster like this (there's over a thousand cards, so this doesn't seem optimal to me):
def pickMonster():
chance = random.randint(1,2)
if chance == 1:
goblin = Monster('goblin', 8, 'animal', 'run')
if chance = 2:
troll == Monster('troll', 8, 'troll', 'smash')
Can I define monsters in a list/dictionary somehow and pull them at random from there? I was trying to use this method to make the code easier to read, but I'm having a hard time figuring out exactly how to do it that way (as I'm not even sure it's possible to put more than 2 values into a list, and dictionaries are the bane of my existence -- I'm fairly new to python).
random
monstercards
akaelement
from adeck
akalist/dict
" Think logically, the deck is a containter for cards, then use a containter in you code too? Then let the random integer be the index of the element. – dragons Mar 18 '14 at 09:03