mirror of
https://github.com/stijndcl/didier.git
synced 2026-06-29 17:39:57 +02:00
Stash currency beginning
This commit is contained in:
parent
cb72774a7a
commit
ea2a25d1fc
6 changed files with 67 additions and 79 deletions
|
|
@ -25,7 +25,7 @@ class Bitcoin(commands.Cog):
|
|||
:param ctx: Discord Context
|
||||
"""
|
||||
price = self.getPrice()
|
||||
bc = float(currency.getOrAddUser(ctx.author.id)[8])
|
||||
bc = float(currency.get_or_add_user(ctx.author.id)[8])
|
||||
|
||||
currentTime = timeFormatters.dateTimeNow()
|
||||
currentTimeFormatted = currentTime.strftime('%m/%d/%Y om %H:%M:%S')
|
||||
|
|
@ -78,9 +78,9 @@ class Bitcoin(commands.Cog):
|
|||
purchased = round(float(amount) / price, 8)
|
||||
|
||||
# Update the db
|
||||
currency.update(ctx.author.id, "dinks", float(currency.dinks(ctx.author.id)) - float(amount))
|
||||
currency.update(ctx.author.id, "dinks", currency.dinks(ctx.author.id) - float(amount))
|
||||
currency.update(ctx.author.id, "bitcoins",
|
||||
float(currency.getOrAddUser(ctx.author.id)[8]) + float(purchased))
|
||||
float(currency.get_or_add_user(ctx.author.id).bitcoins) + float(purchased))
|
||||
|
||||
await ctx.send("**{}** heeft **{:,}** Bitcoin{} gekocht voor **{:,}** Didier Dink{}!"
|
||||
.format(ctx.author.display_name, purchased, checks.pluralS(purchased),
|
||||
|
|
@ -94,14 +94,14 @@ class Bitcoin(commands.Cog):
|
|||
:param amount: the amount of Bitcoins the user wants to sell
|
||||
"""
|
||||
if str(amount).lower() == "all":
|
||||
amount = float(currency.getOrAddUser(ctx.author.id)[8])
|
||||
amount = float(currency.get_or_add_user(ctx.author.id)[8])
|
||||
|
||||
try:
|
||||
amount = float(amount)
|
||||
if amount <= 0:
|
||||
raise ValueError
|
||||
|
||||
bc = float(currency.getOrAddUser(ctx.author.id)[8])
|
||||
bc = float(currency.get_or_add_user(ctx.author.id)[8])
|
||||
|
||||
if bc == 0.0:
|
||||
# User has no Bitcoins
|
||||
|
|
@ -112,7 +112,7 @@ class Bitcoin(commands.Cog):
|
|||
.format(ctx.author.display_name))
|
||||
else:
|
||||
price = self.getPrice()
|
||||
dinks = float(currency.dinks(ctx.author.id))
|
||||
dinks = currency.dinks(ctx.author.id)
|
||||
|
||||
currency.update(ctx.author.id, "bitcoins", bc - amount)
|
||||
currency.update(ctx.author.id, "dinks", dinks + (price * amount))
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class Dinks(commands.Cog):
|
|||
Command that shows the user's Didier Dinks & Platinum Dinks
|
||||
:param ctx: Discord Context
|
||||
"""
|
||||
dinks = currency.dinksAll(ctx.author.id)
|
||||
dinks = currency.dinks_all(ctx.author.id)
|
||||
|
||||
answer = "**{}** heeft **{:,}** Didier Dink{}"\
|
||||
.format(ctx.author.display_name, math.floor(dinks["dinks"]), checks.pluralS(dinks["dinks"]))
|
||||
|
|
@ -148,7 +148,7 @@ class Dinks(commands.Cog):
|
|||
"""
|
||||
# 0 1 2 3 4 5 6 7 8 9 10
|
||||
# ID dinks level investedamount investeddays profit defense offense bc nightly streak
|
||||
response = currency.getOrAddUser(ctx.author.id)
|
||||
response = currency.get_or_add_user(ctx.author.id)
|
||||
|
||||
# Calculate the cost to level your bank
|
||||
interestLevelPrice = round(math.pow(1.28, int(response[2])) * 300)
|
||||
|
|
@ -179,7 +179,7 @@ class Dinks(commands.Cog):
|
|||
Command that shows the user's bank stats.
|
||||
:param ctx: Discord Context
|
||||
"""
|
||||
response = currency.getOrAddUser(ctx.author.id)
|
||||
response = currency.get_or_add_user(ctx.author.id)
|
||||
|
||||
# Calculate the prices to level stats up
|
||||
defense = int(response[6])
|
||||
|
|
@ -213,7 +213,7 @@ class Dinks(commands.Cog):
|
|||
increasing interest.
|
||||
:param ctx: Discord Context
|
||||
"""
|
||||
response = currency.getOrAddUser(ctx.author.id)
|
||||
response = currency.get_or_add_user(ctx.author.id)
|
||||
interestLevelPrice = float(math.pow(1.28, int(response[2])) * 300)
|
||||
|
||||
# Check if user has enough Didier Dinks to do this
|
||||
|
|
@ -233,7 +233,7 @@ class Dinks(commands.Cog):
|
|||
increasing capacity & rob chances.
|
||||
:param ctx: Discord Context
|
||||
"""
|
||||
response = currency.getOrAddUser(ctx.author.id)
|
||||
response = currency.get_or_add_user(ctx.author.id)
|
||||
|
||||
offense = int(response[7])
|
||||
capacity = calcCapacity(offense)
|
||||
|
|
@ -256,7 +256,7 @@ class Dinks(commands.Cog):
|
|||
increasing chance of failed robs by others.
|
||||
:param ctx: Discord Context
|
||||
"""
|
||||
response = currency.getOrAddUser(ctx.author.id)
|
||||
response = currency.get_or_add_user(ctx.author.id)
|
||||
defense = int(response[6])
|
||||
defenseLevelPrice = math.floor(math.pow(1.4, defense) * 365) if defense < 38 else 5 * calcCapacity(defense - 6)
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ class Dinks(commands.Cog):
|
|||
elif not checks.isValidAmount(ctx, amount[0])[0]:
|
||||
await ctx.send(checks.isValidAmount(ctx, amount[0])[1])
|
||||
else:
|
||||
user = currency.getOrAddUser(ctx.author.id)
|
||||
user = currency.get_or_add_user(ctx.author.id)
|
||||
if str(amount[0]).lower() == "all":
|
||||
amount[0] = user[1]
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ class Dinks(commands.Cog):
|
|||
:param args:
|
||||
:return:
|
||||
"""
|
||||
user = currency.getOrAddUser(ctx.author.id)
|
||||
user = currency.get_or_add_user(ctx.author.id)
|
||||
args = list(args)
|
||||
claimAll = False
|
||||
|
||||
|
|
@ -546,8 +546,8 @@ class Dinks(commands.Cog):
|
|||
return False, None, None
|
||||
|
||||
# Check the database for these users
|
||||
user1 = currency.getOrAddUser(ctx.author.id)
|
||||
user2 = currency.getOrAddUser(target.id)
|
||||
user1 = currency.get_or_add_user(ctx.author.id)
|
||||
user2 = currency.get_or_add_user(target.id)
|
||||
|
||||
# Can't rob without Didier Dinks
|
||||
if float(user1[1]) < 1.0:
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ class Leaderboards(commands.Cog):
|
|||
|
||||
@leaderboard.command(name="Dinks", aliases=["Cash"], hidden=True)
|
||||
async def dinks(self, ctx):
|
||||
entries = currency.getAllRows()
|
||||
platDinks = currency.getAllPlatDinks()
|
||||
entries = currency.get_all_rows()
|
||||
platDinks = currency.get_all_plat_dinks()
|
||||
|
||||
# Take platinum dinks into account
|
||||
for i, user in enumerate(entries):
|
||||
|
|
@ -77,7 +77,7 @@ class Leaderboards(commands.Cog):
|
|||
|
||||
@leaderboard.command(name="Bitcoin", aliases=["Bc"], hidden=True)
|
||||
async def bitcoin(self, ctx):
|
||||
users = currency.getAllRows()
|
||||
users = currency.get_all_rows()
|
||||
boardTop = []
|
||||
for i, user in enumerate(sorted(users, key=lambda x: x[8], reverse=True)):
|
||||
# Don't create an empty leaderboard
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Tasks(commands.Cog):
|
|||
with open("files/lastTasks.json", "r") as fp:
|
||||
lastTasks = json.load(fp)
|
||||
if int(self.getCurrentHour()) == 4 and int(time.time()) - int(lastTasks["interest"]) > 10000:
|
||||
users = currency.getAllRows()
|
||||
users = currency.get_all_rows()
|
||||
bitcoinPrice = self.getCurrentBitcoinPrice()
|
||||
for user in users:
|
||||
# People in prison don't get interest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue