enzanki-ars / rocket-league-replay-analysis

UNMAINTAINED - Creating videos for Analyzing Rocket League Replays (https://gitlab.com/enzanki_ars/rocket-league-replay-analysis)
https://gitlab.com/enzanki_ars/rocket-league-replay-analysis
GNU Affero General Public License v3.0
24 stars 2 forks source link

XP miscalculation #48

Closed ghost closed 6 years ago

ghost commented 6 years ago

I'm not entirely sure how to submit a pull request, but there should be support for players that have reached the max level and continued to gain XP. Currently, if a player has maxed out their levels, this function will return an error because get_xp_level is returning None.

Just a small fix, untested but should work:

data/xp.py

def get_xp_level(xp):
    levels = [(1000, 1),
              (2000, 2),
              (3250, 3),
              (4750, 4),
              (6500, 5),
              (9250, 6),
              (13000, 7),
              (17750, 8),
              (23500, 9),
              (30250, 10),
              (38750, 11),
              (49000, 12),
              (61000, 13),
              (74750, 14),
              (90250, 15),
              (108250, 16),
              (128750, 17),
              (151750, 18),
              (177250, 19),
              (205250, 20),
              (236500, 21),
              (271000, 22),
              (308750, 23),
              (349750, 24),
              (394000, 25),
              (442250, 26),
              (494500, 27),
              (550750, 28),
              (611000, 29),
              (675250, 30),
              (744250, 31),
              (818000, 32),
              (896500, 33),
              (979750, 34),
              (1067750, 35),
              (1161250, 36),
              (1260250, 37),
              (1364750, 38),
              (1474750, 39),
              (1590250, 40),
              (1712000, 41),
              (1840000, 42),
              (1974250, 43),
              (2114750, 44),
              (2261500, 45),
              (2415250, 46),
              (2576000, 47),
              (2743750, 48),
              (2918500, 49),
              (3100250, 50),
              (3289750, 51),
              (3487000, 52),
              (3692000, 53),
              (3904750, 54),
              (4125250, 55),
              (4354250, 56),
              (4591750, 57),
              (4837750, 58),
              (5092250, 59),
              (5355250, 60),
              (5627500, 61),
              (5909000, 62),
              (6199750, 63),
              (6499750, 64),
              (6809000, 65),
              (7128250, 66),
              (7457500, 67),
              (7796750, 68),
              (8146000, 69),
              (8505250, 70),
              (8875250, 71),
              (9256000, 72),
              (9647500, 73),
              (10049750, 74),
              (10462750, 75)]

    max_xp = max([x[0] for x in levels])
    max_level = max([x[1] for x in levels])

    if xp > max_xp:
        return max_level
    else:
        for xp_limit, xp_level in levels:
            if xp <= xp_limit:
                return xp_level
enzanki-ars commented 6 years ago

Thank you for the information! I didn't even realize that there was a bug here (the wiki does not have much information in to whether players can go over max level or not.) I will be sure to include this fix.

By the way, it is possible to create a pull request online by clicking on the edit button on the file in GitHub. For example, this file would be here. Once click there, it will allow you to edit the file, commit it to your own fork, and submit a pull request all at once. Don't worry about it though, as I can add this code very easily.

enzanki-ars commented 6 years ago

I was about to commit the fix, but I wanted to credit you correctly (using this new feature). Sadly, I do not have a github email address for you.

If you would like the change credited to you, could you go to https://github.com/settings/emails and post the email address GitHub gives in the "Keep my email address private" section here or on my Reddit PMs (@enzanki_ars)?

enzanki-ars commented 6 years ago

Nevermind. It seems that the noreply email that I used worked correctly! https://github.com/enzanki-ars/rocket-league-replay-analysis/commit/9b89aa77f3036408388ad67cb35605329520b5b3