Python3在视频游戏的新行上打印用户输入字符串



Python初学者,几个月来,仍然困惑,仍然有严重的冒名顶替综合症。

我在玩一些暗黑破坏神2复活,当我玩的时候,我在我的脑海里想象代码,特别是当我在我的法师上使用法术时,像霹雳,在我目前的水平上造成1-114的伤害;)

所以我选择了alt选项卡,然后写了下面的代码:

import random
#For the random thunderbolt spell damage
thunderbolt_damage = random.randint(1,114)
#Asking for user input
mouse_clicks = int(input("How often do you want to click to use thunderbolt? "))

def thunder_spell():

mana = 120
'''Mana at my current level in Diablo2'''
while mouse_clicks > 0:
mana += mouse_clicks * -9 
break

print("You have " + str(mana) + " Mana left")



print("Your thunderbolt just did " + str(thunderbolt_damage) + " damage") 


thunder_spell()

问题:我希望能够打印我用鼠标点击的次数,每次显示随机伤害,在新的一行。我试了好几种方法,但都没用。我遇到了一些错误。我认为这可以用for循环来完成,但我不知道怎么做。我学会了使用codecademy的大部分时间。

import random

thunderbolt_damage = random.randint(1,114)
#Asking for user input
mouse_clicks = int(input("How often do you want to click to use thunderbolt? "))
mana = 120
def thunder_spell(mana):
for i in range(0, mouse_clicks):
mana -= 9
#For the random thunderbolt spell damage
thunderbolt_damage = random.randint(1,114)
print("Your thunderbolt just did " + str(thunderbolt_damage) + " damage")
return mana
print("You have " + str(thunder_spell(mana)) + " Mana left")

如果我明白你的要求,我相信这将工作

最新更新