Skip to content

Commit

Permalink
Add level property
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Mar 13, 2024
1 parent 2b12b80 commit e5bfab6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion osu/objects/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from .status import Status
from ..game import Game

from ..bancho.constants import LEVEL_GRAPH, ClientPackets, Privileges, Mode
from ..bancho.streams import StreamOut
from ..bancho.constants import ClientPackets, Privileges, Mode

import logging

Expand Down Expand Up @@ -61,6 +61,20 @@ def mode(self, value: Mode):
def loaded(self) -> bool:
return bool(self.name)

@property
def level(self) -> int:
if self.tscore <= 0:
return 1

if self.tscore >= LEVEL_GRAPH[-1]:
return 100 + int((self.tscore - LEVEL_GRAPH[99]) / 100000000000)

for idx, v in enumerate(LEVEL_GRAPH, start=0):
if v > self.tscore:
return idx

return 1

def request_presence(self):
"""Request a presence update for this player"""
self.game.bancho.request_presence([self.id])
Expand Down

0 comments on commit e5bfab6

Please sign in to comment.