def update_user_characters(): user_ids = database_mongo.get_all_users_list_ids() for _id in user_ids: u = get_user(_id) chars = u.characters for name in chars.keys(): chars[name] = get_character_from_dict(chars, name).get_dict() u.characters = chars database_mongo.save_user(u)
def remove_character(self, charName): c = character.get_character_from_dict( self.characters, formatter_custom.name_formatter(charName)) if c.total > 1: if c.total <= 7: c.const_amnt -= 1 c.total -= 1 self.characters[formatter_custom.name_formatter( charName)] = c.get_dict() else: del self.characters[formatter_custom.name_formatter(charName)]
def equip_weapon(self, charName, weapName): if not self.does_character_exist(charName): return False, "c" if not self.does_weapon_exist(weapName): return False, "w" c = character.get_character_from_dict(self.characters, charName) w = weapon.get_weapon_from_dict(self.weapons, weapName) if c.weapon_type.upper() != w.weapon_type.upper(): return False, "i" c.equip_weapon(w) self.save_character(c) return True, "g"
def clear_user_xp(): users_ids = database_mongo.get_all_users_list_ids() for i in range(len(users_ids)): u = get_user(users_ids[i]) u.reset_level() for char_key in u.characters.keys(): char = character.get_character_from_dict(u.characters, char_key) char.xp = 0 u.characters[char_key] = char.get_dict() for weap_key in u.weapons.keys(): weap = weapon.get_weapon_from_dict(u.weapons, weap_key) weap.xp = 0 u.weapons[weap_key] = weap.get_dict() database_mongo.save_user(u)
def update_users(): users_ids = database_mongo.get_all_users_list_ids() for i in range(len(users_ids)): u = get_user(users_ids[i]) for char_key in u.characters.keys(): char = character.get_character_from_dict(u.characters, char_key) char_DB = character.get_character(char.name) char.URL_icon = char_DB.URL_icon char.URL_portrait = char_DB.URL_portrait char.description = char_DB.description char.constellations = char_DB.constellations char.constellation_name = char_DB.constellation_name u.characters[char_key] = char.get_dict() for weap_key in u.weapons.keys(): weap = weapon.get_weapon_from_dict(u.weapons, weap_key) weap_DB = weapon.get_weapon(weap.name) weap.URL_icon = weap_DB.URL_icon u.weapons[weap_key] = weap.get_dict() database_mongo.save_user(u)
def get_character(self, charName): c = character.get_character_from_dict( self.characters, formatter_custom.name_formatter(charName)) return c