Example #1
0
def get_all_characters_API():
    print("Getting Characters from API")
    allCharNames = get_character_names_API()
    allChars = []
    for i in allCharNames:
        URL_name = "{}".format(i)
        charList = database_mongo.get_all_characters_of_criteria(
            "URL_name", URL_name)
        if len(charList) == 0:
            print("getting {} data".format(i))
            response = requests.get(apiURL + "characters/" + i)
            json_data = response.json()
            name = formatter_custom.name_unformatter("{}".format(i))

            iconURL = f"Images/Characters/{URL_name}-icon.png"
            portraitURL = f"Images/Characters/{URL_name}-portrait.png"

            description = formatter_custom.text_formatter("{}".format(
                json_data['description']))
            rarity = int("{}".format(json_data['rarity']), base=10)
            element = formatter_custom.name_unformatter("{}".format(
                json_data['vision']))
            weaponType = "{}".format(json_data['weapon_type'])
            constName = {"1": "{}".format(json_data['constellation'])}
            constellations = constellation.get_all_constillations(
                rarity, json_data)
            allChars.append(
                Character(name, URL_name, iconURL, portraitURL, description,
                          rarity, element, {}, weaponType, constName,
                          constellations, {}, 1, 0, 0, 0, 5, 100, 0, 50, 20))
            print("finished {} data".format(i))
        else:
            allChars.append(get_character(URL_name))
    print("Finished Getting Characters from API")
    return allChars
Example #2
0
def does_char_exist(name):
  real_char = database_mongo.get_all_characters_of_criteria("URL_name", formatter_custom.name_formatter(name))
  if real_char == []:
    return False
  return True
Example #3
0
def get_six_star_characters():
  sixStarChars = database_mongo.get_all_characters_of_criteria("rarity", 6)
  chars = []
  for c in sixStarChars:
    chars.append(dict_to_char(c))
  return chars
Example #4
0
def get_four_star_characters():
  fourStarChars = database_mongo.get_all_characters_of_criteria("rarity", 4)
  chars = []
  for c in fourStarChars:
    chars.append(dict_to_char(c))
  return chars