示例#1
0
    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)
示例#2
0
    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,
        )
示例#3
0
 def difficulty(self) -> LevelDifficulty:
     """:class:`.LevelDifficulty`: Average difficulty of a map pack."""
     return LevelDifficulty.from_value(self.options.get("difficulty", -1))
示例#4
0
文件: level.py 项目: scottwedge/gd.py
    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,
        )