此任务是从游戏角色中确定力量和技能这两个属性之间的区别。其过程是:
这必须重复,直到强度属性等于或低于0,然而,这一部分我不能做,我知道如何循环,但这总是通过询问用户是否愿意继续。在
c1sc=random.randint(1,6)
c2sc=random.randint(1,6)
if c1sc > c2sc:
c1st=c1st+strengthmodifier
c2st=c2st-strengthmodifier
c1sk=c1sk+skillmodifier
c2sk=c2sk-skillmodifier
print('Character 1, your strength attribute is: '+(str(c1st))+' and your skill attribute is: '+(str(c1sk)))
print('Character 2, your strength attribute is: '+(str(c2st))+' and your skill attribute is: '+(str(c2sk)))
elif c2sc > c1sc:
c1st=c1st-strengthmodifier
c2st=c2st+strengthmodifier
c1sk=c1sk-skillmodifier
c2sk=c2sk+skillmodifier
print('Character 1, your strength attribute is: '+(str(c1st))+' and your skill attribute is: '+(str(c1sk)))
print('Character 2, your strength attribute is: '+(str(c2st))+' and your skill attribute is: '+(str(c2sk)))
else:
print('It\'s a draw, no changes were made.')
if c1sk < 0:
c1sk=0
elif c2sk < 0:
c2sk=0
if c1st < 0:
print('Character 1 died. Game over.')
elif c2st < 0:
print('Character 2 died. Game over.')
请帮忙!在
只是为了让你了解情况:(用伪代码)
不确定这是否是你要找的。如果c2sk和c1sk每次都被随机地重新分配,它应该在循环中。在
让我向您介绍
while
循环。当您希望在指定的条件为true或false时发生某些事情时,可以使用此选项。在我简短地编辑了你的代码。在
随机导入
我给了玩家1和2的初始值打赌这些可以根据你的喜好改变。为了四舍五入,我创建了另一个变量,并将强度改为整数。在
添加另一个循环来进行缩减。。。在
当然,还有更简洁的写作方式。这仍然是不理想的,但减少了代码。。。在
^{pr2}$最后,假设每一轮都要重放。。。在
相关问题 更多 >
编程相关推荐