本文整理汇总了Python中UI.xInput方法的典型用法代码示例。如果您正苦于以下问题:Python UI.xInput方法的具体用法?Python UI.xInput怎么用?Python UI.xInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI
的用法示例。
在下文中一共展示了UI.xInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: import UI [as 别名]
# 或者: from UI import xInput [as 别名]
def save():
"""Saves user character progress, returns 0 on success, -1 on failure"""
global Player
FileName = UI.xInput("Enter filename to save to (default: player.dat): ", "player.dat")
FileName = "".join(("saves/", FileName))
try:
if os.path.exists(FileName):
if input("Warning! File already exists. Type \'yes\' if you want to continue: ") != "yes":
return 0
Out = open(FileName, "wb")
pickle.dump(Player, Out)
Out.close()
except Exception:
print ("Error: " + sys.exc_info()[0])
UI.waitForKey()
return -1
print("Complete")
UI.waitForKey()
return 0
示例2: load
# 需要导入模块: import UI [as 别名]
# 或者: from UI import xInput [as 别名]
def load():
global Player
global Arena
FileName = UI.xInput("Enter filename to load from (default: player.dat): ", "player.dat")
FileName = "".join(("saves/", FileName))
try:
if not os.path.exists(FileName):
print("File doesn't exist!")
UI.waitForKey()
return -1
Out = open(FileName, "rb")
Player = pickle.load(Out)
Out.close()
# Resolve player's items to pointers
# TODO: Use ID's to do it, save IDs to file
for InvItem in Player.Inventory:
for MasterItem in Item.ItemList:
if InvItem.Base.Name == MasterItem.Name:
InvItem.Base = MasterItem
for InvItem in Player.Inventory:
if not InvItem.Equipped: break
Player.Equipment[InvItem.Base.Type] = InvItem
Arena.Opponent1 = Player
except Exception:
print ("Error: " + sys.exc_info()[0])
UI.waitForKey()
return -1
print("Complete")
UI.waitForKey()
return 0