def translate(self, index, to): """ Función que traduce un texto usando el servicio de google traductor. :param index: Índice del string :type index: int :param to: Idioma destino :type to: str :return: String con la entrada traducida :rtype: str """ text = self.get(index) if langselfconfig.is_true("TRANSLATIONS"): # Si el servicio de traducciones esta activado if NULL_IDENTIFIER not in text: try: # Se consulta por la traducción al servicio de google # noinspection SpellCheckingInspection return google_translate( text, to, str(langtranslateconfig.get_value("WEB_HEADER")), str(langtranslateconfig.get_value("WEB_GOOGLETRANSLATE")), ) except: # Si ocurre algún error en la traducción return text else: errors.warning(errors.ERROR_CANTTRANSLATE) return text else: return text
def get(self, index, *args, **kwargs): """ Retorna un string asociado al índice -index- en el archivo de idiomas cargado. :param index: Índice del string :type index: int, string :param args: Argumentos :type args: list :param kwargs: Parámetros :type kwargs: list :return: String asociado al índice :rtype: str """ if str(index).isdigit(): try: # Si existe el lang en la matriz de datos # noinspection PyUnresolvedReferences,SpellCheckingInspection if kwargs.get("noformat") or len(args) == 0: return self.lang[index] else: return self.lang[index].format(*args) except: errors.warning(errors.ERROR_LANGNOTEXIST, str(index), self.langname) return NULL_LANG.format(str(index)) else: errors.warning(errors.ERROR_LANGBADINDEX, str(index)) return NULL_LANG.format(str(index))
def isTrue(self, param): """ Función que retorna true si el parámetro del archivo es verdadero :param param: Parámetro a buscar :return: booleano """ if param in self.getParameters(): if self.configs[param] == TRUE: return True else: return False else: errors.warning(errors.ERROR_CONFIGNOTEXISTENT, param)
def __init__(self, directory, conffile, **kwargs): """ Función constructora de la clase. Keywords: - verbose (bool) = Indica si se imprime el estado de ejecución o no en consola :param directory: Ubicación del archivo de configuraciones :type directory: str :param conffile: Nombre del archivo de configuraciones :type conffile: str :param kwargs: Parámetros adicionales :type kwargs: list :return: void """ # Se carga el archivo de configuraciones filename = directory + conffile try: # noinspection PyShadowingBuiltins file = open(filename.replace("\\", "/"), "r") # @ReservedAssignment except: errors.throw(errors.ERROR_NOCONFIGFILE, filename) # Variables self.config_single = [] self.configs = {} self.filename = filename self.filename_title = conffile self.totalconfigs = 0 # Se cargan las configuraciones for configline in file: if configline[0] != CONFIG_COMMENT and configline != "\n": config = string2list(configline, CONFIG_SEPARATOR) if len(config) == 1: self.config_single.append(config[0]) elif len(config) == 2: self.totalconfigs += 1 self.configs[config[0]] = config[1] else: errors.throw(errors.ERROR_BADCONFIG, configline, filename) if kwarg_is_true_param(kwargs, "verbose"): self.verbose = True if not (self.totalconfigs + len(self.config_single)): errors.warning(errors.WARNING_NOCONFIGFOUND, filename) else: print CONFIG_LOAD.format(filename) else: self.verbose = False file.close()
def visitCfgVertex(self, vertex): "Generic visitor for simple statements" # Check the entry points for following in vertex.outEdges: if len(vertex.entryPoints) > 0: # Not unreachable code if following.entryPoints != vertex.entryPoints: if isinstance(vertex, Goto): self.longjumps.append(vertex) else: # TODO: Improve error message errors.warning("Unreachable statement at line %s" % vertex.lineNum) vertex.forEachChild(self.visit)
def getValue(self, param): """ Retorna el valor del parametro param :param param: Parámetro :return: valor """ if str(param).isdigit(): param = int(param) if 0 <= param < len(self.config_single): return self.config_single[param] else: errors.throw(errors.ERROR_BADINDEXCONFIG, str(param)) else: if param in self.getParameters(): return self.configs[param] else: errors.warning(errors.ERROR_CONFIGNOTEXISTENT, param)
def is_true(self, param): """ Función que retorna true si el parámetro del archivo es verdadero. :param param: Parámetro a buscar :type param: str :return: Booleano indicando pertenencia :rtype: bool """ if param in self.get_parameters(): if self.configs[param].upper() == TRUE or self.configs[param] == "1": return True else: return False else: errors.warning(errors.ERROR_CONFIGNOTEXISTENT, param)
def get_value(self, param, **kwargs): """ Retorna el valor del parámetro param. Keywords: - autoNumberify (bool) = Activa la auto-conversión a números :param param: Parámetro a obtener valor :type param: object :param kwargs: Keywords :return: Valor del parámetro :rtype: object """ if str(param).isdigit(): param = int(param) if 0 <= param < len(self.config_single): param_value = str(self.config_single[param]) # noinspection PyTypeChecker if kwarg_is_true_param(kwargs, "autoNumberify"): # Auto-conversión a números return convert_to_number(param_value) # El resultado se entrega sin convertir else: return param_value else: errors.throw(errors.ERROR_BADINDEXCONFIG, str(param)) else: if param in self.get_parameters(): param_value = self.configs[param] # noinspection PyTypeChecker if kwarg_is_true_param(kwargs, "autoNumberify"): # Auto-conversión a números return convert_to_number(param_value) # El resultado se entrega sin convertir else: return param_value else: errors.warning(errors.ERROR_CONFIGNOTEXISTENT, param) return None
def get(self, index, *args, **kwargs): """ Retorna un string asociado al indice -index- en el archivo de idiomas cargado :param index: Indice del string :param args: Argumentos :param kwargs: Parámetros :return: String """ if str(index).isdigit(): try: # Si existe el lang en la matriz de datos if kwargs.get("noformat") or len(args) == 0: return self.lang[index] else: return self.lang[index].format(*args) except: errors.warning(errors.ERROR_LANGNOTEXIST, str(index), self.langname) return NULL_LANG.format(str(index)) else: errors.warning(errors.ERROR_LANGBADINDEX, str(index)) return NULL_LANG.format(str(index))
def translate(self, index, to): """ Función que traduce un texto usando el servicio de google traductor :param index: Indice del string :param to: Idioma destino :return: String """ text = self.get(index) if langselfconfig.isTrue("TRANSLATIONS"): # Si el servicio de traducciones esta activado if not NULL_IDENTIFIER in text: try: # Se consulta por la traducción al servicio de google return googleTranslate(text, to, langtranslateconfig.getValue("WEB_HEADER"), langtranslateconfig.getValue("WEB_GOOGLETRANSLATE")) except: # Si ocurre algún error en la traducción return text else: errors.warning(errors.ERROR_CANTTRANSLATE) return text else: return text
def guardExecutableDefinitions(entry_points): logging.debug("Checking for direct execution of function or procedure bodies...") for entry_point in entry_points.values(): if isinstance(entry_point, syntax.ast.DefinitionStatement): if len(entry_point.inEdges) != 0: reachable_predecessors = (len(predecessor.entryPoints) > 0 for predecessor in entry_point.inEdges) if any(reachable_predecessors): errors.warning("Execution of procedure/function at line %s" % entry_point.lineNum) # TODO: Could use ERROR statement here # TODO: Could also have an option to allow procedures to be directly executable # which may involve inserting a call to the procedure at this point ... probably # more appropriate for GOSUBroutines. raise_stmt = syntax.ast.Raise(type="ExecutedDefinitionException") raise_stmt.lineNum = entry_point.lineNum ast_utils.insertStatementBefore(entry_point, raise_stmt) raise_stmt.clearOutEdges() entry_point.clearInEdges() return entry_point, entry_points
def inferTypeOfFunction(entry_point): ''' Infer the type of the function defined at entry_point by discovering the type of all of the return points from the function. If the types are different numeric types, promote IntegerTypes to FloatTypes. If the types are a mixture of StringTypes and NumericTypes box the return value in an object type. :param entry_point: A DefineFunction AstNode at the start of a user defined function. :returns: The infered type of the function. One of IntegerType, FloatType, StringType or ObjectType. If the type of the function could not be inferred (possibly because other function types need inferring too) return PendingType. ''' print "DEF ", entry_point.name return_types = set() for vertex in depthFirstSearch(entry_point): if isinstance(vertex, ReturnFromFunction): return_types.add(vertex.returnValue.actualType) for type in return_types: print " =", type # If there is only one return type, set the type of the function, and exit if len(return_types) == 0: errors.warning("%s never returns at line %s" % (entry_point.name, entry_point.lineNum)) elif PendingOwlType() in return_types: return_type = PendingOwlType() elif len(return_types) == 1: return_type = representative(return_types) elif reduce(operator.and_, [type.isA(NumericOwlType()) for type in return_types]): # TODO: Modify all function returns to cast to FloatOwlType, if necessary return_type = FloatOwlType() else: # TODO: Modify all function returns to box to ObjectOwlType, if necessary # TODO: Modify all function calls to unbox from ObjectOwlType, to what? return_type = ObjectOwlType() entry_point.returnType = return_type return return_type
def branchCheck(self, branch): if branch[0] == "QuestStart": return branch[1] + ":" + branch[2] in self.player.getParent().getQuests() elif branch[0] == "NotQuestStart": return branch[1] + ":" + branch[2] not in self.player.getParent().getQuests() elif branch[0] == "QuestObjComplete": if branch[1] + ":" + branch[2] in self.player.getParent().getQuests(): return self.player.getParent().getQuests()[branch[1] + ":" + branch[2]].getObjectiveCompleted(branch[3]) return False elif branch[0] == "Item": if self.player.getParent().getInventory().hasItem(ItemFactory.createItem(*branch[2:])) == None: return False else: if self.player.getParent().getInventory().hasItem( ItemFactory.createItem(*branch[2:]) ).getAmount() >= int(branch[1]): return True else: return False else: errors.warning("Unknown Branch: " + branch[0])
def questAction(self, action): if action[0] == "Add": if action[1] + ":" + action[2] not in self.player.getParent().getQuests(): quest = loadQuest(config.AssetPath + action[1], action[2]) self.player.getParent().getQuests()[action[1] + ":" + action[2]] = quest elif action[0] == "Complete": if action[1] + ":" + action[2] in self.player.getParent().getQuests(): quest = self.player.getParent().getQuests()[action[1] + ":" + action[2]] quest.completeObjective(action[3]) if quest.getCompleted(): for reward in quest.getRewards(): key, val = reward.split(" ", 1) if key == "Gold": self.player.getParent().getInventory().addGold(int(val)) elif key == "Exp": self.player.getParent().getBattleObject().addExp(int(val)) elif key == "Item": item = ItemFactory.createItem(val.split(" ")) self.player.getParent().getInventory().addItem(item) else: errors.warning("Unknown Quest Action: " + action[0])
def __init__(self, filename, **kwargs): """ Función constructora :param filename: Nombre del archivo :param kwargs: Parámetros adicionales :return: void """ # Se carga el archivo de configuraciones try: file = open(filename.replace("\\", "/"), "r") # @ReservedAssignment except: errors.throw(errors.ERROR_NOCONFIGFILE, filename) # Variables self.config_single = [] self.configs = {} self.filename = filename self.totalconfigs = 0 # Se cargan las configuraciones # noinspection PyUnboundLocalVariable for configline in file: if configline[0] != CONFIG_COMMENT and configline != "\n": config = string2list(configline, CONFIG_SEPARATOR) if len(config) == 1: self.config_single.append(config[0]) elif len(config) == 2: self.totalconfigs += 1 self.configs[config[0]] = config[1] else: errors.throw(errors.ERROR_BADCONFIG, configline, filename) if kwargs.get("verbose"): self.verbose = True if not (self.totalconfigs + len(self.config_single)): errors.warning(errors.WARNING_NOCONFIGFOUND, filename) else: print CONFIG_LOAD.format(filename) else: self.verbose = False file.close()
def __init__(self, filename, **kwargs): """ Función constructora :param filename: Nombre del archivo :param kwargs: Parámetros adicionales :return: void """ # Se carga el archivo de configuraciones try: file = open(filename.replace('\\', '/')) # @ReservedAssignment except: errors.throw(errors.ERROR_NOCONFIGFILE, filename) # Variables self.config_single = [] self.configs = {} self.filename = filename self.totalconfigs = 0 # Se cargan las configuraciones # noinspection PyUnboundLocalVariable for configline in file: if configline[0] != CONFIG_COMMENT and configline != "\n": config = string2list(configline, CONFIG_SEPARATOR) if len(config) == 1: self.config_single.append(config[0]) elif len(config) == 2: self.totalconfigs += 1 self.configs[config[0]] = config[1] else: errors.throw(errors.ERROR_BADCONFIG, configline, filename) if kwargs.get("verbose"): self.verbose = True if not (self.totalconfigs + len(self.config_single)): errors.warning(errors.WARNING_NOCONFIGFOUND, filename) else: print(CONFIG_LOAD.format(filename)) else: self.verbose = False file.close()
def translate(self, index, to): """ Función que traduce un texto usando el servicio de google traductor :param index: Indice del string :param to: Idioma destino :return: String """ text = self.get(index) if langselfconfig.isTrue( "TRANSLATIONS" ): # Si el servicio de traducciones esta activado if NULL_IDENTIFIER not in text: try: # Se consulta por la traducción al servicio de google return google_translate( text, to, langtranslateconfig.getValue("WEB_HEADER"), langtranslateconfig.getValue("WEB_GOOGLETRANSLATE")) except: # Si ocurre algún error en la traducción return text else: errors.warning(errors.ERROR_CANTTRANSLATE) return text else: return text
def loadXML(xmlPath,level,GameEngine,GraphicEngine): errors.info("Loading level: "+level) try: filer = open(xmlPath,"r") except IOError: errors.critical("Level file not found.") exit() lines = filer.readlines() started=False levelData = [] for i in range(len(lines)): #Strip Tabs and New Lines lines[i] = lines[i].lstrip("\t").rstrip("\n") for line in lines: #Extract Level Data if not started: if line == "<Level "+level+">": started=True continue if line == "</Level>": break levelData.append(line) Name=None BG = None Mask=None Enemies=None BattleBG=None BattleFBG=None Triggers = [] GameObjects = [] NPCs = [] i = 0 while i < len(levelData): #Isolate Triggers, NPCs, and GameObjects (GraphicObjects must be dealt with immediately because they are contained within GameObjects) temp = {} if levelData[i].startswith("<LevelName>"): Name=levelData[i].lstrip("<LevelName").lstrip(">").rstrip("/LevelName>").rstrip("<") elif levelData[i].startswith("<Background>"): BG=levelData[i].lstrip("<Background").lstrip(">").rstrip("/Background>").rstrip("<") elif levelData[i].startswith("<Mask>"): Mask=levelData[i].lstrip("<Mask").lstrip(">").rstrip("/Mask>").rstrip("<") elif levelData[i].startswith("<Enemies>"): Enemies = json.loads(levelData[i].lstrip("<Enemies").lstrip(">").rstrip("/Enemies>").rstrip("<")) elif levelData[i].startswith("<BattleBG>"): BattleBG = json.loads(levelData[i].lstrip("<BattleBG").lstrip(">").rstrip("/BattleBG>").rstrip("<")) elif levelData[i]=="<Trigger>": n=1 while levelData[i+n]!="</Trigger>": key = levelData[i+n][1:levelData[i+n].find(">")] value = levelData[i+n][levelData[i+n].find(">")+1:levelData[i+n].find("<",levelData[i+n].find(">"))] temp[key]=json.loads(value) n+=1 Triggers.append(temp) i+=n elif levelData[i].startswith("<GameObject"): path = levelData[i].lstrip("<GameObject").rstrip(">").lstrip(" ").split(" ")[0] if len(levelData[i].lstrip("<GameObject").rstrip(">").lstrip(" ").split(" "))>1: objectName = levelData[i].lstrip("<GameObject").rstrip(">").lstrip(" ").split(" ")[1] if path != "": tempFiler = file(config.AssetPath+path,"r") lines = tempFiler.readlines() started=False for j in range(len(lines)): #Strip Tabs and New Lines lines[j] = lines[j].lstrip("\t").rstrip("\n") j=1 for line in lines: #Extract Level Data if not started: if line == "<GameObject "+objectName+">": started=True continue if line == "</GameObject>": break levelData.insert(i+j,line) j+=1 #for line in levelData: # print line temp["graphicObject"] = {} n=1 while levelData[i+n]!="</GameObject>": key = levelData[i+n][1:levelData[i+n].find(">")] if key == "Mask": n+=1 temp["mask"] = {} while levelData[i+n]!="</Mask>": state = levelData[i+n][7:levelData[i+n].find(">")] temp["mask"][state] = json.loads(levelData[i+n][levelData[i+n].find(">")+1:levelData[i+n].rfind("<")]) n+=1 n+=1 elif key == "GraphicObject": if "animations" not in temp["graphicObject"]: temp["graphicObject"]["animations"] = {} n+=1 while levelData[i+n]!="</GraphicObject>": if levelData[i+n].startswith("<State"): state = levelData[i+n][7:levelData[i+n].find(">")] temp["graphicObject"]["animations"][state] = [None,None,None,None] n+=1 while levelData[i+n]!="</State>": #Retrieve Direction dire = int(levelData[i+n][11:levelData[i+n].find(">")]) xml = levelData[i+n][levelData[i+n].find(">")+1:levelData[i+n].rfind("<")] if dire == 0: temp["graphicObject"]["animations"][state][dire] = loadAnimation(xml,state+"N") elif dire == 1: temp["graphicObject"]["animations"][state][dire] = loadAnimation(xml,state+"E") elif dire == 2: temp["graphicObject"]["animations"][state][dire] = loadAnimation(xml,state+"S") elif dire == 3: temp["graphicObject"]["animations"][state][dire] = loadAnimation(xml,state+"W") n+=1 n+=1 else: key = levelData[i+n][levelData[i+n].find("<")+1:levelData[i+n].find(">")] value = levelData[i+n][levelData[i+n].find(">")+1:levelData[i+n].rfind("<")] temp["graphicObject"][key] = json.loads(value) n+=1 n+=1 else: value = levelData[i+n][levelData[i+n].find(">")+1:levelData[i+n].find("<",levelData[i+n].find(">"))] temp[key[0].lower()+key[1:]]=json.loads(value) n+=1 GameObjects.append(temp) i+=n elif levelData[i].startswith("<NPC"): path = levelData[i].lstrip("<NPC").rstrip(">").lstrip(" ").split(" ")[0] if len(levelData[i].lstrip("<NPC").rstrip(">").lstrip(" ").split(" "))>1: objectName = levelData[i].lstrip("<GameObject").rstrip(">").lstrip(" ").split(" ")[1] if path != "": tempFiler = file(config.AssetPath+path,"r") lines = tempFiler.readlines() started=False for j in range(len(lines)): #Strip Tabs and New Lines lines[j] = lines[j].lstrip("\t").rstrip("\n") j=1 for line in lines: #Extract Level Data if not started: if line == "<NPC "+objectName+">": started=True continue if line == "</NPC>": break levelData.insert(i+j,line) j+=1 n=1 while levelData[i+n]!="</NPC>": key = levelData[i+n][1:levelData[i+n].find(">")] value = levelData[i+n][levelData[i+n].find(">")+1:levelData[i+n].find("<",levelData[i+n].find(">"))] if key == "Dialog": if value != "null": dialog=open(config.AssetPath+value,"r") lines=dialog.readlines() dialog="" for line in lines: dialog+=line.rstrip("\n") dialog.replace("\t","") temp["Dialog"]=json.loads(dialog) else: temp["Dialog"]=None elif key == "AnimeXML": temp["AnimeXML"]=value elif key == "Icon": if value=="null": temp["Icon"]=None else: temp["Icon"]=value else: temp[key]=json.loads(value) n+=1 NPCs.append(temp) i+=1 i+=1 if Name == None: errors.warning("Level has no Name attribute.") Name = "Unknown Area" GraphicEngine.setLevelName(Name) if BG == None: errors.error("Level has no Background attribute.") else: try: GraphicEngine.setBackground(pygame.image.load(config.AssetPath+BG).convert()) except pygame.error: errors.error("Unable to load level background.") if Mask == None: errors.info("Level has no Mask attribute.") else: try: GameEngine.setMask(pygame.image.load(config.AssetPath+Mask).convert()) except pygame.error: errors.error("Unable to load level mask.") if Enemies != None and len(Enemies)>0: if BattleBG == None or len(BattleBG) == 0: errors.info("No battle backgrounds specified for this level.") else: # for i in xrange(len(BattleBG)): # for j in range(len(BattleBG[i])): # if BattleBG[i][j] != None: # try: # BattleBG[i][j] = pygame.image.load(BattleBG[i][j]).convert_alpha() # except pygame.error: # errors.error("Unable to load battle background for this level.") # BattleBG[i][j] = None GameEngine.setBattleBG(BattleBG) GameEngine.setEnemies(Enemies) else: GameEngine.setBattleBG([]) GameEngine.setEnemies([]) for trigger in Triggers: errors.debug("Adding "+trigger["Id"]+" trigger.") # Should probably be using a factory... if "Area" in trigger.keys() and trigger["Area"]!=None: trigger["Area"] = pygame.rect.Rect(trigger["Area"]) if trigger["Effect"]=="State Set": del trigger["Effect"] GameEngine.addTrigger(triggers.StateSetTrigger(**trigger)) elif trigger["Effect"]=="State Toggle": del trigger["Effect"] GameEngine.addTrigger(triggers.StateToggleTrigger(**trigger)) elif trigger["Effect"]=="Area Change": del trigger["Effect"] GameEngine.addTrigger(triggers.AreaChangeTrigger(**trigger)) elif trigger["Effect"]=="SBSC": del trigger["Effect"] GameEngine.addTrigger(triggers.SBSCTrigger(**trigger)) elif trigger["Effect"]=="TBSC": del trigger["Effect"] GameEngine.addTrigger(triggers.TBSCTrigger(**trigger)) elif trigger["Effect"]=="Battle": del trigger["Effect"] GameEngine.addTrigger(triggers.BattleTrigger(**trigger)) elif trigger["Effect"]=="Item": del trigger["Effect"] GameEngine.addTrigger(triggers.ItemTrigger(**trigger)) elif trigger["Effect"]=="Quest Complete": del trigger["Effect"] GameEngine.addTrigger(triggers.QuestCompleteTrigger(**trigger)) else: errors.error("Undefined Trigger Effect") for obj in GameObjects: errors.debug("Adding "+obj["id"]) #print str(obj["id"])+":" #for key in obj.keys(): # print key,obj[key] #for key in obj["graphicObject"].keys(): # print key,obj["graphicObject"][key] #for key in obj["graphicObject"]["animations"].keys(): # for i in range(0,4): # if obj["graphicObject"]["animations"][key][i] != None: # print key+str(i),len(obj["graphicObject"]["animations"][key][i].getFrames()) # else: # print key+str(i),None #print "\n" for state in obj["mask"].keys(): if obj["mask"][state] != None: img = pygame.image.load(config.AssetPath+str(obj["mask"][state])) obj["mask"][state] = maskFromSurface(img) if obj["graphicObject"].keys().__contains__("flipX"): for state in obj["graphicObject"]["animations"].keys(): i=0 if obj["graphicObject"]["animations"][state][1].getNextAnimation() != None: nextAnimation = obj["graphicObject"]["animations"][state][1].getNextAnimation()[:-1]+"W" else: nextAnimation = None obj["graphicObject"]["animations"][state][3] = Animation(None,nextAnimation,state+"W") for frame in obj["graphicObject"]["animations"][state][1].getFrames(): i+=1 obj["graphicObject"]["animations"][state][3].addFrame(AnimationFrame(pygame.transform.flip(frame.image,True,False),frame.delay,None,i-1)) del obj["graphicObject"]["flipX"] #Animation Linker: for state in obj["graphicObject"]["animations"].keys(): for dire in range(0,4): if obj["graphicObject"]["animations"][state][dire] == None: continue nextState = obj["graphicObject"]["animations"][state][dire].getNextAnimation() if nextState == None or type(nextState)==Animation: continue if obj["graphicObject"]["animations"][nextState.rstrip("NESW")][dire].getName()==nextState: obj["graphicObject"]["animations"][state][dire].nextAnimation = obj["graphicObject"]["animations"][nextState.rstrip("NESW")][dire] else: errors.error("Animation linker is officially insufficient. \n(It was already unofficially insufficient, but now things just got worse)\n((Troublemaker: "+state+" -> "+nextState+"))") obj["graphicObject"] = GraphicObject(**obj["graphicObject"]) GraphicEngine.addObject(obj["graphicObject"]) if obj.keys().__contains__("pushable") and obj["pushable"]==True: del obj["pushable"] if obj["area"]!=None: obj["area"] = pygame.rect.Rect(obj["area"]) GameEngine.addActor(Pushable(**obj)) else: GameEngine.addActor(GameObject(**obj)) for npc in NPCs: if "AnimeXML" in npc: errors.debug("Adding sNPC: "+npc["Id"]) if npc["Icon"]!=None: npc["Icon"]=pygame.image.load(npc["Icon"]).convert() npc["Dialog"]=loadDialog(npc["Dialog"]) #print npc["Dialog"] temp = sNPC(**npc) GameEngine.addNPC(temp) GraphicEngine.addObject(temp.getGraphicObject()) else: errors.debug("Adding NPC: "+npc["Id"]) if npc["Icon"]!=None: npc["Icon"]=pygame.image.load(npc["Icon"]).convert() npc["Dialog"]=loadDialog(npc["Dialog"]) #print npc["Dialog"] temp = NPC(**npc) GameEngine.addNPC(temp) GraphicEngine.addObject(temp.getGraphicObject()) filer.close()
import ctypes import os import signal import string import time except Exception: errors.throw(errors.ERROR_IMPORTSYSTEMERROR) # Importación de librerías externas # noinspection PyBroadException try: # noinspection PyUnresolvedReferences import WConio # @UnresolvedImport except: if os.name == "nt": errors.warning(errors.ERROR_IMPORTWCONIO) # Constantes _CMD_COLORS = { "blue": 0x10, "gray": 0x80, "green": 0x20, "lblue": 0x90, "lgray": 0x70, "lgreen": 0xA0, "lred": 0xC0, "purple": 0x50, "white": 0xF0, "yellow": 0x60, "lpurple": 0xD0, "lyellow": 0xE0,