mirror of https://github.com/stijndcl/didier
Remove old code
parent
3ca4520e56
commit
07b356bff2
|
@ -6,11 +6,6 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from database.crud import users
|
from database.crud import users
|
||||||
from database.exceptions import currency as exceptions
|
from database.exceptions import currency as exceptions
|
||||||
from database.schemas import Bank, NightlyData
|
from database.schemas import Bank, NightlyData
|
||||||
from database.utils.math.currency import (
|
|
||||||
capacity_upgrade_price,
|
|
||||||
interest_upgrade_price,
|
|
||||||
rob_upgrade_price,
|
|
||||||
)
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"add_dinks",
|
"add_dinks",
|
||||||
|
@ -18,13 +13,10 @@ __all__ = [
|
||||||
"get_bank",
|
"get_bank",
|
||||||
"get_nightly_data",
|
"get_nightly_data",
|
||||||
"invest",
|
"invest",
|
||||||
"upgrade_capacity",
|
|
||||||
"upgrade_interest",
|
|
||||||
"upgrade_rob",
|
|
||||||
"NIGHTLY_AMOUNT",
|
"NIGHTLY_AMOUNT",
|
||||||
]
|
]
|
||||||
|
|
||||||
NIGHTLY_AMOUNT = 420
|
NIGHTLY_AMOUNT = 50
|
||||||
|
|
||||||
|
|
||||||
async def get_bank(session: AsyncSession, user_id: int) -> Bank:
|
async def get_bank(session: AsyncSession, user_id: int) -> Bank:
|
||||||
|
@ -81,57 +73,3 @@ async def claim_nightly(session: AsyncSession, user_id: int):
|
||||||
session.add(bank)
|
session.add(bank)
|
||||||
session.add(nightly_data)
|
session.add(nightly_data)
|
||||||
await session.commit()
|
await session.commit()
|
||||||
|
|
||||||
|
|
||||||
async def upgrade_capacity(session: AsyncSession, user_id: int) -> int:
|
|
||||||
"""Upgrade capacity level"""
|
|
||||||
bank = await get_bank(session, user_id)
|
|
||||||
upgrade_price = capacity_upgrade_price(bank.capacity_level)
|
|
||||||
|
|
||||||
# Can't afford this upgrade
|
|
||||||
if upgrade_price > bank.dinks:
|
|
||||||
raise exceptions.NotEnoughDinks
|
|
||||||
|
|
||||||
bank.dinks -= upgrade_price
|
|
||||||
bank.capacity_level += 1
|
|
||||||
|
|
||||||
session.add(bank)
|
|
||||||
await session.commit()
|
|
||||||
|
|
||||||
return bank.capacity_level
|
|
||||||
|
|
||||||
|
|
||||||
async def upgrade_interest(session: AsyncSession, user_id: int) -> int:
|
|
||||||
"""Upgrade interest level"""
|
|
||||||
bank = await get_bank(session, user_id)
|
|
||||||
upgrade_price = interest_upgrade_price(bank.interest_level)
|
|
||||||
|
|
||||||
# Can't afford this upgrade
|
|
||||||
if upgrade_price > bank.dinks:
|
|
||||||
raise exceptions.NotEnoughDinks
|
|
||||||
|
|
||||||
bank.dinks -= upgrade_price
|
|
||||||
bank.interest_level += 1
|
|
||||||
|
|
||||||
session.add(bank)
|
|
||||||
await session.commit()
|
|
||||||
|
|
||||||
return bank.interest_level
|
|
||||||
|
|
||||||
|
|
||||||
async def upgrade_rob(session: AsyncSession, user_id: int) -> int:
|
|
||||||
"""Upgrade rob level"""
|
|
||||||
bank = await get_bank(session, user_id)
|
|
||||||
upgrade_price = rob_upgrade_price(bank.rob_level)
|
|
||||||
|
|
||||||
# Can't afford this upgrade
|
|
||||||
if upgrade_price > bank.dinks:
|
|
||||||
raise exceptions.NotEnoughDinks
|
|
||||||
|
|
||||||
bank.dinks -= upgrade_price
|
|
||||||
bank.rob_level += 1
|
|
||||||
|
|
||||||
session.add(bank)
|
|
||||||
await session.commit()
|
|
||||||
|
|
||||||
return bank.rob_level
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import math
|
|
||||||
|
|
||||||
__all__ = ["capacity_upgrade_price", "interest_upgrade_price", "rob_upgrade_price"]
|
|
||||||
|
|
||||||
|
|
||||||
def interest_upgrade_price(level: int) -> int:
|
|
||||||
"""Calculate the price to upgrade your interest level"""
|
|
||||||
base_cost = 600
|
|
||||||
growth_rate = 1.8
|
|
||||||
|
|
||||||
return math.floor(base_cost * (growth_rate**level))
|
|
||||||
|
|
||||||
|
|
||||||
def capacity_upgrade_price(level: int) -> int:
|
|
||||||
"""Calculate the price to upgrade your capacity level"""
|
|
||||||
base_cost = 800
|
|
||||||
growth_rate = 1.6
|
|
||||||
|
|
||||||
return math.floor(base_cost * (growth_rate**level))
|
|
||||||
|
|
||||||
|
|
||||||
def rob_upgrade_price(level: int) -> int:
|
|
||||||
"""Calculate the price to upgrade your rob level"""
|
|
||||||
base_cost = 950
|
|
||||||
growth_rate = 1.9
|
|
||||||
|
|
||||||
return math.floor(base_cost * (growth_rate**level))
|
|
|
@ -4,12 +4,7 @@ import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from database.crud import currency as crud
|
from database.crud import currency as crud
|
||||||
from database.exceptions.currency import DoubleNightly, NotEnoughDinks
|
from database.exceptions.currency import DoubleNightly
|
||||||
from database.utils.math.currency import (
|
|
||||||
capacity_upgrade_price,
|
|
||||||
interest_upgrade_price,
|
|
||||||
rob_upgrade_price,
|
|
||||||
)
|
|
||||||
from didier import Didier
|
from didier import Didier
|
||||||
from didier.utils.discord.checks import is_owner
|
from didier.utils.discord.checks import is_owner
|
||||||
from didier.utils.discord.converters import abbreviated_number
|
from didier.utils.discord.converters import abbreviated_number
|
||||||
|
@ -59,61 +54,6 @@ class Currency(commands.Cog):
|
||||||
|
|
||||||
await ctx.reply(embed=embed, mention_author=False)
|
await ctx.reply(embed=embed, mention_author=False)
|
||||||
|
|
||||||
@bank.group( # type: ignore[arg-type]
|
|
||||||
name="upgrade", aliases=["u", "upgrades"], case_insensitive=True, invoke_without_command=True
|
|
||||||
)
|
|
||||||
async def bank_upgrades(self, ctx: commands.Context):
|
|
||||||
"""List the upgrades you can buy & their prices."""
|
|
||||||
async with self.client.postgres_session as session:
|
|
||||||
bank = await crud.get_bank(session, ctx.author.id)
|
|
||||||
|
|
||||||
embed = discord.Embed(title="Bank upgrades", colour=discord.Colour.blue())
|
|
||||||
|
|
||||||
embed.add_field(
|
|
||||||
name=f"Interest ({bank.interest_level})", value=str(interest_upgrade_price(bank.interest_level))
|
|
||||||
)
|
|
||||||
embed.add_field(
|
|
||||||
name=f"Capacity ({bank.capacity_level})", value=str(capacity_upgrade_price(bank.capacity_level))
|
|
||||||
)
|
|
||||||
embed.add_field(name=f"Rob ({bank.rob_level})", value=str(rob_upgrade_price(bank.rob_level)))
|
|
||||||
|
|
||||||
embed.set_footer(text="Didier Bank Upgrade [Category]")
|
|
||||||
|
|
||||||
await ctx.reply(embed=embed, mention_author=False)
|
|
||||||
|
|
||||||
@bank_upgrades.command(name="capacity", aliases=["c"]) # type: ignore[arg-type]
|
|
||||||
async def bank_upgrade_capacity(self, ctx: commands.Context):
|
|
||||||
"""Upgrade the capacity level of your bank."""
|
|
||||||
async with self.client.postgres_session as session:
|
|
||||||
try:
|
|
||||||
await crud.upgrade_capacity(session, ctx.author.id)
|
|
||||||
await ctx.message.add_reaction("⏫")
|
|
||||||
except NotEnoughDinks:
|
|
||||||
await ctx.reply("You don't have enough Didier Dinks to do this.", mention_author=False)
|
|
||||||
await self.client.reject_message(ctx.message)
|
|
||||||
|
|
||||||
@bank_upgrades.command(name="interest", aliases=["i"]) # type: ignore[arg-type]
|
|
||||||
async def bank_upgrade_interest(self, ctx: commands.Context):
|
|
||||||
"""Upgrade the interest level of your bank."""
|
|
||||||
async with self.client.postgres_session as session:
|
|
||||||
try:
|
|
||||||
await crud.upgrade_interest(session, ctx.author.id)
|
|
||||||
await ctx.message.add_reaction("⏫")
|
|
||||||
except NotEnoughDinks:
|
|
||||||
await ctx.reply("You don't have enough Didier Dinks to do this.", mention_author=False)
|
|
||||||
await self.client.reject_message(ctx.message)
|
|
||||||
|
|
||||||
@bank_upgrades.command(name="rob", aliases=["r"]) # type: ignore[arg-type]
|
|
||||||
async def bank_upgrade_rob(self, ctx: commands.Context):
|
|
||||||
"""Upgrade the rob level of your bank."""
|
|
||||||
async with self.client.postgres_session as session:
|
|
||||||
try:
|
|
||||||
await crud.upgrade_rob(session, ctx.author.id)
|
|
||||||
await ctx.message.add_reaction("⏫")
|
|
||||||
except NotEnoughDinks:
|
|
||||||
await ctx.reply("You don't have enough Didier Dinks to do this.", mention_author=False)
|
|
||||||
await self.client.reject_message(ctx.message)
|
|
||||||
|
|
||||||
@commands.hybrid_command(name="dinks") # type: ignore[arg-type]
|
@commands.hybrid_command(name="dinks") # type: ignore[arg-type]
|
||||||
async def dinks(self, ctx: commands.Context):
|
async def dinks(self, ctx: commands.Context):
|
||||||
"""Check your Didier Dinks."""
|
"""Check your Didier Dinks."""
|
||||||
|
|
|
@ -62,7 +62,7 @@ def mock(string: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def pluralize(word: str, amount: int, plural_form: Optional[str] = None) -> str:
|
def pluralize(word: str, amount: int, plural_form: Optional[str] = None) -> str:
|
||||||
"""Turn a word into plural"""
|
"""Turn a word into plural if necessary"""
|
||||||
if amount == 1:
|
if amount == 1:
|
||||||
return word
|
return word
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue