Esempio n. 1
0
        def func_gen(emoji, ind):
            async def ret_func(self, payload):
                self.game.move(ind, self.players[self.turn][1])
                await self.message.edit(**self.edit_board())
                self.turn = 0 if self.turn else 1

            return menus.Button(emoji, ret_func)
Esempio n. 2
0
 def __init__(
     self,
     source: menus.PageSource,
     cog: commands.Cog,
     user_token: tekore.Token,
     clear_reactions_after: bool = True,
     delete_message_after: bool = False,
     timeout: int = 60,
     message: discord.Message = None,
     **kwargs: Any,
 ) -> None:
     super().__init__(
         source,
         clear_reactions_after=clear_reactions_after,
         delete_message_after=delete_message_after,
         timeout=timeout,
         message=message,
         **kwargs,
     )
     self.user_token = user_token
     self.cog = cog
     self.add_button(
         menus.Button(emoji_handler.get_emoji("next"), self.skip_next, position=menus.First(6))
     )
     self.add_button(
         menus.Button(
             emoji_handler.get_emoji("previous"), self.skip_previous, position=menus.First(0)
         )
     )
     self.add_button(
         menus.Button(
             emoji_handler.get_emoji("playpause"), self.play_pause, position=menus.First(2)
         )
     )
     self.add_button(
         menus.Button(
             emoji_handler.get_emoji("playall"),
             self.play_pause_all,
             position=menus.First(3),
             skip_if=self._skip_play_all,
         )
     )
     self.add_button(
         menus.Button(emoji_handler.get_emoji("like"), self.like_song, position=menus.First(4))
     )
     self.add_button(
         menus.Button(
             emoji_handler.get_emoji("back_left"),
             self.go_to_previous_page,
             position=menus.First(1),
         )
     )
     self.add_button(
         menus.Button(
             emoji_handler.get_emoji("play"), self.go_to_next_page, position=menus.First(5)
         )
     )
Esempio n. 3
0
 def __init__(self, cog, game: Connect4Game):
     self.cog = cog
     self.game = game
     super().__init__(
         timeout=self.GAME_TIMEOUT_THRESHOLD,
         delete_message_after=False,
         clear_reactions_after=True,
     )
     for index, digit in enumerate(self.DIGITS):
         self.add_button(
             menus.Button(digit, self.handle_digit_press, position=menus.First(index))
         )
Esempio n. 4
0
    def __init__(self, p1: tuple, p2: tuple, isembed: bool, **kwargs):
        super().__init__(**kwargs)
        self.players = [
            (p1[0], "x", p1[1]),
            (p2[0], "o", p2[1]),
        ]
        self.turn = 0  # 0 = player 1,  1 = player 2
        self.game = Game(True)
        self.isembed = isembed

        mapper = [
            [
                "\N{NORTH WEST ARROW}", "\N{UPWARDS BLACK ARROW}",
                "\N{NORTH EAST ARROW}"
            ],
            [
                "\N{LEFTWARDS BLACK ARROW}",
                "\N{BLACK CIRCLE FOR RECORD}",
                "\N{BLACK RIGHTWARDS ARROW}",
            ],
            [
                "\N{SOUTH WEST ARROW}", "\N{DOWNWARDS BLACK ARROW}",
                "\N{SOUTH EAST ARROW}"
            ],
        ]

        def func_gen(emoji, ind):
            async def ret_func(self, payload):
                self.game.move(ind, self.players[self.turn][1])
                await self.message.edit(**self.edit_board())
                self.turn = 0 if self.turn else 1

            return menus.Button(emoji, ret_func)

        for i in range(3):
            for j in range(3):
                self.add_button(func_gen(mapper[i][j], (i, j)))

        async def on_stop(self, payload):
            self.stop()

        self.add_button(menus.Button("⏹️", on_stop))