-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sincere Singularities #8
base: main
Are you sure you want to change the base?
Conversation
- Set up some pre-commit hooks (including mypy) - Add some ruff & mypy config - Remove the samples directory Signed-off-by: koviubi56 <[email protected]>
`check-illegal-windows-names` isn't released yet. Signed-off-by: koviubi56 <[email protected]>
- Setup first Basic ReadMe - Remove Docs from Dev Requirements - Add Requirements.txt (with Disnake Requirement) - Setup Basic Disnake Template main.py
Basic Setup of Disnake
* Package code and clean up - It's generally best practice to package python projects, so this commit does that using setuptools. - Clean up and update the README. - Use python-dotenv for loading .env variables at runtime - Clean up bot code Signed-off-by: koviubi56 <[email protected]> * Format code Signed-off-by: koviubi56 <[email protected]> * Remove 3.12 Signed-off-by: koviubi56 <[email protected]> --------- Signed-off-by: koviubi56 <[email protected]>
* Restaurant Chooser View - Implemented /start_game command - Implemented First Basic (template) restaurants.json - Implemented Restaurants Chooser View - Implemented Basic Restaurant Class TODOS: - Add Docstrings/Comments - Refine Restaurants Embed - Implement Restaurant Menu - (Add Typing Hint) * Fix Typing / Linting Issues * Fixed Reviews
- Implemented Custom Colors (Based on Icon) - Added some Template Menu Items - Added a Example Items Section to the Restaurant overview - Added Proper Type Handling when Loading the JSON
* GUI based Orders are almost done. - Refractored some of the Code (Structure) - Added Ordering Menu Selection Screen - Added Order Check - Implemented better Colors Co-Authored-By: koviubi56 <[email protected]> * Fix Linting Issues Co-Authored-By: koviubi56 <[email protected]> * Remove Unused Type: Ignore Co-Authored-By: koviubi56 <[email protected]> * Fix Formatting Co-Authored-By: koviubi56 <[email protected]> * Simplify List Comprehension Co-authored-by: koviubi56 <[email protected]> * Update CustomerInfo Dataclass Infrastructure Note: We need frozen=True to make the dataclass hashable to use comparisons. Co-Authored-By: koviubi56 <[email protected]> * Fix Formatting --------- Co-authored-by: koviubi56 <[email protected]>
* Add `check_similarity` This function returns the similarity of two strings. Signed-off-by: koviubi56 <[email protected]> * Add `compare_sentences` Measure of the strings' similarity as a float using Sentence Transformer's MiniLM. Signed-off-by: koviubi56 <[email protected]> --------- Signed-off-by: koviubi56 <[email protected]>
* Implement Content Checks. - Implemented `check_pattern_similarity` and `compare_sentences` in `Restaurant.check_order` * Add Numpy Versioning Requirement * Fix Formatting
Generates a random "notionists" (CC0) Dicebear avatar image URL. Signed-off-by: koviubi56 <[email protected]>
- Added clear_webhooks and clear_threads commands - Improved Error/Success Messages
* Add points and buying restaurants First restaurant is unlocked, every other one requires some points. After completing an order, the user gets `round(correctness * 10)` points. Signed-off-by: koviubi56 <[email protected]> * Add docstrings Signed-off-by: koviubi56 <[email protected]> --------- Signed-off-by: koviubi56 <[email protected]>
* Order Conditions - Implemented Various Order Conditions - Improved Naming - Small Fixes Co-Authored-By: koviubi56 <[email protected]> * Fix Debug-Statements, Problems --------- Co-authored-by: koviubi56 <[email protected]>
- Add better comments and docstrings. - Fix some errors. - Better type hinting. - Other misc. refactoring. Signed-off-by: koviubi56 <[email protected]>
* Various Quality of Life Improvements - Added Order Generator - Improved Code Flow - Added New Features Co-Authored-By: BSP <[email protected]> Co-Authored-By: koviubi56 <[email protected]> * Fixed some Linting Errors * Fix Linting * Add docstrings * Fix Formatting * points.py default points to 0 Co-authored-by: koviubi56 <[email protected]> * Fix Changes --------- Co-authored-by: BSP <[email protected]> Co-authored-by: koviubi56 <[email protected]>
* Add automatic difficulty changing Signed-off-by: koviubi56 <[email protected]> * Fix formatting Signed-off-by: koviubi56 <[email protected]> * Store number of orders in (temporary) database Signed-off-by: koviubi56 <[email protected]> --------- Signed-off-by: koviubi56 <[email protected]>
* Add automatic difficulty changing Signed-off-by: koviubi56 <[email protected]> * Fix formatting Signed-off-by: koviubi56 <[email protected]> * Store number of orders in (temporary) database Signed-off-by: koviubi56 <[email protected]> * Add condition frequency based on difficulty Signed-off-by: koviubi56 <[email protected]> --------- Signed-off-by: koviubi56 <[email protected]>
- Applied Black Formatting - Reapplied Ruff Formatting - Opinionated Formatting to match personal style guides
* Add Customer Id to Order Description * Fix MyPy Linting
* Fix Wording/Spelling Errors * Delete Line (Was for next PR)
* NF: Add database functionality * [FT]: Add functionality to save and load game states * Order Conditions (#14) * Order Conditions - Implemented Various Order Conditions - Improved Naming - Small Fixes Co-Authored-By: koviubi56 <[email protected]> * Fix Debug-Statements, Problems --------- Co-authored-by: koviubi56 <[email protected]> * Various Game Improvements (#15) * chore: Update .gitignore and requirements.txt, and remove unused files Update .gitignore to include json files for test cases. Also, update requirements.txt to fix the missing newline at the end of the file. Additionally, remove the unused states.json file. * chore: Update order.py and restaurant.py Update order.py and restaurant.py to import the collections.abc.Iterable module. This ensures compatibility with the latest version of Python. * chore: Update order.py and restaurant.py to import collections.abc.Iterable module * Refactor order.py and restaurant.py to use collections.abc.Iterable module --------- Co-authored-by: Vinyzu <[email protected]> Co-authored-by: koviubi56 <[email protected]>
* Fix Condition Messages - Only Spawn Conditions for owned Restaurants - Delete the Messages using thread.delete_messages (delete_after & message.delete dont work) (- Add .mypy_cache/ to gitignore) * Fix End-Of-Line .gitignore
Note: Every Text we show the user has the text "Extra WishES" to give a Placebo-Information-Overflow effect.
Rename Extra Information to Extra Wish
* Various Game Improvements - Implemented Savestates MongoDB - Implemented States (for Savestates) - Renamed Points to Coins * ReadME is an active TODO. Finish Later * Fix Docstring Typehint State Co-authored-by: koviubi56 <[email protected]> --------- Co-authored-by: koviubi56 <[email protected]>
- Chosen Title: "Restaurant Rush: Kitchen Chaos"
Add Game Title
Signed-off-by: koviubi56 <[email protected]>
Add introduction
Rework Coin Buy Menu if you dont have enough coins
Delete fixed TODOs
Add Restaurant Colors
- TODO: Create Video Presentation and update youtube link
ReadMe Presentation/Documentation
* Improve ReadMe Presentation * Fix Suggestions * Fix ReadMe Hyperlinks
This was approved by the judges.
Fix Order Preview Img URLs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job everyone! You've created a very detailed and rich game that fits the Information Overload theme well 😁.
It's truly impressive to accomplish this much in such a short amount of time with a team of new people.
These comments are intended mostly for future improvement and hopefully give you something useful to take away that you can apply to other projects.
Commits
I like your extensive use of pull requests throughout the project's development. Though a few PRs were quite large, it's understandable given the time crunch you're working with.
Design
I quite like how you've used the split-screen threads view to your advantage to create a UI with controls and information flow. The Views are pretty intuitive, and the order messages being pushed up out of view adds to the difficulty with relation to the theme. However one thing I found lacking was an "exit restaurant" button that I could use in case I've entered the wrong restaurant and have no orders for it.
Code
The code is generally high quality and well formatted across the project. Variables and functions have consistent and meaningful names.
Organization-wise, it would have been easier to review if the game logic and Discord UI implementation were more separated. Perhaps some parts like the coins
and savestates
modules could also be architected in a more object-oriented way with an object representing a Player or something along those lines.
I would have also liked to see the functions and methods make use of positional-only and keyword-only arguments, but this is mostly an API design thing and doesn't affect the functionality much.
Considering the data-driven nature of the app, tests would be a good idea for the core game logic, but again for a code jam that would be going the extra mile.
Documentation
The included docstrings and comments are exhaustive and helpful for the most part, although some are a little redundant.
The Readme is complete with setup and usage instructions and the video presentation does a great job showcasing the functionality and premise of your app.
One nice-to-have would have been a diagram of the game's classes and information flow, as the relationships there look rather complex.
# should be disallowed | ||
raise ValueError(f"User {user_id} already has restaurant {restaurant_name}!") | ||
restaurant = get_restaurant_by_name(restaurant_name) | ||
if get_coins(user_id) - restaurant.coins < 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition could be written more concisely
if get_coins(user_id) - restaurant.coins < 0: | |
if get_coins(user_id) < restaurant.coins: |
@@ -0,0 +1,3 @@ | |||
from setuptools import setup | |||
|
|||
setup() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file necessary if you have pyproject.toml and no extra config in here?
line-length = 119 | ||
# Target Python 3.12. If you decide to use a different version of Python | ||
# you will need to update this value. | ||
target-version = "py312" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be set to py311
to ensure compatibility with your target python version 3.11
. Then you also wouldn't need to ignore rules like UP040
"Topic :: Games/Entertainment", | ||
"Typing :: Typed", | ||
] | ||
dynamic = ["dependencies", "optional-dependencies"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting solution to avoid duplicating the requirements list
@@ -0,0 +1,118 @@ | |||
[build-system] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see a complete pyproject.toml, even in a code jam!
embed.insert_field_at( | ||
index=1, | ||
name=":loudspeaker: :white_check_mark: Info :white_check_mark: :loudspeaker:", | ||
value=f"**Order placed successfully! Correctness: {format(correctness * 100, '.2f')}%.\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value=f"**Order placed successfully! Correctness: {format(correctness * 100, '.2f')}%.\n" | |
value=f"**Order placed successfully! Correctness: {correctness * 100:.2f}%.\n" |
if menu_section := conditions.out_of_stock_sections.get(self.restaurant.name): | ||
embed.add_field( | ||
"Out of stock menu sections", | ||
f"The following menu sections are out of stock: {', '.join(menu_section)}", | ||
inline=False, | ||
) | ||
if sections := conditions.out_of_stock_items.get(self.restaurant.name): | ||
out_of_stock_items = ", ".join([item for menu in sections.values() for item in menu]) | ||
embed.add_field( | ||
"Out of stock menu items", | ||
f"The following menu items are out of stock: {out_of_stock_items}", | ||
inline=False, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see the walrus operator being used too :=)
@disnake.ui.button(label="Pause Orders", style=disnake.ButtonStyle.secondary, row=1) | ||
async def _pause_orders(self, _: disnake.ui.Button, interaction: disnake.MessageInteraction) -> None: | ||
# Placebo Button. Doesn't do anything but looks nice (to give the user feeling of control.) | ||
# This button doesn't do anything because the game ensure the user has 3 orders at all times, so you won't get | ||
# more than 3 orders anyway, and they don't run out. | ||
await interaction.response.defer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever 😆
class StateFormat(TypedDict): | ||
"""Sate format""" | ||
|
||
player_id: str | ||
state: State |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class seems redundant, especially since 1) there already exist methods (save_game_state
) that have the player_id
as a separate arg, and 2) the methods using StateFormat
aren't used anywhere in the codebase anyway
# Creating Orders Thread after initial Message was sent for proper message order. | ||
self.orders_thread = await self.interaction.channel.create_thread( | ||
name="Orders Thread", type=ChannelType.public_thread, invitable=False | ||
) | ||
assert self.orders_thread # MYPY can be stupid at times... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating the thread inside the .new()
classmethod should avoid some of these type issues that Pyright still errors on.
Does "proper message order" mean that the thread creation message must come after the buttons view message? If so, why?
description="Once you gain enough coins, you can buy other restaurants.", | ||
inline=False, | ||
) | ||
interaction.response.send_message(embed=embed, view=IntroductionView()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing an await
embed.add_field( | ||
name="Starting the game", | ||
description="Once you start the game, the orders will be sent as messages in a thread which will be" | ||
" created in this channel. The bot will also send the game menu where you can enter restaurants and" | ||
" add orders. You can buy restaurants with coins, but you already own the first one.", | ||
inline=False, | ||
) | ||
embed.add_field( | ||
name="Adding an order", | ||
description="When you get a new order, select the appropriate restaurant from the menu and enter it." | ||
" Press the buttons to add the menu items that the user requested. Then, input the customer" | ||
" information and click done. You will receive coins based on how correct you were.", | ||
inline=False, | ||
) | ||
embed.add_field( | ||
name="The information overload", | ||
description="The more you play the game, the more difficult it gets. Be quick because being slow will" | ||
" result in penalties!", | ||
inline=False, | ||
) | ||
embed.add_field( | ||
name="Buying restaurants", | ||
description="Once you gain enough coins, you can buy other restaurants.", | ||
inline=False, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description
parameter doesn't exist, it should instead be value
. It seems that mypy wasn't configured correctly so it wasn't able to catch this
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.10.1 | ||
hooks: | ||
- id: mypy | ||
# args: [--strict] # Put config in pyproject.toml. If it doesn't work, put it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting your requirements in additional_dependencies
will allow mypy to type check usage of imported code.
Looks like it wasn't able to catch some issues in bot.py
because it couldn't find the dependencies.
https://github.com/pre-commit/mirrors-mypy?tab=readme-ov-file#using-mypy-with-pre-commit
- repo: https://github.com/pre-commit/mirrors-mypy | |
rev: v1.10.1 | |
hooks: | |
- id: mypy | |
# args: [--strict] # Put config in pyproject.toml. If it doesn't work, put it here. | |
- repo: https://github.com/pre-commit/mirrors-mypy | |
rev: v1.10.1 | |
hooks: | |
- id: mypy | |
additional_dependencies: | |
- disnake~=2.9.2 | |
- python-dotenv~=1.0.1 | |
- dacite~=1.8.1 | |
- pymongo~=4.8.0 | |
- torch~=2.3.1 | |
- sentence-transformers~=3.0.1 | |
- transformers~=4.43.2 | |
- numpy<2 | |
- faker~=26.0.0 |
No description provided.