코드는 사용자가 입력 한 직후 yes_or_no 함수 내에서 멈추게됩니다. 오류 메시지가 없습니다. 제발 도와주세요! 당신이 볼 수 있듯이 간단한 구매를 실현하는 것입니다. buy_something 함수를 테스트 할 수 없었고 문제가있을 수 있음을 알고 있습니다.Python에서 RPG 만들기
print "Shopkeeper: So, you interested in anything?"
당신이 yes를 입력 후 바로 다음이 answer1 = raw_input()
와 원시 입력을 기다리거나 아니, 당신은 item = raw_input()
다시 입력을 기다립니다 어떻게됩니까
#!/usr/bin/env python
import time
# Intro
print "Input Name:"
time.sleep(1)
name = raw_input()
print "Welcome to Tittyland brave %s'" %(name)
time.sleep(2)
print "You are given nothing but 500 gold to start you journey..."
time.sleep(2)
print "Good luck..."
time.sleep(3)
print "Shopkeeper: 'Eh there stranger! Looks like you'll need some gear before going into the wild! Check out my store!'"
time.sleep(4)
print ""
#Inventory and first shop
inventory = {
'pocket' : [],
'backpack' : [],
'gold' : 500,
}
shop = {
'dagger' : 50,
'leather armor' : 150,
'broadsword' : 200,
'health potion' : 75,
}
#Buying items
for key in shop:
print key
print "price: %s" % shop[key]
print ""
print "Shopkeeper: So, you interested in anything?"
answer1 = raw_input()
item = raw_input()
def buying_something(x):
for i in shop:
if shop[i] == x:
inventory[gold] -= shop[i]
inventory[backpack].append(shop[i])
def yes_or_no(x):
if x == 'yes':
print "Shopkeeper: 'Great! So what is your desire stranger"
buying_something(item)
else:
print "Shopkeeper: 'Another time then'"
yes_or_no(answer1)
"Tittyland에 오신 것을 환영합니다." 어쨌든 두 줄의 입력을 연속해서 읽는 것입니다. 그것은 붙어 있지 않고 두 번째 줄을 기다립니다. – JJJ
일반적으로 재생기는 문제를 설명하는 데 필요한 최소한의 코드로만 구성되어야합니다. 이 경우, 그것은 당신의 전체 프로그램보다는 두 줄과 같을 것입니다. 말하자면, 그것이 붙어있는 곳 일뿐입니다. 자세한 지침은 http://stackoverflow.com/help/mcve를 참조하십시오. –