-
Notifications
You must be signed in to change notification settings - Fork 165
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
Add a currency along with various uses #296
base: master
Are you sure you want to change the base?
Conversation
This reverts commit 3c2d869.
Added ability to trade with coins
Mention me when this is ready for review. Wanna have a second pair of eyes on it. |
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 issue from packages/trade/menu#L318
has to be fixed before this can be merged.
if self.coins < amount: | ||
raise ValueError("Not enough coins") | ||
self.coins -= amount | ||
await self.save(update_fields=("coins",)) |
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.
add_coins
and remove_coins
should probably return some output on its status as confirmation.
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.
I think raising an error is appropriate as a way to confirm things went well
@@ -621,6 +621,44 @@ async def count( | |||
f"{country}{settings.collectible_name}{plural}{guild}." | |||
) | |||
|
|||
@app_commands.command() | |||
async def dispose(self, interaction: discord.Interaction, ball: BallInstanceTransform): |
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.
Not sure if dispose
is the best naming for this command, it seems a bit negative. perhaps exchange
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.
dispose
sounds fine to me, exchange
may be confused with trading. What about sell
maybe?
Added a way to add or remove coins from a user
About the wandering trader it would be better to make a separate pr for it after coin have been merge. Mainly to evaluate how much members value the coin to give the set value for shops! |
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 pr also breaks the trade display and that needs some fixes
Co-authored-by: imtherealF1 <[email protected]>
Co-authored-by: imtherealF1 <[email protected]>
Co-authored-by: imtherealF1 <[email protected]>
Co-authored-by: imtherealF1 <[email protected]>
Co-authored-by: imtherealF1 <[email protected]>
Co-authored-by: imtherealF1 <[email protected]>
Putting this as DRAFT again, i will run through all the changes myself and fix some broken stuff. |
this is my idea :( |
except i used different command names |
also, if config.yml isn't updated hence no rarities, /dispose will give a |
@OLi51 This was considered since before Ballsdex was even released to the public. We haven't looked for any fork or other code for getting inspirations (unless they bring it up to us as suggestions), and besides it's not hard to get that kind of idea. I don't really understand the goal of your comment? You don't have any code uploaded, there's no contribution from you. If you want to add features, you are free and welcome to open pull requests, then you'll be properly credited. I find it kinda sad to see people developing private features for themselves and wanting exclusivity, when I want to encourage sharing and contributions, that's why the bot is open source to begin with. |
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.
Copilot reviewed 5 out of 13 changed files in this pull request and generated 1 comment.
Files not reviewed (8)
- migrations/models/36_20241015161531_update.sql: Language not supported
- ballsdex/packages/trade/display.py: Evaluated as low risk
- ballsdex/packages/countryballs/components.py: Evaluated as low risk
- ballsdex/core/utils/enums.py: Evaluated as low risk
- ballsdex/packages/trade/trade_user.py: Evaluated as low risk
- ballsdex/settings.py: Evaluated as low risk
- ballsdex/core/admin/resources.py: Evaluated as low risk
- ballsdex/core/models.py: Evaluated as low risk
Comments suppressed due to low confidence (3)
ballsdex/packages/trade/menu.py:203
- The comment should be 'updates every 5 seconds'.
A loop task that updates each 5 second the menu with the new content.
ballsdex/packages/trade/menu.py:308
- The error message for InvalidTradeOperation should be more descriptive.
raise InvalidTradeOperation()
ballsdex/packages/trade/menu.py:333
- The comment should be 'This is an invalid mutation'.
// This is a invalid mutation, the player is not the owner of the countryball
Co-authored-by: imtherealF1 <[email protected]>
if self.coins < amount: | ||
raise ValueError("Not enough coins") | ||
self.coins -= amount | ||
await self.save(update_fields=("coins",)) |
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.
I think raising an error is appropriate as a way to confirm things went well
user: discord.User | None = None, | ||
user_id: str | None = None, | ||
amount: int = 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.
amount
should be a required parameter
user: discord.User | None = None, | |
user_id: str | None = None, | |
amount: int = 0, | |
amount: int, | |
user: discord.User | None = None, | |
user_id: str | None = None, |
user: discord.User | None = None, | ||
user_id: str | None = None, | ||
amount: int = 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.
Same here
user: discord.User | None = None, | |
user_id: str | None = None, | |
amount: int = 0, | |
amount: int, | |
user: discord.User | None = None, | |
user_id: str | None = None, |
@@ -621,6 +621,44 @@ async def count( | |||
f"{country}{settings.collectible_name}{plural}{guild}." | |||
) | |||
|
|||
@app_commands.command() | |||
async def dispose(self, interaction: discord.Interaction, ball: BallInstanceTransform): |
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.
dispose
sounds fine to me, exchange
may be confused with trading. What about sell
maybe?
self.coins -= amount | ||
|
||
async def fetch_player_coins(self) -> int: | ||
player, _ = await Player.get_or_create(discord_id=self.user.id) |
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.
Makes the query a little lighter. Could also reuse the existing Player model and call .refresh_from_db
player, _ = await Player.get_or_create(discord_id=self.user.id) | |
player, _ = await Player.get_or_create(discord_id=self.user.id).only("coins") |
self.initial_coins_trader1 = trader1.coins | ||
self.initial_coins_trader2 = trader2.coins |
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.
These attributes are unused
Adds a currency (configurable name in config).
TODO:
balls dispose
- dispose of a ball for 1/2 the worth.player balance
to view your balance.Future work for later additions: