本文整理汇总了Python中Engine.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.getInstance方法的具体用法?Python Engine.getInstance怎么用?Python Engine.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine.getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import getInstance [as 别名]
def execute(self, s):
if self.isUsable():
# perform altering commands
self.alter()
Engine.getInstance().show(self.description)
else:
Engine.getInstance().show("You can not do that")
raise Exception
示例2: isUsable
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import getInstance [as 别名]
def isUsable(self):
engine = Engine.getInstance()
# ignore execution if the location where the command can be executed is not equal
# to the name of the current scenario
if not self.requirements:
print "no requirements, automatically pass"
return True
for item in self.requirements:
if not engine.getPlayer().hasItem(item):
print "failed, did not have " + item
return False
print "pass requirements check"
return True
示例3: alter
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import getInstance [as 别名]
def alter(self):
engine = Engine.getInstance() # the engine of the game
player = engine.getPlayer() # the player
# load these up now so there isn't a recursion error earlier on
from Item import loadItem
from Scenario import getRoom
# go through the list of items to remove from the player
for item in self.alterPlayer[0]:
player.removeItem(loadItem(item))
# go through the list of items to add to the player
for item in self.alterPlayer[1]:
player.addItem(loadItem(item))
# go through the list of rooms to be altered
for room in self.alterRooms.keys():
if room is not None:
scene = getRoom(room)
else:
scene = engine.getScenario()
# remove things from the rooms
for n in self.alterRooms[room][0][0]:
scene.objects.remove(loadItem(n))
for n in self.alterRooms[room][1][0]:
scene.commands.remove(loadCommand(n))
for n in self.alterRooms[room][2][0]:
scene.paths.remove(getRoom(n))
# add things to the rooms
for n in self.alterRooms[room][0][1]:
scene.objects.append(loadItem(n))
for n in self.alterRooms[room][1][1]:
scene.commands.append(loadCommand(n))
for n in self.alterRooms[room][2][1]:
scene.paths.append(getRoom(n))
print scene.objects
print scene.commands
print scene.paths