def difficulty(self) -> Union[DemonDifficulty, LevelDifficulty]: """Union[:class:`.LevelDifficulty`, :class:`.DemonDifficulty`]: Difficulty of the level.""" difficulty = self.options.get("difficulty", -1) if self.is_demon(): return DemonDifficulty.from_value(difficulty) else: return LevelDifficulty.from_value(difficulty)
def into_level( self, client: Optional[Client] = None, get_data: bool = True, server_style: bool = False, ) -> Level: if self.is_demon(): difficulty = DemonDifficulty.from_name(self.difficulty) else: difficulty = LevelDifficulty.from_name(self.difficulty) if get_data: data = official_levels_data.get(self.name, "") if data: data = Coder.unzip(data) else: data = "" return Level( id=self.level_id, name=self.name, description=f"Official Level: {self.name}", version=1, creator=AbstractUser(name="RobTop", id=16, account_id=71, client=client), song=Song.official(self.get_song_id(server_style), client=client, server_style=server_style), data=data, password=None, copyable=False, is_demon=self.is_demon(), is_auto=self.is_auto(), difficulty=difficulty, stars=self.stars, coins=self.coins, verified_coins=True, is_epic=False, original=True, low_detail_mode=False, downloads=0, rating=0, score=1, uploaded_timestamp="unknown", last_updated_timestamp="unknown", length=LevelLength.from_name(self.length), stars_requested=self.stars, object_count=0, type=TimelyType.from_value(0), time_n=-1, cooldown=-1, client=client, )
def official(cls, level_id: int, client: Optional[Client] = None) -> None: mapping = { # ID: (name, stars, difficulty, coins, length) 1: ("Stereo Madness", 1, "easy", 3, 3), 2: ("Back On Track", 2, "easy", 3, 3), 3: ("Polargeist", 3, "normal", 3, 3), 4: ("Dry Out", 4, "normal", 3, 3), 5: ("Base After Base", 5, "hard", 3, 3), 6: ("Cant Let Go", 6, "hard", 3, 3), 7: ("Jumper", 7, "harder", 3, 3), 8: ("Time Machine", 8, "harder", 3, 3), 9: ("Cycles", 9, "harder", 3, 3), 10: ("xStep", 10, "insane", 3, 3), 11: ("Clutterfunk", 11, "insane", 3, 3), 12: ("Theory of Everything", 12, "insane", 3, 3), 13: ("Electroman Adventures", 10, "insane", 3, 3), 14: ("Clubstep", 14, "easy_demon", 3, 3), 15: ("Electrodynamix", 12, "insane", 3, 3), 16: ("Hexagon Force", 12, "insane", 3, 3), 17: ("Blast Processing", 10, "harder", 3, 3), 18: ("Theory of Everything 2", 14, "easy_demon", 3, 3), 19: ("Geometrical Dominator", 10, "harder", 3, 3), 20: ("Deadlocked", 15, "easy_demon", 3, 3), 21: ("Fingerdash", 12, "insane", 3, 3), 1001: ("The Seven Seas", 1, "easy", 3, 3), 1002: ("Viking Arena", 2, "normal", 3, 3), 1003: ("Airborne Robots", 3, "hard", 3, 3), 2001: ("Payload", 2, "easy", 0, 1), 2002: ("Beast Mode", 3, "normal", 0, 2), 2003: ("Machina", 3, "normal", 0, 2), 2004: ("Years", 3, "normal", 0, 2), 2005: ("Frontlines", 3, "normal", 0, 2), 2006: ("Space Pirates", 3, "normal", 0, 2), 2007: ("Striker", 3, "normal", 0, 2), 2008: ("Embers", 3, "normal", 0, 1), 2009: ("Round 1", 3, "normal", 0, 2), 2010: ("Monster Dance Off", 3, "normal", 0, 2), 3001: ("The Challenge", 3, "hard", 0, 1), # well... 4001: ("Press Start", 4, "normal", 3, 3), 4002: ("Nock Em", 6, "hard", 3, 3), 4003: ("Power Trip", 8, "harder", 3, 3), } translate = { 1001: 22, 1002: 23, 1003: 24, 3001: 25, 2001: 26, 2002: 27, 2003: 28, 2004: 29, 2005: 30, 2006: 31, 2007: 32, 2008: 33, 2009: 34, 2010: 35, 4001: 36, 4002: 37, 4003: 38, } if level_id not in mapping: raise ValueError( f"Level ID [{level_id}] is not known to be official.") song_id, (name, stars, str_diff, coins, length) = ( translate.get(level_id, level_id), mapping[level_id], ) creator, song = ( AbstractUser(client=client), Song.official(song_id, server_style=False, client=client), ) is_demon = "demon" in str_diff if is_demon: difficulty = DemonDifficulty.from_value(str_diff) else: difficulty = LevelDifficulty.from_value(str_diff) return cls( id=level_id, name=name, description=f"Official Level: {name}", version=1, creator=creator, song=song, data= "", # XXX: maybe we can dump all official levels and load their data password=None, copyable=False, is_demon=is_demon, is_auto=(str_diff == "auto"), difficulty=difficulty, stars=stars, coins=coins, verified_coins=True, is_epic=False, # XXX: are Rob's levels epic? ~ nekit original=True, # would be fun if this was false haha low_detail_mode=False, downloads=0, rating=0, score=1, uploaded_timestamp="unknown", last_updated_timestamp="unknown", length=length, game_version=21, stars_requested=0, object_count=0, type=0, time_n=-1, cooldown=-1, client=client, )
def __init__( self, strategy: Union[int, str, SearchStrategy] = 0, difficulty: Optional[Sequence[Union[int, str, LevelDifficulty]]] = None, demon_difficulty: Optional[Union[int, str, DemonDifficulty]] = None, length: Optional[Union[int, str, LevelLength]] = None, uncompleted: bool = False, only_completed: bool = False, completed_levels: Optional[Sequence[Union[int, Level]]] = None, require_coins: bool = False, featured: bool = False, epic: bool = False, rated: Optional[bool] = None, require_two_player: bool = False, song_id: Optional[int] = None, use_custom_song: bool = False, require_original: bool = False, followed: Optional[Sequence[Union[int, AbstractUser]]] = None, ) -> None: if isinstance(difficulty, (int, str, Enum)): difficulty = [difficulty] if isinstance(length, (int, str, Enum)): length = [length] self.strategy = SearchStrategy.from_value(strategy) not_accepting = self.strategy.value in (5, 6, 16) self.difficulty = (None if ((difficulty is None) or not_accepting) else tuple( map(LevelDifficulty.from_value, difficulty))) self.length = (None if ((length is None) or not_accepting) else tuple( map(LevelLength.from_value, length))) self.demon_difficulty = (None if ((demon_difficulty is None) or not_accepting) else DemonDifficulty.from_value(demon_difficulty)) if self.demon_difficulty is not None: self.difficulty = (LevelDifficulty.DEMON, ) self.uncompleted = uncompleted if completed_levels else False self.only_completed = only_completed if completed_levels else False self.completed_levels = list(completed_levels or []) self.require_coins = require_coins self.require_two_player = require_two_player self.rated = rated self.featured = featured self.epic = epic self.song_id = song_id self.use_custom_song = use_custom_song self.followed = list(followed or []) self.require_original = require_original self.set = ( "strategy", "difficulty", "demon_difficulty", "length", "uncompleted", "only_completed", "completed_levels", "require_coins", "require_two_player", "rated", "featured", "epic", "song_id", "use_custom_song", "followed", "require_original", )