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


Python Tile.addItem方法代码示例

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


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

示例1: init_map

# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import addItem [as 别名]
def init_map( file_ptr ):
  
  current_tile = None
  
  # read from the configuration file
  config = configparser.ConfigParser()
  config.read( file_ptr )
  if len( config.sections() ) == 0:
    raise IOException( "File not found." )
  
  tile_record = dict()
  
  sections = config.sections()
  for section in sections:
    
    tile = Tile()
    
    try:
      description = config.get( section, "description" )
      tile.setDescription( description )
    except (KeyError, configparser.NoOptionError):
      pass
    
    try:
      itemlist = config.get( section, "items" )
      itemlist = itemlist.split(" & ")
      for item in itemlist:
        atoms = item.split(" ")
        item_name = atoms[-1].strip()
        item_modifier = ' '.join( atoms[:-1] ).strip()
        
        item_obj = Item(item_name, item_modifier)
        tile.addItem( item_obj )
    except (KeyError, configparser.NoOptionError):
      pass
    
    try:
      actorlist = config.get( section, "actors" )
      actorlist = actorlist.split(", ")
      for actor in actorlist:
        print( "Actors currently unsupported!" )
        pass
    except (KeyError, configparser.NoOptionError):
      pass
    
    try:
      currentflag = config.get( section, "start" )
      if current_tile != None:
        print("Multiple start tiles detected!")
      current_tile = tile
    except (KeyError, configparser.NoOptionError):
      pass
    
    tile_record[ section ] = tile
  
  for section in sections:
    try:
      north_target = config.get( section, "north" )
      if north_target in tile_record.keys():
        north_target = tile_record[ north_target ]
        tile_record[ section ].linkTile( north_target, NORTH )
      else:
        print( "Link target %s not found." % north_target )
    except (KeyError, configparser.NoOptionError):
      pass
    
    try:
      south_target = config.get( section, "south" )
      if south_target in tile_record.keys():
        south_target = tile_record[ south_target ]
        tile_record[ section ].linkTile( south_target, SOUTH )
      else:
        print( "Link target %s not found." % south_target )
    except (KeyError, configparser.NoOptionError):
      pass
    
    try:
      east_target = config.get( section, "east" )
      if east_target in tile_record.keys():
        east_target = tile_record[ east_target ]
        tile_record[ section ].linkTile( east_target, EAST )
      else:
        print( "Link target %s not found." % east_target )
    except (KeyError, configparser.NoOptionError):
      pass
    
    try:
      west_target = config.get( section, "west" )
      if west_target in tile_record.keys():
        west_target = tile_record[ west_target ]
        tile_record[ section ].linkTile( west_target, WEST )
      else:
        print( "Link target %s not found." % west_target )
    except (KeyError, configparser.NoOptionError):
      pass
    
    try:
      up_target = config.get( section, "up" )
      if up_target in tile_record.keys():
        up_target = tile_record[ up_target ]
#.........这里部分代码省略.........
开发者ID:jrouly,项目名称:dungeon-crawler,代码行数:103,代码来源:util.py


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