Skip to content

Commit

Permalink
clean: remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueRou committed Dec 7, 2023
1 parent a3637e1 commit 282d3b9
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions app/objects/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
from enum import unique
from pathlib import Path
from typing import TYPE_CHECKING
from app.repositories.addition.scores_suspicion import ScoresSuspicion

import app.state
import app.usecases.performance
import app.utils
from app import settings
from app.constants.clientflags import ClientFlags
from app.constants.gamemodes import GameMode
from app.constants.mods import Mods
Expand All @@ -21,17 +19,13 @@
from app.usecases.performance import ScoreParams
from app.utils import escape_enum
from app.utils import pymysql_encode
from circleguard import Circleguard, ReplayPath

if TYPE_CHECKING:
from app.objects.player import Player

__all__ = ("Grade", "SubmissionStatus", "Score")

BEATMAPS_PATH = Path.cwd() / ".data/osu"
REPLAYS_PATH = Path.cwd() / ".data/osr"

circleguard = Circleguard(settings.OSU_API_KEY)

@unique
class Grade(IntEnum):
Expand Down Expand Up @@ -461,52 +455,3 @@ async def increment_replay_views(self) -> None:
{"user_id": self.player.id, "mode": self.mode},
)

async def save_suspicion(self, reason: str, detail: dict):
async with app.state.services.db_session() as session:
obj = ScoresSuspicion(score_id=self.id, suspicion_reason=reason, suspicion_time=datetime.now(), detail=detail)
await app.orm_utils.add_model(session, obj)

async def check_suspicion(self):
replay_path = REPLAYS_PATH / f"{self.id}.osr"

frametime_limition = 14
vanilla_ur_limition = 70
snaps_limition = 20

replay = ReplayPath(replay_path)
snaps = circleguard.snaps(replay)
frametime = circleguard.frametime(replay)
ur = circleguard.ur(replay)

detail = {
'beatmap': {
'title': self.bmap.title,
'bid': self.bmap.id,
'sid': self.bmap.set_id,
'md5': self.bmap.md5,
},
'score': {
'score_id': self.id,
'pp': self.pp,
'mode': repr(self.mode),
'mods': repr(self.mods)
},
'user': {
'user_id': self.player.id,
'username': self.player.full_name
},
'analysis': {
'frametime': frametime,
'ur': ur,
'snaps': len(snaps)
}
}

if frametime < frametime_limition:
await self.save_suspicion(f"timewarp cheating (frametime: {frametime:.2f}) / {frametime_limition})", detail)

if (not self.mods & Mods.RELAX) and ur < vanilla_ur_limition:
await self.save_suspicion(f"potential relax (ur: {ur:.2f} / {vanilla_ur_limition})", detail)

if len(snaps) > snaps_limition:
await self.save_suspicion(f"potential assist (snaps: {len(snaps):.2f} / {snaps_limition})", detail)

0 comments on commit 282d3b9

Please sign in to comment.