【发布时间】:2019-09-05 18:34:14
【问题描述】:
我正在寻找有关如何将此功能添加到我的机器人并将其打印到不和谐的一些指导。 我希望机器人能够在输入命令 /combat 时将结果打印到不和谐而不是我的终端
import random
def combat():
hp = random.randint(1, 11)
ac = random.randint(1, 7)
print('Your HP is', hp, 'and your armor is', ac)
ehp = random.randint(1, 11)
eac = random.randint(1, 7)
print("My HP is", ehp, 'and my armor is', eac)
i = 0
while not hp < 0 | ehp < 0:
"""add counter"""
i = i + 1
'''hp = random.randint(1,11)
ac = random.randint(1,7)
print(hp, ac)
ehp = random.randint(1,11)
eac = random.randint(1,7)
print(ehp, eac)'''
print('Turn',i,':')
dmg = random.randint(1,9)
tdmg = dmg - eac
if tdmg < 0:
tdmg = 0
ehp = ehp - tdmg
print(' You dealt', tdmg, 'damage to me')
print(' I am at', ehp, 'health')
edmg = random.randint(1,9)
tedmg = edmg - ac
if tedmg < 0:
tedmg = 0
hp = hp - tedmg
print(' I dealt', tedmg, 'damage to you')
print(' You are at', hp, 'health')
if ehp < 1:
print('You win')
break
elif hp < 1:
print('I win')
break
combat()
Your HP is 3 and your armor is 5
My HP is 7 and my armor is 3
Turn 1 :
You dealt 0 damage to me
I am at 7 health
I dealt 3 damage to you
You are at 0 health
I win
【问题讨论】:
-
您有基本的 Discord 机器人设置吗? (比如一个客户端和一个或多个事件监听器?)
标签: python discord discord.py