当前位置: 首页>>代码示例>>Python>>正文


Python Engine.getInstance方法代码示例

本文整理汇总了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
开发者ID:nhydock,项目名称:TWIXIE,代码行数:10,代码来源:Command.py

示例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
开发者ID:nhydock,项目名称:TWIXIE,代码行数:16,代码来源:Command.py

示例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
开发者ID:nhydock,项目名称:TWIXIE,代码行数:43,代码来源:Command.py


注:本文中的Engine.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。