我一直在开发一款基于恐怖短信的假牙游戏,但我遇到了一些库存问题。库存是我可以在任何函数中调用的数组。我有点到了那里,但我只是每次都用新的库存重新填充我的阵列。我可以使用一些帮助,这些是我的库存功能:
#Populating an aray with items to be used throughout the game.
def createItems():
items = range(0, 11)
if items[9] != "full":
items[1] = ("Axe")
items[2] = ("Gas")
items[3] = ("keys")
items[4] = ("gun")
items[5] = ("note")
items[9] = ("full")
return items
else:
return items
# this function is going to check if the item passed to it is still in the array
def checkItems(item):
list = createItems()
itemC = item
for i in range (0, 11):
if list[i] == itemC:
return ("no")
break
def createInventory():
inv = range(0 , 11)
inv[10] = ("made")
if inv[10] != ("made"):
for i in range (0, 11):
inv[i] = 0
return inv
def stockInventory(item):
inv = createInventory()
for i in range (0, 11):
if inv[i] == 0:
inv[i] = item
break
return inv
def checkInventory(item):
itemC = item
inv = createInventory()
for i in range(0, 11):
if itemC == inv[i]:
return ("yes")