I'm having issues (still) with generating a random object, in this case a random herb found by foraging. Here's the code for the function:
def collectPlants(self):if self.state == 'normal':print"%s spends an hour looking for medicinal plants." % self.nameif random.choice([0,1]):foundHerb = random.choice(herb_dict)print "You find some %s." % foundHerbreturn random.choice(herb_dict)else: print"%s doesn't find anything useful." % self.name
and the dict block:
herb_dict = [("Aloe Vera", Player().health == Player().health + 2),("Cannabis", Player().state == 'high'),("Ergot", Player().state == 'tripping')
]
Sorry for the clandestine examples. Herb is also a class with three parameters: (self, name, effect).
How do I generate a random herb from the dict when the collectPlants function is called?