0
I’m trying to create an RPG plug simulator, but I’m having trouble properly displaying the labels. Creation runs through the function criaPersonagem()
creating an object in dictionary format (at least I tried to create it like this). Then when I call the object in a function print
only the values and not the labels appear, I am wrong in the own print
or within the function criaPersonagem()
?
personagens = ["",]
class personagem:
def __init__(self,name,genre,race,level,power,damage,health,healthRate,insanity,corruption,strength,agility, intellect, will,perception,defense,size,movement):
self.name = name
self.genre = genre
self.race = race
self.level = level
self.power = power
self.damage = damage
self.health = health
self.healthRate = healthRate
self.insanity = insanity
self.corruption = corruption
self.strength = strength
self.agility = agility
self.intellect = intellect
self.will = will
self.perception = perception
self.defense = defense
self.size = size
self.movement = movement
def exibePersonagem(self):
print(self.name,self.genre,self.race,self.level,self.power,self.damage,self.health,self.healthRate,self.insanity,self.corruption,self.strength,self.agility, self.intellect, self.will,self.perception,self.defense,self.size,self.movement)
def criaPersonagem():
global personagens
perso = {}
perso["name"] = input("Qual o nome do personagem?")
perso["genre"] = input("Qual o genero do personagem?")
perso["race"] = input("Qual a raça do personagem?")
perso["level"] = 0
perso["power"] = 0
perso["damage"] = 0
perso["insanity"] = 0
perso["corruption"] = 0
if perso["race"] == "humano":
perso["strength"] = 10
perso["agility"] = 10
perso["intellect"] = 10
perso["will"] = 10
perso["perception"] = perso["intellect"]
perso["defense"] = perso["agility"]
perso["health"] = perso["strength"]
perso["healthRate"] = perso["health"]/4
perso["size"] = 1
perso["movement"] = 10
values = personagem(perso["name"], perso["genre"], perso["race"], perso["level"],perso["power"],perso["damage"],perso["health"],perso["healthRate"],perso["insanity"],perso["corruption"],perso["strength"],perso["agility"], perso["intellect"], perso["will"],perso["perception"],perso["defense"],perso["size"],perso["movement"])
personagens.append(values)
criaPersonagem()
print(personagens[1].exibePersonagem())
What would be the "labels" you quote?
– Woss
The keys to the dictionary.
– pydoni