【发布时间】:2013-03-12 01:02:08
【问题描述】:
我正在为游戏 Heroscape 做一个掷骰子(这样我们就可以和离岸的朋友一起玩了)。 heroscape 的骰子有 6 个面。 3 面显示头骨,1 面有符号,2 面有盾牌。
我让它随机生成其中 1 个边,但我希望它在最后列出结果(即,你滚动了 6 个头骨、2 个符号和 4 个盾牌)。
这是我当前的代码:
loop = 1
while loop == 1:
diceChoose = raw_input('Pick your dice. (Press 1 for a D20 roll, and 2 for attack /defense dice.) ')
if diceChoose == ('1'):
import random
for x in range(1):
print random.randint(1,21),
print
raw_input("YOUR DICE ROLL(S) HAVE COMPLETED. PRESS ANY KEY TO CONTINUE.")
elif diceChoose == ('2'):
diceNo = int(raw_input('How many dice do you need? '))
testvar = 0
diceRoll = ['skull', 'skull', 'skull', 'symbol', 'shield', 'shield']
from random import choice
while testvar != diceNo:
print choice(diceRoll)
testvar = testvar + 1
if testvar == diceNo:
print ('YOUR DICE ROLLS HAVE COMPLETED')
raw_input("PRESS ANY KEY TO CONTINUE.")
else: loop = raw_input('Type 1 or 2. Nothing else will work. Press 1 to start the program again.')
我尝试的是一堆 if 语句,但我意识到,如果我尝试 print ('diceRoll'),我得到的只是整个数组,而不是随机选择的骰子。
我不确定如何在每个 diceRoll 发生时保存它,因此我可以稍后打印该数字。
(我的想法是这样的
if diceRoll == 'skull' skullNo +1
print('skullNo'))
【问题讨论】:
-
您好 - 欢迎来到 SO。如果Blckknght's Answer 或mine 对您有所帮助,请点击我们名称旁边的绿色复选标记。这将意味着很多,并将帮助网站的其他成员快速找到最有效的答案。
标签: python python-2.7