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


Python ComponentManager.dict_of方法代码示例

本文整理汇总了Python中ComponentManager.ComponentManager.dict_of方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentManager.dict_of方法的具体用法?Python ComponentManager.dict_of怎么用?Python ComponentManager.dict_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ComponentManager.ComponentManager的用法示例。


在下文中一共展示了ComponentManager.dict_of方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: take_turn

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
 def take_turn(self):
     lioncreature = CM.get_Component('Creature', self.LionId)
     lioncoord = CM.get_Component('Coord', self.LionId)
     playercoord = CM.get_Component('Coord', config.PlayerId)
     disttoplayer = get_distance(lioncoord, playercoord)
     if disttoplayer <= lioncreature.VisionRange and \
             coordfov(lioncoord, playercoord):
         if int(disttoplayer) <= 1:
             Attack_Coord(self.BasicAttackId, self.LionId,
                          playercoord)
         else:
             direction = MC.Get_Direction_To(lioncoord, playercoord)
             MC.Walk_Direction_Persistantly(self.LionId, direction)
     else:
         coord = CM.dict_of('Coord')
         tile = CM.dict_of('Tile')
         dist = (lioncreature.VisionRange, False)
         for key, coord in coord.iteritems():
             if get_distance(coord, lioncoord) <= \
                 lioncreature.VisionRange and key != self.LionId and \
                     (tile[key].TileName == 'Lion' or
                         tile[key].TileName == 'Dire Lion'):
                 newdist = get_distance(lioncoord, coord)
                 if newdist < dist:
                     dist = (newdist, coord)
         if dist[1]:
             if dist[0] < 2:
                 direction = MC.Get_Direction_To(dist[1], lioncoord)
             else:
                 direction = MC.Get_Direction_To(lioncoord, dist[1])
             MC.Walk_Direction_Persistantly(self.LionId, direction)
开发者ID:Akhier,项目名称:12Down,代码行数:33,代码来源:Lion.py

示例2: coord_to_coord_fov

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
def coord_to_coord_fov(coord, coord2):
    line = get_line((coord.X, coord.Y), (coord.X, coord.Y))
    line = line[1:-1]
    coords = CM.dict_of('Coord')
    tiles = CM.dict_of('Tile')
    for key, value in coords.iteritems():
        if value in line:
            if key in tiles:
                if not tiles.Passable:
                    return False
    return True
开发者ID:Akhier,项目名称:12Down,代码行数:13,代码来源:S_CoordtoCoordFov.py

示例3: Try_Place

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
def Try_Place(targetcoord, dungeonlevel, monster):
    if targetcoord.X > 0 and targetcoord.X < config.playscreen_width and \
            targetcoord.Y > 0 and targetcoord.Y < config.playscreen_height:
        coords = CM.dict_of('Coord')
        tiles = CM.dict_of('Tile')
        freetoplace = True
        for key, value in coords.iteritems():
            if targetcoord == value and key in tiles:
                if not tiles[key].Passable:
                    freetoplace = False
        if freetoplace:
            monster(targetcoord, dungeonlevel)
            return True
        return False
    else:
        return False
开发者ID:Akhier,项目名称:12Down,代码行数:18,代码来源:S_PlaceMonsters.py

示例4: take_turn

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
 def take_turn(self):
     elephantcreature = CM.get_Component('Creature', self.ElephantId)
     elephantcoord = CM.get_Component('Coord', self.ElephantId)
     elephanttile = CM.get_Component('Tile', self.ElephantId)
     playercoord = CM.get_Component('Coord', config.PlayerId)
     disttoplayer = hypot(elephantcoord.X - playercoord.X,
                          elephantcoord.Y - playercoord.Y)
     if disttoplayer < elephantcreature.VisionRange and \
             coordfov(elephantcoord, playercoord):
         if int(disttoplayer) <= 1:
             if not self.resting:
                 Attack_Coord(self.BasicAttackId, self.ElephantId,
                              playercoord)
                 self.resting = True
             else:
                 self.resting = False
                 Message('The ' + elephanttile.TileName +
                         ' rests this turn instead of attacking.',
                         color=Color.yellow)
         else:
             self.resting = False
             direction = MC.Get_Direction_To(elephantcoord, playercoord)
             if not MC.Walk_Direction(self.ElephantId, direction):
                 directions = MC.Get_Alt_Direction_To(direction)
                 if not MC.Walk_Direction(self.ElephantId, directions[0]):
                     MC.Walk_Direction(self.ElephantId, directions[1])
     else:
         tiles = CM.dict_of('Tile')
         elephantids = []
         for key, value in tiles.iteritems():
             if value.TileName == 'Elephant' or \
                     value.TileName == 'Pink Elephant':
                 if key != self.ElephantId:
                     elephantids.append(key)
         elephantcoords = CM.get_Components('Coord', elephantids)
         shortestdist = (False, elephantcreature.VisionRange)
         for key, coord in elephantcoords.iteritems():
             dist = hypot(
                 elephantcoord.X - coord.X, elephantcoord.Y - coord.Y)
             if dist < shortestdist[1] and dist > 1.5:
                 shortestdist = (coord, dist)
         if shortestdist[0]:
             direction = MC.Get_Direction_To(elephantcoord, shortestdist[0])
             if not MC.Walk_Direction(self.ElephantId, direction):
                 directions = MC.Get_Alt_Direction_To(direction)
                 if not MC.Walk_Direction(self.ElephantId, directions[0]):
                     MC.Walk_Direction(self.ElephantId, directions[1])
         else:
             direction = random.choice([D.N, D.S, D.E, D.W,
                                        D.NE, D.NW, D.SE, D.SW])
             MC.Walk_Direction(self.ElephantId, direction)
开发者ID:Akhier,项目名称:12Down,代码行数:53,代码来源:Elephant.py

示例5: take_turn

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
 def take_turn(self):
     goblincreature = CM.get_Component('Creature', self.GoblinId)
     goblincoord = CM.get_Component('Coord', self.GoblinId)
     playercoord = CM.get_Component('Coord', config.PlayerId)
     disttoplayer = hypot(goblincoord.X - playercoord.X,
                          goblincoord.Y - playercoord.Y)
     if disttoplayer <= goblincreature.VisionRange and \
             coordfov(goblincoord, playercoord):
             if int(disttoplayer) <= 1:
                 Attack_Coord(self.BasicAttackId, self.GoblinId,
                              playercoord)
             else:
                 direction = MC.Get_Direction_To(goblincoord, playercoord)
                 MC.Walk_Direction_Persistantly(self.GoblinId, direction)
     else:
         curnearbygoblins = []
         tiles = CM.dict_of('Tile')
         coords = CM.dict_of('Coord')
         for key, value in tiles.iteritems():
             if (value.TileName == 'Goblin' or
                     value.TileName == 'Hobgoblin') and \
                     key != self.GoblinId:
                 if get_distance(goblincoord, coords[key]) <= \
                         goblincreature.VisionRange:
                     curnearbygoblins.append(key)
         if not self.nearbygoblins:
             self.nearbygoblins = curnearbygoblins
         else:
             direction = False
             for key in curnearbygoblins:
                 if key not in self.nearbygoblins:
                     direction = MC.Get_Direction_To(
                         goblincoord, coords[key])
                     break
             if direction:
                 MC.Walk_Direction_Persistantly(self.GoblinId, direction)
开发者ID:Akhier,项目名称:12Down,代码行数:38,代码来源:Goblin.py

示例6: Walk_Direction

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
def Walk_Direction(creatureid, direction):
    cCoord = CM.get_Component('Coord', creatureid)
    newCoord = Coord(cCoord.X + direction.X, cCoord.Y + direction.Y)
    Coords = CM.dict_of('Coord')
    walkable = True
    for key, value in Coords.iteritems():
        if value == newCoord:
            if CM.check_Component('Tile', key):
                tile = CM.get_Component('Tile', key)
                if not tile.Passable:
                    walkable = False
    if walkable:
        cCoord.X = newCoord.X
        cCoord.Y = newCoord.Y
        return True
    else:
        return False
开发者ID:Akhier,项目名称:12Down,代码行数:19,代码来源:S_MoveCreature.py

示例7: Teleport_Random

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
def Teleport_Random(creatureid):
    cCoord = CM.get_Component('Coord', creatureid)
    x = randint(1, config.playscreen_width - 1)
    y = randint(1, config.playscreen_height - 1)
    newCoord = Coord(x, y)
    Coords = CM.dict_of('Coord')
    walkable = True
    for key, value in Coords.iteritems():
        if value == newCoord:
            if CM.check_Component('Tile', key):
                tile = CM.get_Component('Tile', key)
                if not tile.Passable:
                    walkable = False
    if walkable:
        cCoord.X = newCoord.X
        cCoord.Y = newCoord.Y
    else:
        Teleport_Random(creatureid)
开发者ID:Akhier,项目名称:12Down,代码行数:20,代码来源:S_MoveCreature.py

示例8: Blink_Random_Failable

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
def Blink_Random_Failable(creatureid, mindist=4, maxdist=10):
    cCoord = CM.get_Component('Coord', creatureid)
    x = randint(mindist, maxdist) * choice([-1, 1])
    y = randint(mindist, maxdist) * choice([-1, 1])
    newCoord = Coord(cCoord.X + x, cCoord.Y + y)
    while newCoord.X < 1 or newCoord.X > config.playscreen_width - 3 or \
            newCoord.Y < 1 or newCoord.Y > config.playscreen_height - 3:
        x = randint(mindist, maxdist) * choice([-1, 1])
        y = randint(mindist, maxdist) * choice([-1, 1])
        newCoord = Coord(cCoord.X + x, cCoord.Y + y)
    Coords = CM.dict_of('Coord')
    walkable = True
    for key, value in Coords.iteritems():
        if value == newCoord:
            if CM.check_Component('Tile', key):
                tile = CM.get_Component('Tile', key)
                if not tile.Passable:
                    walkable = False
    if walkable:
        cCoord.X = newCoord.X
        cCoord.Y = newCoord.Y
开发者ID:Akhier,项目名称:12Down,代码行数:23,代码来源:S_MoveCreature.py

示例9: take_turn

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
 def take_turn(self):
     dogcreature = CM.get_Component('Creature', self.DogId)
     dogcoord = CM.get_Component('Coord', self.DogId)
     playercoord = CM.get_Component('Coord', config.PlayerId)
     disttoplayer = hypot(dogcoord.X - playercoord.X,
                          dogcoord.Y - playercoord.Y)
     if disttoplayer < dogcreature.VisionRange and \
             coordfov(dogcoord, playercoord):
         if int(disttoplayer) <= 1:
             Attack_Coord(self.BasicAttackId, self.DogId, playercoord)
         else:
             direction = MC.Get_Direction_To(dogcoord, playercoord)
             if not MC.Walk_Direction(self.DogId, direction):
                 directions = MC.Get_Alt_Direction_To(direction)
                 if not MC.Walk_Direction(self.DogId, directions[0]):
                     MC.Walk_Direction(self.DogId, directions[1])
     else:
         tiles = CM.dict_of('Tile')
         dogids = []
         for key, value in tiles.iteritems():
             if value.TileName == 'Dog' or \
                     value.TileName == 'Rabid Dog':
                 if key != self.DogId:
                     dogids.append(key)
         dogcoords = CM.get_Components('Coord', dogids)
         shortestdist = (False, dogcreature.VisionRange)
         for key, coord in dogcoords.iteritems():
             dist = hypot(dogcoord.X - coord.X, dogcoord.Y - coord.Y)
             if dist < shortestdist[1] and dist > 1.5:
                 shortestdist = (coord, dist)
         if shortestdist[0]:
             direction = MC.Get_Direction_To(dogcoord, shortestdist[0])
             if not MC.Walk_Direction(self.DogId, direction):
                 directions = MC.Get_Alt_Direction_To(direction)
                 if not MC.Walk_Direction(self.DogId, directions[0]):
                     MC.Walk_Direction(self.DogId, directions[1])
         else:
             direction = random.choice([D.N, D.S, D.E, D.W,
                                        D.NE, D.NW, D.SE, D.SW])
             MC.Walk_Direction(self.DogId, direction)
开发者ID:Akhier,项目名称:12Down,代码行数:42,代码来源:Dog.py

示例10: Play_Game

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
def Play_Game():
    config.player_action = None
    config.mouse = libtcodpy.Mouse()
    config.key = libtcodpy.Key()
    while not config.gamewindow.is_window_closed:
        libtcodpy.sys_check_for_event(libtcodpy.EVENT_KEY_PRESS |
                                      libtcodpy.EVENT_MOUSE,
                                      config.key, config.mouse)
        Render()
        config.gamewindow.flush
        check_level_up()
        dungeonlevelid = config.DungeonLevelIds[config.CurrentDungeonLevel]
        dungeonlevel = CM.get_Component('DungeonLevel', dungeonlevelid)
        objectids = []
        objectids.extend(dungeonlevel.ItemIds)
        objectids.extend(dungeonlevel.FeatureIds)
        objectids.extend(dungeonlevel.MonsterIds)
        objectids.append(config.PlayerId)
        charmap = char_map(dungeonlevel.MapId)
        for objectid in objectids:
            objectcoord = CM.get_Component('Coord', objectid)
            x = objectcoord.X
            y = objectcoord.Y
            if config.visible[x][y]:
                config.playscreen.write_ex(x, y, charmap[x][y],
                                           Color.map_tile_visible)
        playercreature = CM.get_Component('Creature', config.PlayerId)
        if 'Paralyzed' in playercreature.Special:
            playercreature.Special.pop('Paralyzed', None)
            config.player_action = 'Paralyzed'
            Message('You have been paralyzed for a turn', color=Color.red)
        else:
            config.player_action = Handle_Keys()
        if config.player_action == 'exit' or \
                config.game_state == 'finished' or\
                config.game_state == 'Quit':
            if config.player_action == 'exit':
                choice = None
                while choice is None:
                    choice = Menu('Are you sure you want to Quit?',
                                  ['Yes I want to quit', 'No'], 34)
                if choice == 0:
                    End_Game()
                    break
            else:
                config.gamewindow.clear
                config.playscreen.clear
                break
        if config.game_state == 'playing' and \
                config.player_action != 'no action':
            actions = CM.dict_of('Action')
            keylist = list(actions.keys())
            creatures = CM.dict_of('Creature')
            creatures = dict(creatures)
            poison = CM.dict_of('Poison')
            if poison:
                poison = dict(poison)
                for key, value in poison.iteritems():
                    creature = CM.get_Component('Creature', key)
                    creature.CurHp -= value.Damage
                    value.TurnsLeft -= 1
                    check_death(value.SourceId, key, poison=True)
                    if value.TurnsLeft <= 0:
                        CM.remove_Component('Poison', key)
            for key in keylist:
                if key in objectids:
                    if 'Paralyzed' in creatures[key].Special:
                        creatures[key].Special.pop('Paralyzed', None)
                        tile = CM.get_Component('Tile', key)
                        Message('The ' + tile.TileName + ' is paralyzed!',
                                color=Color.sky)
                    else:
                        actions[key].take_turn()
            for key, value in creatures.iteritems():
                if 'CardinalLeap' in value.Special:
                    (need, cur, dist) = value.Special['CardinalLeap']
                    if cur < need:
                        cur += 1
                        value.Special['CardinalLeap'] = (
                            need, cur, dist)
开发者ID:Akhier,项目名称:12Down,代码行数:82,代码来源:Play_Game.py

示例11: render_statscreen

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]
def render_statscreen():
    config.statscreen.set_default_background(Color.black)
    config.statscreen.set_default_foreground(Color.white)
    config.statscreen.clear
    PC = CM.get_Component('Creature', config.PlayerId)
    PL = CM.get_Component('Level', config.PlayerId)
    PA = CM.get_Component('Attack', config.PlayerAttack)
    overflowhpcolor = Color.lighter_red
    curhpcolor = Color.light_red
    losthpcolor = Color.darker_red
    poison = CM.dict_of('Poison')
    if config.PlayerId in poison:
        overflowhpcolor = Color.lighter_green
        curhpcolor = Color.light_green
        losthpcolor = Color.darker_green
    barwidth = config.statscreen_width - 4
    if PC.CurHp < PC.MaxHp:
        render_bar(2, 2, barwidth, 'HP', PC.CurHp,
                   PC.MaxHp, curhpcolor, losthpcolor)
    else:
        render_bar(2, 2, barwidth, 'HP',
                   PC.CurHp - PC.MaxHp, PC.MaxHp, overflowhpcolor,
                   curhpcolor, overflow=True)
    bottomybar = config.statscreen_height - 2
    render_bar(2, bottomybar, barwidth, 'LV ' + str(PL.level),
               PC.Xp, int(config.xptolevel * config.xpscale),
               Color.blue, Color.darker_blue)
    bottomybar -= 2
    config.statscreen.write(2, 1, 'Name: ' + config.PlayerName)
    statlist = ['Def: ' + str(PC.Defense)]
    if 'EnhancedDefense' in PC.Special:
        statlist.append('^Df: ' + str(PC.Special['EnhancedDefense']))
    statlist.append('Str: ' + str(PC.Strength))
    statlist.append('Agi: ' + str(PC.Agility))
    statlist.append('Atk: ' + str(PA.Dice) + 'd' + str(PA.Sides))
    if 'LifeDrain' in PA.Special:
        statlist.append('LDr: ' + str(PA.Special['LifeDrain']))
    if 'Paralyze' in PA.Special:
        statlist.append('Prz: ' + str(PA.Special['Paralyze']))
    if 'PierceDefense' in PA.Special:
        statlist.append('PDf: ' + str(PA.Special['PierceDefense']))
    if 'CausePoison' in PA.Special:
        statlist.append('Psn: ' + str(PA.Special['CausePoison']))
    if 'SideSwipe' in PC.Special:
        statlist.append('Side SideSwipe')
    if 'Dodge' in PC.Special:
        statlist.append('Ddg: ' + str(PC.Special['Dodge']))
    if 'ParalyzeResistance' in PC.Special:
        statlist.append('PRs: ' + str(PC.Special['ParalyzeResistance']))
    if 'CritChance' in PC.Special:
        statlist.append('Crt: ' + str(PC.Special['CritChance']))
    if 'ReduceCrit' in PC.Special:
        statlist.append('RCr: ' + str(PC.Special['ReduceCrit']))
    if 'Fear' in PC.Special:
        statlist.append('Fer: ' + str(PC.Special['Fear']))
    if 'RandomBlink' in PC.Special:
        statlist.append('Bnk: ' + str(PC.Special['RandomBlink']))
    if 'HealthPotion' in PC.Special:
        statlist.append('Hpt: ' + str(PC.Special['HealthPotion']))
    if 'LifeSaver' in PC.Special:
        statlist.append('%$#: @')
    statnum = len(statlist) + 1
    space = config.statscreen_height - 6
    if 'CardinalLeap' in PC.Special:
        (need, cur, dist) = PC.Special['CardinalLeap']
        space -= 2
        render_bar(2, bottomybar, barwidth, 'Lp' + str(dist), cur, need,
                   Color.dark_yellow, Color.darker_yellow)
        bottomybar -= 2
    spacing = int(space / statnum)
    y = 2 + spacing
    for stat in statlist:
        config.statscreen.write(2, y, stat)
        y += spacing
开发者ID:Akhier,项目名称:12Down,代码行数:76,代码来源:Render.py

示例12: Handle_Keys

# 需要导入模块: from ComponentManager import ComponentManager [as 别名]
# 或者: from ComponentManager.ComponentManager import dict_of [as 别名]

#.........这里部分代码省略.........
            else:
                Attack_Coord(config.PlayerAttack, config.PlayerId,
                             playercoord.get_coord_from_self(Dir.W))
        elif config.key.vk == libtcodpy.KEY_RIGHT or \
                config.key.vk == libtcodpy.KEY_KP6:
            if cardinalleap:
                MC.Walk_Direction_Multiple(config.PlayerId, Dir.E, dist)
                playercreature.Special['CardinalLeap'] = (
                    neededenergy, -1, dist)
                config.fov_recompute = True
            elif MC.Walk_Direction(config.PlayerId, Dir.E):
                config.fov_recompute = True
            else:
                Attack_Coord(config.PlayerAttack, config.PlayerId,
                             playercoord.get_coord_from_self(Dir.E))
        elif config.key.vk == libtcodpy.KEY_HOME or \
                config.key.vk == libtcodpy.KEY_KP7:
            if MC.Walk_Direction(config.PlayerId, Dir.NW):
                if sideswipe:
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.N))
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.W))
                config.fov_recompute = True
            else:
                Attack_Coord(config.PlayerAttack, config.PlayerId,
                             playercoord.get_coord_from_self(Dir.NW))
        elif config.key.vk == libtcodpy.KEY_PAGEUP or \
                config.key.vk == libtcodpy.KEY_KP9:
            if MC.Walk_Direction(config.PlayerId, Dir.NE):
                if sideswipe:
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.N))
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.E))
                config.fov_recompute = True
            else:
                Attack_Coord(config.PlayerAttack, config.PlayerId,
                             playercoord.get_coord_from_self(Dir.NE))
        elif config.key.vk == libtcodpy.KEY_END or \
                config.key.vk == libtcodpy.KEY_KP1:
            if MC.Walk_Direction(config.PlayerId, Dir.SW):
                if sideswipe:
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.S))
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.W))
                config.fov_recompute = True
            else:
                Attack_Coord(config.PlayerAttack, config.PlayerId,
                             playercoord.get_coord_from_self(Dir.SW))
        elif config.key.vk == libtcodpy.KEY_PAGEDOWN or \
                config.key.vk == libtcodpy.KEY_KP3:
            if MC.Walk_Direction(config.PlayerId, Dir.SE):
                if sideswipe:
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.S))
                    Attack_Coord(config.PlayerAttack, config.PlayerId,
                                 playercoord.get_coord_from_self(Dir.E))
                config.fov_recompute = True
            else:
                Attack_Coord(config.PlayerAttack, config.PlayerId,
                             playercoord.get_coord_from_self(Dir.SE))
        elif config.key.vk == libtcodpy.KEY_KP5:
            pass

        else:
            key_char = chr(config.key.c)
            if key_char == '>':
                playercoord = CM.get_Component('Coord', config.PlayerId)
                curlevel = config.CurrentDungeonLevel
                leveldata = CM.get_Component('DungeonLevel',
                                             config.DungeonLevelIds[curlevel])
                coords = CM.dict_of('Coord')
                tolevels = CM.dict_of('ToLevel')
                for key, value in coords.iteritems():
                    if (value == playercoord and
                            key in tolevels and
                            key in leveldata.FeatureIds):
                        next_level()
                        config.fov_recompute = True
                        break
            elif key_char == 'b' and \
                (config.key.lctrl or config.key.rctrl) and \
                    'RandomBlink' in playercreature.Special:
                playercreature.Special['RandomBlink'] -= 1
                if playercreature.Special['RandomBlink'] <= 0:
                    playercreature.Special.pop('RandomBlink', None)
                MC.Blink_Random(config.PlayerId)
                config.fov_recompute = True
            elif key_char == 'D' \
                    and 'HealthPotion' in playercreature.Special and \
                    playercreature.CurHp < playercreature.MaxHp:
                playercreature.Special['HealthPotion'] -= 1
                if playercreature.Special['HealthPotion'] <= 0:
                    playercreature.Special.pop('HealthPotion', None)
                playercreature.CurHp += random.randint(1, 8) + 2
                if playercreature.CurHp > playercreature.MaxHp:
                    playercreature.CurHp = playercreature.MaxHp
            return 'no action'
开发者ID:Akhier,项目名称:12Down,代码行数:104,代码来源:Handle_Keys.py


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