所以我正在开发一款基于文本的游戏,我有一家商店可以出售矿石。我有一个 if 语句检查您要出售的矿石数量是否大于您拥有的数量。无论我输入什么数字,它都表示我没有足够的数字。
copore = 100 #testing
op = raw_input(p)
if op.lower() == "copper":
print"""
You have %r copper ore.
How much would you like to sell?
""" % copore
op = raw_input(p)
if op.lower() > copore:
print"""
You do not have that much copper ore.
You have %r copper ore.
""" % copore
menu()
elif op.lower() <= copore:
copore = copore - op
gold = gold + (op * 2)
print"""
You sell your copper ore for 2 gold each.
You now have %r copper ore.
and %r gold.
""" % (copore, gold)
menu()
else:
print"""
That is not a valid number
"""
menu()
这很可能是我自己的愚蠢,但我认为让别人看它不会有什么坏处。谢谢你。