def insertAdventurer(self, adventureComplete: AdventureC): characterid = self.getInsertCharacterID(adventureComplete._name, False) typeid = self.getBaseConstants(Type(None, adventureComplete._type), False) adventurerid = self.getInsertAdventurerID( characterid, typeid, int(adventureComplete._limited), adventureComplete.ascended, adventureComplete._stars, None, None, adventureComplete._title) # stats for attributeKeys in adventureComplete.stats: attributeid = self.getBaseConstants(Attribute(None, attributeKeys), False) db.insertData( AdventurerStats( None, adventurerid, attributeid, str(adventureComplete.stats.get(attributeKeys)))) # skills for skillsKeys in adventureComplete.skills: skillsList = adventureComplete.skills.get(skillsKeys) if (skillsKeys == "special"): adventurerskillid = db.insertData( AdventurerSkill(None, adventurerid, skillsList.get("name"), skillsKeys)) self.insertAdventurerSkillEffects(adventurerskillid, skillsList.get("effects")) elif (skillsKeys == "combat"): for skills in skillsList: adventurerskillid = db.insertData( AdventurerSkill(None, adventurerid, skills.get("name"), skillsKeys)) self.insertAdventurerSkillEffects(adventurerskillid, skills.get("effects")) # development else: for skills in skillsList: for effects in skills.get("effects"): temp_attribute = effects.get("attribute") temp_modifier = effects.get("modifier") if (temp_modifier == None): temp_modifier = "" if (len(temp_modifier) > 0 and temp_modifier[len(temp_modifier) - 1] == "%"): temp_modifier = temp_modifier[:len(temp_modifier) - 1] attributeid = self.getBaseConstants( Attribute(None, temp_attribute), False) modifierid = self.getBaseConstants( Modifier(None, temp_modifier), True) #AdventurerDevelopment db.insertData( AdventurerDevelopment(None, adventurerid, skills.get("name"), attributeid, modifierid))
def insertAdventurer(self, adventureComplete:AdventureC): characterid = self.getInsertCharacterID(adventureComplete._name, False) typeid = self.getBaseConstants(Type(None, adventureComplete._type),False) adventurerid = self.getInsertAdventurerID(characterid, typeid, int(adventureComplete._limited), adventureComplete.ascended, adventureComplete._stars, None, None, adventureComplete._title) # stats stat_list = {"hp","mp","physical_attack","magic_attack","defense","strength","endurance","dexterity","agility","magic"} temp_list = set() for attributeKeys in adventureComplete.stats: temp_list.add(attributeKeys.lower()) attributeid = self.getBaseConstants(Attribute(None, attributeKeys),False) self._db.insertData(AdventurerStats(None, adventurerid, attributeid, str(adventureComplete.stats.get(attributeKeys)))) if(stat_list != temp_list): print("HEY STAT NAMED WRONG >:( FOR : "+adventureComplete._title + " " + adventureComplete._name) raise Exception('spam', 'eggs') # skills for skillsKeys in adventureComplete.skills: skillsList = adventureComplete.skills.get(skillsKeys) if (skillsKeys =="special"): adventurerskillid = self._db.insertData(AdventurerSkill(None, adventurerid, skillsList.get("name"),skillsKeys)) self.insertAdventurerSkillEffects(adventurerskillid, skillsList.get("effects")) elif(skillsKeys =="combat"): for skills in skillsList: adventurerskillid = self._db.insertData(AdventurerSkill(None, adventurerid, skills.get("name"),skillsKeys)) self.insertAdventurerSkillEffects(adventurerskillid, skills.get("effects")) # development else: for skills in skillsList: attr_str = "" for effects in skills.get("effects"): attr_str = attr_str +" "+effects.get("attribute") temp_modifier = effects.get("modifier") if(temp_modifier == None): temp_modifier = "" if(len(temp_modifier) > 0 and temp_modifier[len(temp_modifier)-1] == "%"): temp_modifier = temp_modifier[:len(temp_modifier)-1] modifierid = self.getBaseConstants(Modifier(None, temp_modifier), True) #AdventurerDevelopment attributeid = self.getBaseConstants(Attribute(None, attr_str), False) self._db.insertData(AdventurerDevelopment(None, adventurerid, skills.get("name"), attributeid, modifierid))
def insertAssistSkillEffects(self, assistskillid, skilleffectList): # assistskilleffects SET UP for effects in skilleffectList: # Type for skills #typeid=self.getBaseConstants(Type(None, temp_type), False) temp_target = effects.get("target") temp_attribute = effects.get("attribute") temp_modifier = effects.get("modifier") temp_element = effects.get("element") temp_type = effects.get("type") if(temp_modifier==None): temp_modifier="" if(len(temp_modifier) > 0 and temp_modifier[len(temp_modifier)-1] == "%"): temp_modifier = temp_modifier[:len(temp_modifier)-1] targetid = self.getBaseConstants(Target(None, temp_target), False) attributeid = self.getBaseConstants(Attribute(None, temp_attribute), False) modifierid = self.getBaseConstants(Modifier(None, temp_modifier), True) if(temp_element == None): temp_element = "" if(temp_type == None): temp_type = "" eleid = self.getBaseConstants(Element(None, temp_element), False) typeid = self.getBaseConstants(Type(None, temp_type), False) # inserting effects self._db.insertData(AssistSkillEffects(None, assistskillid, targetid, attributeid, modifierid, effects.get("duration"), effects.get("max_activations"),eleid,typeid))
def insertAssist(self, assistComplete: AssistC): characterid = self.getInsertCharacterID(assistComplete._name, False) assistid = self.getInsertAssistID(characterid, int(assistComplete._limited), assistComplete._stars, None, None, assistComplete._title) # stats stat_list = { "hp", "mp", "physical_attack", "magic_attack", "defense", "strength", "endurance", "dexterity", "agility", "magic" } temp_list = set() for attributeKeys in assistComplete.stats: temp_list.add(attributeKeys.lower()) attributeid = self.getBaseConstants(Attribute(None, attributeKeys), False) self._db.insertData( AssistStats(None, assistid, attributeid, str(assistComplete.stats.get(attributeKeys)))) if (stat_list != temp_list): print("HEY STAT NAMED WRONG >:( FOR : " + assistComplete._title + " " + assistComplete._name) raise Exception('spam', 'eggs') # skills for skills in assistComplete.skills: assistskillid = self._db.insertData( AssistSkill(None, assistid, skills.get("name"))) self.insertAssistSkillEffects(assistskillid, skills.get("effects"))
def insertAdventurerSkillEffects(self, adventurerskillid, skilleffectList): ele_list = [ 'light', 'wind', 'fire', 'dark', 'ice', 'water', 'earth', 'thunder' ] # AdventurerSkillEffects SET UP for effects in skilleffectList: #Type+Element temp_type = effects.get("type") if (temp_type == None): temp_type = "" temp_element = effects.get("element") if (temp_element == None): temp_element = "" if (temp_type.split("_")[0] in ele_list): temp_split = temp_type.split("_") temp_element = temp_split[0] print(temp_type) temp_type = temp_split[1] + "_" + temp_split[2] #temp_index = temp_value.find("_") #temp_element = temp_value[0:temp_index] #temp_ad_ele = temp_element #temp_type = temp_value[temp_index+1:] #else: #temp_type = "" #temp_element="" # Element eleid = self.getBaseConstants(Element(None, temp_element), False) # Type for skills typeid = self.getBaseConstants(Type(None, temp_type), False) temp_target = effects.get("target") temp_attribute = effects.get("attribute") temp_speed = effects.get("speed") temp_modifier = effects.get("modifier") if (temp_modifier == None): temp_modifier = "" if (len(temp_modifier) > 0 and temp_modifier[len(temp_modifier) - 1] == "%"): temp_modifier = temp_modifier[:len(temp_modifier) - 1] targetid = self.getBaseConstants(Target(None, temp_target), False) attributeid = self.getBaseConstants( Attribute(None, temp_attribute), False) speedid = self.getBaseConstants(Speed(None, temp_speed), False) modifierid = self.getBaseConstants(Modifier(None, temp_modifier), True) # inserting effects self._db.insertData( AdventurerSkillEffects(None, adventurerskillid, targetid, attributeid, modifierid, effects.get("duration"), typeid, eleid, speedid))
def insertAssist(self, assistComplete: AssistC): characterid = self.getInsertCharacterID(assistComplete._name, False) assistid = self.getInsertAssistID(characterid, int(assistComplete._limited), assistComplete._stars, None, None, assistComplete._title) # stats for attributeKeys in assistComplete.stats: attributeid = self.getBaseConstants(Attribute(None, attributeKeys), False) db.insertData( AssistStats(None, assistid, attributeid, str(assistComplete.stats.get(attributeKeys)))) # skills for skills in assistComplete.skills: assistskillid = db.insertData( AssistSkill(None, assistid, skills.get("name"))) self.insertAssistSkillEffects(assistskillid, skills.get("effects"))
def insertAdventurerSkillEffects(self, adventurerskillid, skilleffectList): # AdventurerSkillEffects SET UP for effects in skilleffectList: #Type+Element temp_type = effects.get("type") if (temp_type == None): temp_type = "" temp_element = effects.get("element") if (temp_element == None): temp_element = "" #temp_index = temp_value.find("_") #temp_element = temp_value[0:temp_index] #temp_ad_ele = temp_element #temp_type = temp_value[temp_index+1:] #else: #temp_type = "" #temp_element="" # Element eleid = self.getBaseConstants(Element(None, temp_element), False) # Type for skills typeid = self.getBaseConstants(Type(None, temp_type), False) temp_target = effects.get("target") temp_attribute = effects.get("attribute") temp_speed = effects.get("speed") temp_modifier = effects.get("modifier") if (temp_modifier == None): temp_modifier = "" if (len(temp_modifier) > 0 and temp_modifier[len(temp_modifier) - 1] == "%"): temp_modifier = temp_modifier[:len(temp_modifier) - 1] targetid = self.getBaseConstants(Target(None, temp_target), False) attributeid = self.getBaseConstants( Attribute(None, temp_attribute), False) speedid = self.getBaseConstants(Speed(None, temp_speed), False) modifierid = self.getBaseConstants(Modifier(None, temp_modifier), True) # inserting effects db.insertData( AdventurerSkillEffects(None, adventurerskillid, targetid, attributeid, modifierid, effects.get("duration"), typeid, eleid, speedid))