示例#1
0
    def __init__(self, data, WR):
        self.place = data["place"]
        self.time = run_time(data["run"]["times"]["primary_t"])
        self.delta_p = self.time - WR
        self.perc = round(self.time / WR * 100, 2)

        if self.place != 1:
            self.moy_rank = run_time((self.time - WR) / (self.place - 1))
        else:
            self.moy_rank = run_time(0)
示例#2
0
    def __add__(self, other):
        tempo = super().__add__(other)

        tempo.Run_average = run_time(tempo.Run_Total / tempo.Run_count)
        tempo.PB_average = run_time(tempo.PB_Total / tempo.Run_count)
        tempo.WR_average = run_time(tempo.WR_Total / tempo.Run_count)
        tempo.PB_delta_average = run_time(tempo.PB_delta / tempo.Run_count)
        tempo.perc = round((tempo.PB_Total) / tempo.WR_Total * 100, 2)


        return tempo
示例#3
0
def get_leaderboards_level(IDs):
    varistr = ""
    if IDs[3] != {}:
        tempo = []
        for key in IDs[3]:
            tempo.append(f"var-{key}={IDs[3][key]}")
        varistr = "&".join(tempo)
        if varistr != "": varistr = "?" + varistr

    game_date = requester(f"/games/{IDs[0]}")['data']["release-date"]
    now = str(datetime.date.today())

    rankings = {}
    for year in range(int(now[:4]), int(game_date[:4]), -1):
        print(f"Getting year {year} leaderboard")
        tempo = []
        rep = requester(
            f"/leaderboards/{IDs[0]}/level/{IDs[2]}/{IDs[1]}?date={f'{year}-{now[5:7]}-{now[8:10]}'}"
            + varistr)

        for run in rep["data"]["runs"]:
            tempo.append((run_time(run["run"]["times"]["primary_t"])))
        if len(tempo) == 0: break
        else:
            rankings[year] = tempo
    return rankings
示例#4
0
    def __init__(self, system, pbs, runs):
        self.system = system
        self.runs = runs
        self.pbs = pbs

        sum_Runs = sum(runs)
        sum_Pbs = sum(pbs)

        self.Run_count = len(self.runs)
        self.Run_Total = sum_Runs.time


        self.PB_count = len(pbs)
        self.WR_Total = sum_Pbs.WR
        self.PB_Total = sum_Pbs.time
        self.PB_delta = sum_Pbs.delta
        self.perc = round((self.PB_Total) / self.WR_Total * 100, 2)

        self.Run_average = run_time(self.Run_Total / self.Run_count)
        self.PB_average = run_time(self.PB_Total / self.PB_count)
        self.WR_average = run_time(self.WR_Total / self.PB_count)
        self.PB_delta_average = run_time(self.PB_delta / self.PB_count)
示例#5
0
    def __truediv__(self, integ):
        tempo = deepcopy(self)
        for cle, value in tempo.__dict__.items():
            if isinstance(value, run_time):
                tempo.__dict__[cle] = run_time(tempo.__dict__[cle] / integ)
            elif isinstance(value, int) or isinstance(value, float):
                tempo.__dict__[cle] /= integ
                if "count" in cle:
                    tempo.__dict__[cle] = int(tempo.__dict__[cle])

            else:
                pass
        return tempo
示例#6
0
    def __init__(self, IDs, game, category, rank, level=None):
        super().__init__()

        self.IDs = IDs
        self.game = game
        self.category = category
        self.place = rank
        self.level = level
        if not IDs[2]:
            print(f"     Fetching {self.game} - {self.category}")
            infos = get_leaderboard(IDs)["data"]["runs"]
        else:
            print(f"     Fetching {self.game} - {level} - {self.category}")
            infos = get_leaderboard_level(IDs)["data"]["runs"]
        self.WR = run_time(infos[0]["run"]["times"]["primary_t"])
        for no, one in enumerate(infos):
            self.data.append(ranking(one, self.WR))
示例#7
0
    def __init__(self, data):
        def clean_gamename(name):
            if "The Legend of Zelda" in name:
                return name[14:]
            if name == "Ocarina of Time Category Extensions":
                return "Zelda: Ocarina of Time"
            if name == "Super Mario 64 Category Extensions":
                return "Super Mario 64"

            else:
                return name

        def repertoire(lequel, data, requester):
            try:
                return lequel[data]
            except KeyError:
                lequel[data] = requester(data)
                return lequel[data]

        self.IDs = [data["game"], data["category"], data["level"], {}]
        self.system = repertoire(Run.systems, data["system"]["platform"],
                                 get_system)

        self.game = clean_gamename(
            repertoire(Run.games, data["game"], get_game))

        self.category = repertoire(Run.categories, data["category"],
                                   get_category)

        subcateg = []
        for value, item in data["values"].items():
            tempo = get_variable(value)
            if tempo["is-subcategory"]:
                subcateg.append(tempo["values"]["values"][item]["label"])
                self.IDs[3][value] = item
        if subcateg:
            self.category = f'{self.category} ({",".join(subcateg)})'

        self.level = None
        if self.IDs[2]:
            self.level = repertoire(Run.levels, self.IDs[2], get_level)

        self.time = run_time(data["times"]["primary_t"])