Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
76e736f
Add files via upload
andrewthederp Feb 7, 2022
f09047c
fixed bugs and made register_commands async
andrewthederp Mar 25, 2022
6f626a4
bumped version to 2.3.1
andrewthederp Mar 25, 2022
2f2ec6c
Update __init__.py
andrewthederp Mar 25, 2022
3cb513d
Update __init__.py
andrewthederp Mar 25, 2022
f8a1ea2
Add files via upload
andrewthederp Jul 2, 2022
48bbf37
Delete examples directory
andrewthederp Jul 2, 2022
886d192
Delete mkdocs.yml
andrewthederp Jul 2, 2022
2143f48
Delete tests directory
andrewthederp Jul 2, 2022
a8b8baf
Delete docs directory
andrewthederp Jul 2, 2022
616cd10
Delete build/lib/disgames directory
andrewthederp Jul 2, 2022
afc04c2
Delete errors.py
andrewthederp Jul 2, 2022
4d9926a
Delete constants.py
andrewthederp Jul 2, 2022
9a5617f
Delete cog.py
andrewthederp Jul 2, 2022
85d74a2
Delete disgames/mixins directory
andrewthederp Jul 2, 2022
7840ee2
fixed whoopsie oopsie
andrewthederp Jul 2, 2022
54f906f
Create test.py
andrewthederp Jul 2, 2022
4d08f8d
Update and rename test.py to __init__.py
andrewthederp Jul 2, 2022
99d3618
Delete words.txt
andrewthederp Jul 2, 2022
5e9c15c
words.txt
andrewthederp Jul 2, 2022
a3d563e
Update setup.py
andrewthederp Jul 2, 2022
2062faa
Add files via upload
andrewthederp Jul 2, 2022
51331bf
Update README.md
andrewthederp Jul 2, 2022
f2993aa
Update README.md
andrewthederp Jul 2, 2022
e95f04b
Update README.md
andrewthederp Jul 2, 2022
a82c176
Update README.md
andrewthederp Jul 2, 2022
5a0a7ce
Update README.md
andrewthederp Jul 2, 2022
e1fc465
Add files via upload
andrewthederp Jul 2, 2022
f91ec9c
Add files via upload
andrewthederp Jul 2, 2022
c7efcd4
Add files via upload
andrewthederp Jul 3, 2022
c8467a1
Add files via upload
andrewthederp Jul 3, 2022
ddbffaf
Added a way to find the game winner
andrewthederp Jul 3, 2022
2b0f068
Added documentation for winnings
andrewthederp Jul 3, 2022
7da16fd
Update README.md
andrewthederp Jul 3, 2022
dbf777e
fixed import errors
andrewthederp Jul 4, 2022
cd2fe7f
Update hangman.py
andrewthederp Jul 4, 2022
aae15ed
Update soko.py
andrewthederp Jul 4, 2022
4876c54
Add files via upload
andrewthederp Jul 4, 2022
bfe7007
Delete disgames directory
andrewthederp Jul 4, 2022
31613d7
Delete __main__.py
andrewthederp Jul 4, 2022
70063a8
Delete __init__.py
andrewthederp Jul 4, 2022
695a261
Delete reaction_games directory
andrewthederp Jul 4, 2022
a32804e
Delete message_games directory
andrewthederp Jul 4, 2022
35df869
Delete button_games directory
andrewthederp Jul 4, 2022
d4fb081
fixed an oopsie whoopsie
andrewthederp Jul 4, 2022
686589f
Add files via upload
andrewthederp Jul 11, 2022
811da00
Add files via upload
andrewthederp Jul 11, 2022
252d98d
Add files via upload
andrewthederp Jul 11, 2022
1ffe1a3
Add files via upload
andrewthederp Jul 12, 2022
6184867
Add files via upload
andrewthederp Jul 12, 2022
f6c5294
Add files via upload
andrewthederp Jul 12, 2022
99db536
Add files via upload
andrewthederp Jul 12, 2022
9e70831
Add files via upload
andrewthederp Jul 14, 2022
63c6afb
Add files via upload
andrewthederp Jul 15, 2022
3119fa7
Add files via upload
andrewthederp Jul 15, 2022
46ab5e7
Add files via upload
andrewthederp Jul 15, 2022
360e176
Add files via upload
andrewthederp Jul 15, 2022
77a8bbf
Update hangman.py
andrewthederp Jul 15, 2022
a824e7f
missed a `,`
andrewthederp Jul 16, 2022
8b0af80
Update chess.py
andrewthederp Jul 16, 2022
48a7a1d
Small fix
andrewthederp Jul 16, 2022
4633706
Add files via upload
andrewthederp Jul 16, 2022
397a76c
Update hangman.py
andrewthederp Jul 16, 2022
e812856
Update hangman.py
andrewthederp Jul 16, 2022
3af0b32
Update hangman.py
andrewthederp Jul 16, 2022
02ac130
Update hangman.py
andrewthederp Jul 16, 2022
7a74a93
Update hangman.py
andrewthederp Jul 16, 2022
8252b0a
Update hangman.py
andrewthederp Jul 16, 2022
5e34dc3
Update hangman.py
andrewthederp Jul 16, 2022
0fb51da
Fixed bug where hangman image would not appear
andrewthederp Jul 17, 2022
16b6acc
Update tictactoe.py
andrewthederp Jul 17, 2022
6c2a6c8
Added better formatting
andrewthederp Jul 18, 2022
a298f23
Fixed small mistake
andrewthederp Jul 18, 2022
9f5b397
Fixed issue
andrewthederp Jul 18, 2022
e2df5a5
Fixed mistake
andrewthederp Jul 18, 2022
b9faa3d
Update chess.py
andrewthederp Jul 18, 2022
5117e9d
Update chess.py
andrewthederp Jul 18, 2022
ccd64c1
Fixing more stupid mistakes
andrewthederp Jul 18, 2022
e5189bd
akinator.py got deleted :(
andrewthederp Aug 15, 2022
99baa77
Update __init__.py
andrewthederp Aug 16, 2022
6b82374
Update __init__.py
andrewthederp Aug 16, 2022
877c2e6
Update __init__.py
andrewthederp Aug 16, 2022
cd62c47
re-adding akinator
andrewthederp Nov 18, 2022
cf435ff
re-adding akinator
andrewthederp Nov 18, 2022
4bae0f1
Update __init__.py
andrewthederp Nov 18, 2022
c639f2b
re-adding akinator
andrewthederp Nov 18, 2022
3c982bc
Update wordle.py
andrewthederp Jul 10, 2023
0ab767b
Merge pull request #28 from andrewthederp/andrewthederp-patch-1
andrewthederp Jul 10, 2023
e14fc46
Update setup.py
andrewthederp Jul 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<p align="center">
<img src="./docs/src/disgames.png" height="125px" width="125px" />
</p>

<h1 align="center">Disgames</h1>
A python module made to make creating games easier and adds a bunch of game commands to your discord python bot

---
Note: The logo has been designed by using resources from [flaticon.com](https://www.flaticon.com/)


## Contents

- [Disgames](#disgames)
- [Contents](#contents)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Winnings](#winnings)
- [Example](#example)
- [Extra](#extra)

## Installation
Expand All @@ -33,31 +28,36 @@ pip install git+https://github.com/andrewthederp/Disgames

## Usage

You can either load it as an extension by doing

```py
from discord.ext import commands

bot = commands.Bot("YOUR_PREFIX_HERE")

bot.load_extension("disgames")
```

or call the `register_commands` function manually by doing

```py
from disgames import register_commands
from discord.ext import commands

bot = commands.Bot("YOUR_PREFIX_HERE")
register_commands(bot)
```

More examples on customizing the commands added to your bot can be seen in [`examples/`](./examples/)

And that's it! now your bot has the games implemented in [`disgames/mixins/`](./disgames/mixins/)
- Import the class of the game you want from the controls type you want
- E.g. `from disgames.button_games import Chess`
- Create an instance of the class while providing the necessary args/kwargs
- E.g. `game = Chess(ctx, white=ctx.author, black=member)`
- Start the game by running the start function and providing the necessary args/kwargs
- E.g. `game.start(end_game_option=True)`

More examples can be seen in [`examples/`](./examples/)

## Configuration
You can configure some variables that are used throughout the module
- `disgames.ongoing_game_color` The color of the embed while the game is still running
- `disgames.lost_game_color` The color of the embed when the player looses (only used in singleplayer games)
- `disgames.won_game_color` The color of the embed when the player wins
- `isgames.drawn_game_color` The color of the embed when the game draws
- `disgames.resend_embed_list` A list of strings, if the player sends a message which is in the list. The game embed will be re-sent (only used in message games)
- `disgames.end_game_list` A list of strings, if the player sends a message which is in the list. The game will end (only used in message games)

Example of changing a variable: `disgames.drawn_game_color = 0x000000`

## Winnings
The start function will return any of `discord.Member`/`True`/`False`/`None`/`list`/`0`
- `True`/`False` will only be returned if the game is a single player game and it means the author has won/lost
- `None` means the game has ended in a draw
- `discord.Member` means that that person has won the game
- `list` would be a list of bools, this is only returned by `Soko`. A `True` will be added into the list for every game the user wins. And the last item in the list will always be `False` if `play_forever` is set to `True`
- `0` means that the game timed out

## Examples
Coming soon!

## Extra

Note that this works with the now discontinued module [discord.py](https://pypi.org/project/discord.py) and we
will make it compatible with other modules as soon as possible
Note that this package only works with [discord.py](https://pypi.org/project/discord.py) and other modules that use the `discord` namespace
69 changes: 32 additions & 37 deletions disgames/__init__.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
from .cog import *
from .constants import *
from discord.ext import commands
from .errors import PathNotFound
from .mixins import TicTacToe, TicTacToeReactions
from typing import NamedTuple
buttons = False
try:
from discord.ui import Button
from discord.ui import View
buttons = True
except ImportError:
pass
import discord

resend_embed_list = ['re-send','resend']
end_game_list = ['end','stop','quit']

ongoing_game_color = discord.Color.blurple()
lost_game_color = discord.Color.red()
won_game_color = discord.Color.green()
drawn_game_color = discord.Color.red()

__title__ = 'disgames'
__author__ = 'andrewthederp'
__license__ = 'Apache License 2.0'
__copyright__ = 'Copyright 2021-2022 Andrewthederp and MarzaElise'
__version__ = '2.3.0'

def register_commands(
bot, *, ignore: list = [], stockfish_path=None, ttt_reactions=False, button_commands=True
):
if button_commands:
ignore.extend(BUTTON_GAMES if not buttons else NON_BUTTON_GAMES)
else:
ignore.extend(BUTTON_GAMES)
games = []
if ttt_reactions:
ignore.append(TicTacToe)
ignore.append(TicTacToeButtons)
games.append(TicTacToeReactions)
games += [game for game in ALL_GAMES if game not in ignore]

class Games(*games):
def __init__(self, bot):
for cls in games:
cls.__init__(self, bot)

g = Games(bot)
if stockfish_path:
g.stockfish_path = stockfish_path
bot.add_cog(g)
__version__ = '3.0.0'

def enable_better_formatting():
import os
os.system('pip install git+https://github.com/andrewthederp/FormatGame')
try:
import format_game
return 1
except ImportError:
return 0

class FormatType:
plain = 0
plain_codeblock = 1

listed = 2
listed_codeblock = 3

emojis = 4
emojis_codeblock = 5

image = 6

text = 7

class VersionInfo(NamedTuple):
major: int
Expand Down
23 changes: 5 additions & 18 deletions disgames/__main__.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
import aiohttp
import argparse
import chess
import disgames
import platform
import sys
from __init__ import VersionInfo
from typing import Tuple
import chess
import akinator
import sys

VersionInfo = disgames.VersionInfo

def version() -> None:
entries = [
'- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(
sys.version_info
)
]

entries = []

version_info: VersionInfo = VersionInfo(major=2, minor=0, micro=1)
entries.append('- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(sys.version_info))
version_info: VersionInfo = VersionInfo(major=3, minor=0, micro=0)
entries.append('- Disgames v{0.major}.{0.minor}.{0.micro}'.format(version_info))
entries.append(f'- aiohttp v{aiohttp.__version__}')
entries.append(f'- aiohttp v{aiohttp.__version__}')
entries.append(f'- Chess v{chess.__version__}')
entries.append(f'- Akinator v{akinator.__version__}')

uname = platform.uname()
entries.append('- System Info: {0.system} {0.release} {0.version}'.format(uname))
print('\n'.join(entries))

def show_version(parser, args) -> None:
if args.version:
Expand Down
Binary file added disgames/assets/arialbd.ttf
Binary file not shown.
Binary file added disgames/assets/wordle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading