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


Python Location.debug_string方法代码示例

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


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

示例1: load_from_file

# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import debug_string [as 别名]
 def load_from_file(self,map_path):
   conf_file = os.path.join(map_path,"map.json")
   
   #Open the file for reading
   f = open(conf_file,'r')
   
   if f:
     self.log_debug("File (%s) Opened" % (conf_file))
     
     #Read in the entire file and load it as json
     map_conf = load(f)
     self.log_debug("Loaded JSON from file")
     self.log_debug("JSON: %s" % str(map_conf))
     
     #Set the map settings
     try:
       self.title = map_conf["general"]["title"]
       self.x_size = map_conf["general"]["x_size"]
       self.y_size = map_conf["general"]["y_size"]
     except KeyError,e:
       self.log_error("Invalid config file: %s is missing" % str(e))
       return
     
     #Now setup the game board
     self.generate_grid(self.x_size,self.y_size)
     
     #Add locations to the grid
     for location_json in map_conf["locations"]:
       if "start_location" in location_json and location_json["start_location"]:
         start_location = True
       else:
         start_location = False
       self.log_debug("Processing location JSON %s" % str(location_json))
       location = Location(name=location_json["title"],symbol=location_json["symbol"],start_location=start_location)
       
       #Parse the jobs for this location
       if "jobs" in location_json:
         for job_json in location_json["jobs"]:
           self.log_debug("Processing job JSON %s" % str(job_json))
           job = Job(name=job_json["title"],
                     symbol=job_json["symbol"] if "symbol" in job_json else "",
                     availability=job_json["availability"],
                     pay=job_json["pay"],
                     rank=job_json["rank"],
                     location=location)
           location.add_job(job)
       if "education" in location_json:
         for class_json in location_json["education"]:
           self.log_debug("Processing class JSON %s" % str(class_json))
           course = Course(name=class_json["title"],
                           symbol=class_json["symbol"],
                           knowledge_value=class_json["knowledge_value"],
                           time=class_json["time"],
                           knowledge_required=class_json["knowledge_required"],
                           course_required=class_json["course_required"] if "course_required" in class_json else None,
                           cost=class_json["cost"])
           location.add_course(course)
       if "items" in location_json:
         for items_json in location_json["items"]:
           self.log_debug("Processing item JSON %s" % str(items_json))
           effects = {}
           if "effects" in items_json:
             for effect in items_json["effects"]:
               self.log_debug("Processing effect json: %s" % str(effect))
               effects[effect['attribute']] = effect['value']
           self.log_debug("Loaded effects as %s" % (str(effects)))
           item = Item(name=items_json["title"],
                     symbol=items_json["symbol"] if "symbol" in items_json else "",
                     availability=items_json["availability"],
                     cost=items_json["cost"],
                     effects=effects,
                     consumable=items_json["consumable"] if "consumable" in items_json else True,
                     )
           location.add_item(item)
           self.log_debug("Added item:\n%s" % item.debug_string())
       
       #Finally add this location to the map
       self.log_debug("Loaded location from file:\n%s" % location.debug_string())
       self.add_location(location_json["x"],location_json["y"],location)
     
     #Close the file
     f.close()
开发者ID:ChodeGames,项目名称:bitfl,代码行数:84,代码来源:map.py


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