【发布时间】:2013-11-15 09:57:57
【问题描述】:
此任务是确定游戏角色的力量和技能两个属性之间的差异。这个过程是:
- 确定强度属性之间的差异。
- 差值除以 5 并向下舍入以创建“强度修正值”。
- 对技能属性执行相同的过程并命名为“技能修饰符”。
- 然后游戏开始:
- 两名玩家都投掷六面骰子。
- 如果值相同,则不会发生任何变化。
- 如果数值不同,则数值最高的玩家将获得先前计算的力量和技能,然后将其添加到他们的总和中。数值最低的玩家的力量和技能会从他们的总和中扣除。
这必须重复,直到强度属性等于或低于 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.')
请帮忙!
【问题讨论】:
标签: python loops random python-3.x