aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/tic_tac_toe.py
blob: 0fa1902bdd9d082f7bfa25da176e23bc335ea0ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import typing as t

import discord
from discord.ext.commands import Cog, Context

from bot.bot import SeasonalBot


class Player:
    """Class that contains information about player and functions that interact with player."""

    def __init__(self, user: discord.User, ctx: Context):
        self.user = user
        self.ctx = ctx


class Game:
    """Class that contains information and functions about Tic Tac Toe game."""

    def __init__(self, channel: discord.TextChannel, players: t.List[Player], ctx: Context):
        self.channel = channel
        self.players = players
        self.ctx = ctx

        self.current = self.players[0]
        self.next = self.players[1]

        self.winner: t.Optional[Player] = None
        self.loser: t.Optional[Player] = None


class TicTacToe(Cog):
    """TicTacToe cog contains tic-tac-toe game commands."""

    def __init__(self, bot: SeasonalBot):
        self.bot = bot


def setup(bot: SeasonalBot) -> None:
    """Load TicTacToe Cog."""
    bot.add_cog(TicTacToe(bot))