나는 공포 텍스트 기반의 아젠타 게임에 종사하고있다 & 나는 재고 문제가있다. 인벤토리는 모든 함수에서 호출 할 수있는 배열입니다. 나는 종류가 있지만 매번 새로운 배열로 배열을 다시 채우고 있습니다. 내가 도움을 사용할 수 있습니다, 이러한 내 인벤토리 기능은 다음과 같습니다텍스트 기반 어드벤처 게임 인벤토리 문제 파이썬
#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")
코드를 올바르게 들여 씁니다. 따르기가 어렵습니다. –
@DanielRoseman – Blank1268
이 코드에 4 ~ 5 가지의 근본적인 오해가 있기 때문에 대답하기가 어려울 것입니다. http://docs.python.org/2/tutorial/의 섹션 1 ~ 5를 살펴본 다음이 섹션으로 돌아가시기 바랍니다. – YXD