Esempio n. 1
0
async def generatesupskills(source) -> str:
    output = ""
    removetooltip(source)
    removecitation(source)
    iconreplace(source)
    for tr in source.find_all("tr"):
        if tr.find_all("th"):
            continue
        if tr.get("class"):
            continue
        output += "**" + tr.find("td", {"class": "skill-name"}).text.strip() + \
                  "**\n"
        # I don't know why this check is actually needed but it doesn't work
        # without it
        if EMP or DOMAIN in tr.find("td", {"class": "skill-name"}).text:
            td = tr.find_all("td", {"style": ""})[1]
        else:
            td = tr.find_all("td", {"style": ""})[2]
        for span in td.find_all("span", {"class": "tooltip"}):
            span.replace_with("/" + span.text)
        output += "Obtained: " + td.text.strip() + "\n"
        td = tr.find("td", {"style": "text-align:left;"})
        for span in td.find_all("span", {"class": "skill-upgrade-text"}):
            span.replace_with("\n__" + span.text + "__")
        for br in td.find_all("br"):
            br.replace_with(" ")
        output += td.text + "\n"
    return output
Esempio n. 2
0
async def generateskills(source, multiskill: bool) -> list:
    # Skills are too big to put in one field, so this generates the information
    # for each skill to be displayed in its own field.
    output = []
    # Miscellaneous cleaning
    removetooltip(source)
    removecitation(source)
    iconreplace(source)
    # Skill counter and text buffer for the skill info
    i = 1
    skillinfo = ""
    for tr in source.find_all("tr"):
        if tr.find_all("th") or tr.get("class"):
            if multiskill and tr.find("th", {"colspan": "6"}):
                output.append((tr.find("th", {"colspan": "6"}).text, "Press "
                              "the :arrows_counterclockwise: reaction to see "
                               "this character's other skills"))
            continue
        # Get the cell with the skill name
        td = tr.find("td", {"class": "skill-name"})
        # Handle any skill name changes
        for span in td.find_all("span", {"class": "skill-upgrade-text"}):
            for br in span.find_all("br"):
                br.replace_with(" ")
            span.replace_with("/" + span.text)
        skillname = "Skill " + str(i) + ": " + td.text.strip()
        # The next three cells don't have a class identifier, so you just have
        # to hope the table format stays consistent with all cases
        td = tr.find_all("td", {"class": None})
        # The first unmarked cell is for the cooldown, which needs handling of
        # potential cooldown reductions and linked skills
        for span in td[0].find_all("span"):
            if "Linked" not in span.text:
                span.replace_with("/" + span.text + " ")
            else:
                span.replace_with("(Linked Skill) ")
        skillinfo += "Cooldown: " + td[0].text + "\n"
        # The second unmarked cell is for the duration, which needs handling of
        # potential upgrades
        for span in td[1].find_all("span"):
            span.replace_with("/" + span.text + " ")
        skillinfo += "Duration: " + td[1].text + "\n"
        for span in td[2].find_all("span"):
            span.replace_with("/" + span.text)
        # The third unmarked cell is for the obtain level, which also includes
        # potential upgrades
        skillinfo += "Obtained: " + td[2].text + "\n"
        # The cell with skill information apparently doesn't have an identifier,
        # but it DOES always have a specific styling.
        td = tr.find("td", {"style": "text-align:left;"})
        for br in td.find_all("br"):
            br.replace_with(" ")
        for span in td.find_all("span", {"class": "skill-upgrade-text"}):
            span.replace_with("\n__" + span.text + "__")
        skillinfo += td.text + "\n"
        output.append((skillname, skillinfo))
        skillinfo = ""
        i += 1
    return output
Esempio n. 3
0
async def generateca(source) -> list:
    # Empty variables to be filled later
    name = ""
    output = []
    outputtext = ""
    # Miscellaneous cleaning
    removetooltip(source)
    removecitation(source)
    iconreplace(source)
    # Check if the CA eventually gets another name
    if len(source.find_all("td", {"class": "skill-name"})) > 1:
        namechange = True
    else:
        namechange = False
    for tr in source.find_all("tr"):
        # If the row has styling, it's a dud row
        if tr.find("th") is not None:
            continue
        # If the row has a "skill" upgrade, add it in mark it as such, then
        # Remove it to prevent double inclusion
        if tr.find("td", {"class": "skill-name"}) and not namechange:
            name = " - " + tr.find("td", {"class": "skill-name"}).text
            tr.find("td", {"class": "skill-name"}).replace_with("")
        if tr.find("span", {"class": "skill-upgrade-text"}):
            if namechange:
                outputtext += "__" + tr.find("span", {"class":
                                             "skill-upgrade-text"}).text + \
                              "__\n"
                tr.find("span", {"class": "skill-upgrade-text"})\
                    .replace_with("")
            else:
                tr.find("span", {"class": "skill-upgrade-text"}) \
                    .replace_with("\n__" + tr.find("span", {"class":
                                  "skill-upgrade-text"}).text + "__\n")
        td = tr.find("td", {"style": "text-align:left;"})
        for br in td.find_all("br"):
            br.replace_with(" ")
        if namechange:
            outputtext += "**" + tr.find("td", {"class": "skill-name"}).text + \
                      ":** " + td.text + "\n"
        else:
            outputtext += td.text

    output.append(name)
    output.append(outputtext)
    return output
Esempio n. 4
0
async def generateca(source) -> list:
    # Cutting out unneeded bits
    raw = source[source.find("<img alt=\"Skill"):].split("</tr>", 1)[0]
    # ...Mirage Munitions
    if "None" in raw:
        return ["None", "-"]
    parsed = BeautifulSoup(raw, 'html.parser')
    # Getting the name
    name = parsed.find_all("td", {"class": "skill-name"})[0].text
    # Remove line breaks
    for br in parsed.find_all("br"):
        br.replace_with("\n")
    # Miscellaneous cleaning
    removetooltip(parsed)
    removecitation(parsed)
    iconreplace(parsed)
    for span in parsed.find_all("span", {"class": "skill-upgrade-text"}):
        span.string.replace_with("**" + span.string + "**")
    output = parsed.find_all("td", {"class": ""})[0].text
    return [name, output]
Esempio n. 5
0
async def generateaura(source: str, categories: list) -> str:
    output = ""
    # Check if the summon has sub auras and trim the source accordingly.
    if "Summons with Sub Auras" in categories:
        raw = source[source.find("Main Aura"):].split("</tbody>", 1)[0]
        output += "__Main Aura__\n"
    else:
        raw = source[source.find("Aura"):].split("</tbody>", 1)[0]
    parsed = BeautifulSoup(raw, "html.parser")
    # Remove tooltips
    removetooltip(parsed)
    # Icons
    iconreplace(parsed)
    for tr in parsed.find_all("tr"):
        # Main aura was already inserted in the trimming phase. This inserts
        # the sub aura separator.
        if "Aura" in tr.text:
            output += "__Sub Aura__\n"
        else:
            output += "**" + tr.find("th").text + ":** " + tr.find("td").text \
                      + "\n"
    return output
Esempio n. 6
0
async def generatecall(source: str) -> list:
    # Empty variables to be filled later
    output = []
    # Trim to what's needed
    raw = source[source.find("/Summons#Calls") - 25:].split("</tbody>", 1)[0]
    parsed = BeautifulSoup(raw, "html.parser")
    # Miscellaneous cleaning
    removetooltip(parsed)
    removecitation(parsed)
    iconreplace(parsed)
    # Remove cooldown text
    for th in parsed.find_all("th", {"style": "width:35px;"}):
        th.replace_with("")
    # Get call name
    output.append("Name " + parsed.find("th", {
        "colspan": "2"
    }).text.split(" ", 1)[1])
    # Counters and buffer variables to be filled
    skillspan = 0
    cdspan = 0
    uncap = ""
    cd = ""
    call = ""
    for tr in parsed.find_all("tr"):
        # Check if the row has call text, or if it's just an uncap identifier
        # or uncomboable identifier
        if tr.find("td"):
            # Check if the call text covers multiple uncaps, and increment
            # skillspan accordingly
            if tr.find("td").get("rowspan"):
                skillspan = int(tr.find("td")["rowspan"])
            # Get call text
            call = tr.find("td").text
            # Check if the "call" is just an indicator that the call cannot be
            # comboed:
            if call == "Can't be included in other players' combo calls.":
                continue
        # De-increment cdspan and keep the cooldown as-is, or get the new
        # cooldown if cdspan is 1 or less
        if cdspan > 1:
            cdspan -= 1
        else:
            for td in tr.find_all("td", {"style": "text-align:center;"}):
                # If the cooldown has separate values for first call and
                # subsequent calls, the first call will be recorded, and then
                # when the tr steps to the next cooldown (for subsequent calls),
                # a slash will be inserted to split the two.
                if cd:
                    cd += "/"
                cd += td.text
                if td.get("rowspan"):
                    cdspan = int(td['rowspan'])
        # Inserts a slash between multiple uncaps with the same call text and
        # de-increments skillspan, or gets the uncap level.
        if uncap:
            uncap += "/" + tr.find("th").text
            skillspan -= 1
        else:
            if "once" not in tr.text:
                uncap = tr.find("th").text
        # If all the uncaps are covered (skillspan <=1), then the output is
        # processed and stored, and the buffer variables and counters are reset.
        if skillspan <= 1:
            skillspan = 0
            # Check for the case of single-use summons
            if "Can only be summoned once per battle." not in tr.text:
                output.append(("" + uncap, call + " (" + cd + ")"))
            else:
                output[0] += "\n**" + call + "**"
            uncap = ""
            if cdspan <= 1:
                cd = ""
    return output