-1
我想從我的用戶得到的輸入分配一個'陣營',並根據以下輸入修改curAdvRep \ curCrmRep的值。從函數int可變增量
輸入信息顯示出我獲得所需結果的功能,但我需要能夠永久修改派系的代表。
從文件2調用文件1:
curAdvRep = 0
curCrmRep = 0
Crimson = "Crimson Brootherhood reputation: {0}".format(curCrmRep)
Advent = "Advent of Chaos reputation: {0}".format(curAdvRep)
PathSelDict = {'Advent' : Advent, 'Crimson' : Crimson, 'n' : n, 'c' : cont, 'd' : d, 'p' : p, 'l' : l}
def Faction (rep):
global curAdvRep
global curCrmRep
global Advent
global Crimson
if rep in PathSelDict:
if rep == 'Advent':
curAdvRep += 50
curCrmRep -= 5
Advent = "Advent of Chaos reputation: {0}".format(curAdvRep)
print(Advent)
#print(Factions[JoinWorld])
elif rep == 'Crimson':
curAdvRep -= 5
curCrmRep += 50
print(PathSelDict[JoinWorld])
else:
print(Dismiss)
sys.exit(0)
從文件1:
rep = input("Which side are you on? Advent or Crimson? ").title()
questfunc.Faction(rep)
print(Advent)
print(curAdvRep)
print(curCrmRep)
輸出:
Pick up the box or leave it alone? (p or l): p
Pick up the box
Reputation Gain
Advent of Chaos reputation: 5
Which side are you on? Advent or Crimson? advent
Advent of Chaos reputation: 55
Advent of Chaos reputation: 0
0
0
我很抱歉,如果任我的問題還是我的代碼進攻。我已經爲我的問題研究了一個答案,但是由於沒有找到匹配的答案或者我無法將間接答案翻譯成我的具體問題,我還沒有找到解決方案。
而不是簡單地降評級,請告訴我什麼即時做錯了...... 我想有我主程序從我的職能分開。 Main =文件1,函數= File2。 Main將收集並存儲來自用戶的輸入並調用函數來傳遞變量。 基於用戶輸入,我需要修改來自函數的變量,並讓它在文件1和文件2中隨後調用該變量時使用。 請幫我理解。 – DaNNuN 2015-04-02 20:23:03