示例#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
示例#2
0
def get_all_weaps_API():
    allWeapNames = get_weapon_names_API()
    allWeaps = []
    for i in allWeapNames:
        URL_name = "{}".format(i)
        weapList = database_mongo.get_all_weapons_of_criteria(
            "URL_name", URL_name)
        if len(weapList) == 0:
            print("Getting {} Data".format(i))
            response = requests.get(apiURL + "weapons/" + i)
            json_data = response.json()

            name = formatter_custom.name_unformatter("{}".format(i))
            URL_icon = f"Images/Weapons/{URL_name}-icon.png"

            rarity = int("{}".format(json_data['rarity']))
            weapon_type = "{}".format(json_data['type'])
            attack = int("{}".format(json_data['baseAttack']))
            substat = "{}".format(json_data['subStat'])

            allWeaps.append(
                Weapon(name, URL_name, URL_icon, weapon_type, 0, rarity, 1,
                       attack, substat, 0, 1, 0))
            print("Finished {} Data".format(i))
        else:
            allWeaps.append(get_weapon(URL_name))
    print("Finished Weapons")
    return allWeaps
示例#3
0
async def embed_show_char_info(ctx, u, c):
    color = discord.Color.red()
    char_DB = character.get_character(c["name"])
    if char_DB.element == "Anemo":
        color = discord.Color.green()
    elif char_DB.element == "Dendro":
        color = discord.Color.dark_green()
    elif char_DB.element == "Electro":
        color = discord.Color.purple()
    elif char_DB.element == "Hydro":
        color = discord.Color.dark_blue()
    elif char_DB.element == "Geo":
        color = discord.Color.orange()
    elif char_DB.element == "Cryo":
        color = discord.Color.blue()
    const_names_dict = char_DB.constellation_name
    const_names = ""
    for key in const_names_dict.keys():
        if const_names == "":
            const_names += const_names_dict[key]
        else:
            const_names += " or " + const_names_dict[key]
    embed = discord.Embed(title="{un}\'s {cn}".format(un=u.nickname,
                                                      cn=char_DB.name),
                          color=color,
                          description=char_DB.description)
    level = formatter_custom.number_format(c["level"])
    currXP = formatter_custom.number_format(c["xp"])
    maxXP = formatter_custom.number_format(
        formatter_custom.get_xp_to_next_level(c["level"]))
    embed.add_field(name="Level {l}".format(l=level),
                    value="**XP:** {x}/{xm}".format(x=currXP, xm=maxXP))
    embed.add_field(
        name="Amount Info",
        value="**Constellations Unlocked:** {cu}\n**Total Wished:** {tr}".
        format(cu=c["const_amnt"],
               tr=formatter_custom.number_format(c["total"])))
    if len(c["weapon_equiped"]) == 0:
        text = "None"
    else:
        text = c["weapon_equiped"]["name"]
    embed.add_field(name="Equiped Weapon", value=text)
    embed.add_field(
        name="Trivia Info",
        value="**Element:** {e}\n**Constellation:** {c}\n**Weapon Type:** {w}".
        format(e=char_DB.element,
               c=const_names,
               w=formatter_custom.name_unformatter(
                   formatter_custom.name_formatter(char_DB.weapon_type))))
    f = []
    f.append(discord.File(c["URL_icon"], "{}-icon.png".format(c["URL_name"])))
    f.append(
        discord.File(c["URL_portrait"],
                     "{}-portrait.png".format(c["URL_name"])))
    embed.set_image(url="attachment://{}-portrait.png".format(c["URL_name"]))
    embed.set_thumbnail(url="attachment://{}-icon.png".format(c["URL_name"]))

    await ctx.send(embed=embed, files=f)
示例#4
0
 def set_team(self, teamNum, characters):
     for name in characters:
         if not self.does_character_exist(name):
             return False, name
     self.teams[str(teamNum)] = {}
     for i in range(len(characters)):
         self.teams[str(teamNum)][str(
             i + 1)] = formatter_custom.name_unformatter(
                 formatter_custom.name_formatter(characters[i]))
     return True, "None"
示例#5
0
 def change_favorite_character(self, name):
     if formatter_custom.name_formatter(name) in self.characters.keys():
         self.favorite_character = formatter_custom.name_unformatter(
             formatter_custom.name_formatter(name))
         return True
     elif name.lower() == "none":
         self.favorite_character = "None"
         return True
     else:
         return False