as you know I'm making a text adventure using Python. Should I put the monster's stats into a class or dictionary?
Please suggest. All suggestions welcome!

Recommended Answers

All 3 Replies

Put them into a class. Then you can store them all in a list if you like.
Sample class

class Monster:
    def __init__(self):
        #Store the unit attributes
        self.hp = 25
        self.type = 'bird'
        self.attackDmg = 15
        self.defence = .5

    def attcker(self,unitBeingAttacked)
        dmgDone = self.attackDmg*unitBeingAttacked.defense

I know how to make classes. I'm just asking for your suggestion. I think you should use this instead if using classes

class monster():
    def __init__(self, hp, type, attackDmg, defence):
        self.hp = hp
        self.type = type
        self.attackDmg = attackDmg
        self.defence = defence
    def attacker(self, unitBeingAttacked):
        dmgDone = self.attackDmg*unitBeingAttacked.defense

birdMon = monster(25, 'bird', 15, .5)
etcMon = monster(123,'etc',123,.1)

thanks anyway

I know how to make classes. I'm just asking for your suggestion. I think you should use this instead if using classes

class monster():
    def __init__(self, hp, type, attackDmg, defence):
        self.hp = hp
        self.type = type
        self.attackDmg = attackDmg
        self.defence = defence
    def attacker(self, unitBeingAttacked):
        dmgDone = self.attackDmg*unitBeingAttacked.defense

birdMon = monster(25, 'bird', 15, .5)
etcMon = monster(123,'etc',123,.1)

thanks anyway

It really depends on what you want.
for something as simple as a monster, with HP, a name, and some stats, anything would work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.