0
Good guys are... I am currently working on a project, where in one of the functions the script has to write a certain code that was generated from parameters chosen by the user, but after generating such code and adding it to the target file, I’ve noticed there’s always some error in the identation. To make the same work I have to go to the editor and re-tabulate all the lines, even if the tab is correct, I already tried to change the editor and even use the python itself, but the same error returns.
Follow code to generate:
def criarHabilidade(self, nome, classe, valorMinimoParaAcertar, danoMinimo, danoMaximo):
habilidadesCriadas[nome] = classe
habilidade = '''
def {0}(self, dado, alvo = "sem", estadoDoJogador = "normal"):
dano = 0
if estadoDoJogador == "normal":
if dano >= {1}:
dano = random.randint({2}, {3})
else:
dano = 0
return "Errou"
if alvo != "sem":
resultado = alvo.levarDano(dano)
if resultado == "Morreu":
return alvo.nome+": Morre!"
else:
return alvo.nome+": -"+str(dano)+" vida. Vida atual: "+str(alvo.vida)
else:
return dano
else:
return "Impossivel atacar! Jogador morto ou sob efeito de algo..."
'''.format(nome, valorMinimoParaAcertar, danoMinimo, danoMaximo)
Follows the resulting code:
#Habilidades criadas 007689
def oi(self, dado, alvo = "sem", estadoDoJogador = "normal"):
dano = 0
if estadoDoJogador == "normal":
if dano >= 1:
dano = random.randint(1, 1)
else:
dano = 0
return "Errou"
if alvo != "sem":
resultado = alvo.levarDano(dano)
if resultado == "Morreu":
return alvo.nome+": Morre!"
else:
return alvo.nome+": -"+str(dano)+" vida. Vida atual: "+str(alvo.vida)
else:
return dano
else:
return "Impossivel atacar! Jogador morto ou sob efeito de algo..."
NOTE: I am using object orientation, and according to the editors the code is correct, however I always have to perform the procedure I have already commented.
Thanks!! As soon as you get home I’ll be there!
– KiritoBR Kazuto