def return_objectives(self): """ """ objectives = [] for ordinal in self.objectives: obj_num = self.objectives[ordinal]["number"] achieved = self.db.achieved.get(ordinal, 0) if self.objectives[ordinal]["type"] == defines.OBJECTIVE_TALK: target = LS("Talk to") object = DIALOGUE_HANDLER.get_npc_name(self.objectives[ordinal]["object"]) objectives.append({"target": target, "object": object, "achieved": achieved, "total": obj_num }) return objectives
def return_objectives(self): """ Get the information of all objectives. Set desc to an objective can hide the details of the objective. """ objectives = [] for ordinal in self.objectives: desc = self.objectives[ordinal]["desc"] if desc: # If an objective has desc, use its desc. objectives.append({"desc": self.objectives[ordinal]["desc"]}) else: # Or make a desc by other data. obj_num = self.objectives[ordinal]["number"] accomplished = self.db.accomplished.get(ordinal, 0) if self.objectives[ordinal]["type"] == defines.OBJECTIVE_TALK: # talking target = LS("Talk to") name = DIALOGUE_HANDLER.get_npc_name( self.objectives[ordinal]["object"]) objectives.append({ "target": target, "object": name, "accomplished": accomplished, "total": obj_num, }) elif self.objectives[ordinal][ "type"] == defines.OBJECTIVE_OBJECT: # getting target = LS("Get") name = "" # Get the name of the objective object. for model_name in settings.COMMON_OBJECTS: model = apps.get_model(settings.WORLD_DATA_APP, model_name) if model: # Get record. try: record = model.objects.get( key=self.objectives[ordinal]["object"]) name = record.name break except Exception, e: pass objectives.append({ "target": target, "object": name, "accomplished": accomplished, "total": obj_num, }) elif self.objectives[ordinal][ "type"] == defines.OBJECTIVE_KILL: # getting target = LS("Kill") name = "" # Get the name of the objective character. for model_name in settings.COMMON_OBJECTS: # find in common objects model = apps.get_model(settings.WORLD_DATA_APP, model_name) if model: # Get record. try: record = model.objects.get( key=self.objectives[ordinal]["object"]) name = record.name break except Exception, e: pass if not name: # find in world_npcs for model_name in settings.WORLD_NPCS: # find in common objects model = apps.get_model(settings.WORLD_DATA_APP, model_name) if model: # Get record. try: record = model.objects.get( key=self.objectives[ordinal]["object"]) name = record.name break except Exception, e: pass
def return_objectives(self): """ Get the information of all objectives. Set desc to an objective can hide the details of the objective. """ objectives = [] for ordinal in self.objectives: desc = self.objectives[ordinal]["desc"] if desc: # If an objective has desc, use its desc. objectives.append({"desc": self.objectives[ordinal]["desc"]}) else: # Or make a desc by other data. obj_num = self.objectives[ordinal]["number"] accomplished = self.db.accomplished.get(ordinal, 0) if self.objectives[ordinal]["type"] == defines.OBJECTIVE_TALK: # talking target = _("Talk to") name = DIALOGUE_HANDLER.get_npc_name(self.objectives[ordinal]["object"]) objectives.append({"target": target, "object": name, "accomplished": accomplished, "total": obj_num, }) elif self.objectives[ordinal]["type"] == defines.OBJECTIVE_OBJECT: # getting target = _("Get") name = "" # Get the name of the objective object. object_key = self.objectives[ordinal]["object"] model_names = OBJECT_KEY_HANDLER.get_models(object_key) for model_name in model_names: model = apps.get_model(settings.WORLD_DATA_APP, model_name) # Get record. try: record = model.objects.get(key=object_key) name = record.name break except Exception, e: pass objectives.append({"target": target, "object": name, "accomplished": accomplished, "total": obj_num, }) elif self.objectives[ordinal]["type"] == defines.OBJECTIVE_KILL: # getting target = _("Kill") name = "" # Get the name of the objective character. object_key = self.objectives[ordinal]["object"] model_names = OBJECT_KEY_HANDLER.get_models(object_key) for model_name in model_names: model = apps.get_model(settings.WORLD_DATA_APP, model_name) # Get record. try: record = model.objects.get(key=object_key) name = record.name break except Exception, e: pass objectives.append({"target": target, "object": name, "accomplished": accomplished, "total": obj_num, })
def return_objectives(self): """ Get the information of all objectives. Set desc to an objective can hide the details of the objective. """ output = [] for ordinal, objective in self.objectives.items(): desc = objective["desc"] if desc: # If an objective has desc, use its desc. output.append({"ordinal": ordinal, "desc": objective["desc"]}) else: # Or make a desc by other data. obj_num = objective["number"] accomplished = self.db.accomplished.get(ordinal, 0) if objective["type"] == defines.OBJECTIVE_TALK: # talking target = _("Talk to") name = DIALOGUE_HANDLER.get_npc_name(objective["object"]) output.append({ "ordinal": ordinal, "target": target, "object": name, "accomplished": accomplished, "total": obj_num, }) elif objective["type"] == defines.OBJECTIVE_OBJECT: # getting target = _("Get") # Get the name of the objective object. object_key = objective["object"] model_name = TYPECLASS("OBJECT").model_name model = apps.get_model(settings.WORLD_DATA_APP, model_name) # Get record. try: record = model.objects.get(key=object_key) name = record.name except Exception as e: logger.log_err("Can not find the quest object: %s" % object_key) continue output.append({ "ordinal": ordinal, "target": target, "object": name, "accomplished": accomplished, "total": obj_num, }) elif self.objectives[ordinal][ "type"] == defines.OBJECTIVE_KILL: # getting target = _("Kill") # Get the name of the objective character. object_key = self.objectives[ordinal]["object"] model_name = TYPECLASS("OBJECT").model_name model = apps.get_model(settings.WORLD_DATA_APP, model_name) # Get record. try: record = model.objects.get(key=object_key) name = record.name except Exception as e: logger.log_err("Can not find the quest object: %s" % object_key) continue output.append({ "ordinal": ordinal, "target": target, "object": name, "accomplished": accomplished, "total": obj_num, }) return output