(economy): Flip bonus logic and fix workout text.
Default to not giving a bonus. Fix an issue where `workout` was displaying unboosted reward.
This commit is contained in:
@@ -280,11 +280,11 @@ class Lion:
|
|||||||
timezone = self.settings.timezone.value
|
timezone = self.settings.timezone.value
|
||||||
return naive_utc_dt.replace(tzinfo=pytz.UTC).astimezone(timezone)
|
return naive_utc_dt.replace(tzinfo=pytz.UTC).astimezone(timezone)
|
||||||
|
|
||||||
def addCoins(self, amount, flush=True, ignorebonus=False):
|
def addCoins(self, amount, flush=True, bonus=False):
|
||||||
"""
|
"""
|
||||||
Add coins to the user, optionally store the transaction in pending.
|
Add coins to the user, optionally store the transaction in pending.
|
||||||
"""
|
"""
|
||||||
self._pending_coins += amount * (1 if ignorebonus else self.economy_bonus)
|
self._pending_coins += amount * (self.economy_bonus if bonus else 1)
|
||||||
self._pending[self.key] = self
|
self._pending[self.key] = self
|
||||||
if flush:
|
if flush:
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ class TimeSlot:
|
|||||||
reward += guild_settings.accountability_bonus.value
|
reward += guild_settings.accountability_bonus.value
|
||||||
|
|
||||||
for memid in self.members:
|
for memid in self.members:
|
||||||
Lion.fetch(self.guild.id, memid).addCoins(reward)
|
Lion.fetch(self.guild.id, memid).addCoins(reward, bonus=True)
|
||||||
|
|
||||||
async def cancel(self):
|
async def cancel(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ async def cmd_send(ctx):
|
|||||||
return await ctx.embed_reply("We are still waiting for {} to open an account.".format(target.mention))
|
return await ctx.embed_reply("We are still waiting for {} to open an account.".format(target.mention))
|
||||||
|
|
||||||
# Finally, send the amount and the ack message
|
# Finally, send the amount and the ack message
|
||||||
target_lion.addCoins(amount, ignorebonus=True)
|
target_lion.addCoins(amount)
|
||||||
source_lion.addCoins(-amount)
|
source_lion.addCoins(-amount)
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ async def cmd_set(ctx):
|
|||||||
# Postgres `coins` column is `integer`, sanity check postgres int limits - which are smalled than python int range
|
# Postgres `coins` column is `integer`, sanity check postgres int limits - which are smalled than python int range
|
||||||
target_coins_to_set = target_lion.coins + amount
|
target_coins_to_set = target_lion.coins + amount
|
||||||
if target_coins_to_set >= 0 and target_coins_to_set <= POSTGRES_INT_MAX:
|
if target_coins_to_set >= 0 and target_coins_to_set <= POSTGRES_INT_MAX:
|
||||||
target_lion.addCoins(amount, ignorebonus=True)
|
target_lion.addCoins(amount)
|
||||||
elif target_coins_to_set < 0:
|
elif target_coins_to_set < 0:
|
||||||
target_coins_to_set = -target_lion.coins # Coins cannot go -ve, cap to 0
|
target_coins_to_set = -target_lion.coins # Coins cannot go -ve, cap to 0
|
||||||
target_lion.addCoins(target_coins_to_set, ignorebonus=True)
|
target_lion.addCoins(target_coins_to_set)
|
||||||
target_coins_to_set = 0
|
target_coins_to_set = 0
|
||||||
else:
|
else:
|
||||||
return await ctx.embed_reply("Member coins cannot be more than {}".format(POSTGRES_INT_MAX))
|
return await ctx.embed_reply("Member coins cannot be more than {}".format(POSTGRES_INT_MAX))
|
||||||
|
|||||||
@@ -501,7 +501,7 @@ class ReactionRoleMessage:
|
|||||||
if price and refund:
|
if price and refund:
|
||||||
# Give the user the refund
|
# Give the user the refund
|
||||||
lion = Lion.fetch(self.guild.id, member.id)
|
lion = Lion.fetch(self.guild.id, member.id)
|
||||||
lion.addCoins(price, ignorebonus=True)
|
lion.addCoins(price)
|
||||||
|
|
||||||
# Notify the user
|
# Notify the user
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ def _scan(guild):
|
|||||||
if member.voice.self_stream or member.voice.self_video:
|
if member.voice.self_stream or member.voice.self_video:
|
||||||
hour_reward += guild_hourly_live_bonus
|
hour_reward += guild_hourly_live_bonus
|
||||||
|
|
||||||
lion.addCoins(hour_reward * interval / (3600), flush=False)
|
lion.addCoins(hour_reward * interval / (3600), flush=False, bonus=True)
|
||||||
|
|
||||||
|
|
||||||
async def _study_tracker():
|
async def _study_tracker():
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ class Tasklist:
|
|||||||
# Rewarding process, now that we know what we need to reward
|
# Rewarding process, now that we know what we need to reward
|
||||||
# Add coins
|
# Add coins
|
||||||
user = Lion.fetch(self.member.guild.id, self.member.id)
|
user = Lion.fetch(self.member.guild.id, self.member.id)
|
||||||
user.addCoins(reward_coins)
|
user.addCoins(reward_coins, bonus=True)
|
||||||
|
|
||||||
# Mark tasks as rewarded
|
# Mark tasks as rewarded
|
||||||
taskids = [task['taskid'] for task in reward_tasks]
|
taskids = [task['taskid'] for task in reward_tasks]
|
||||||
|
|||||||
@@ -130,12 +130,12 @@ async def workout_complete(member, workout):
|
|||||||
|
|
||||||
settings = GuildSettings(member.guild.id)
|
settings = GuildSettings(member.guild.id)
|
||||||
reward = settings.workout_reward.value
|
reward = settings.workout_reward.value
|
||||||
user.addCoins(reward)
|
user.addCoins(reward, bonus=True)
|
||||||
|
|
||||||
settings.event_log.log(
|
settings.event_log.log(
|
||||||
"{} completed their daily workout and was rewarded `{}` coins! (`{:.2f}` minutes)".format(
|
"{} completed their daily workout and was rewarded `{}` coins! (`{:.2f}` minutes)".format(
|
||||||
member.mention,
|
member.mention,
|
||||||
reward,
|
int(reward * user.economy_bonus),
|
||||||
workout.duration / 60,
|
workout.duration / 60,
|
||||||
), title="Workout Completed"
|
), title="Workout Completed"
|
||||||
)
|
)
|
||||||
@@ -143,7 +143,7 @@ async def workout_complete(member, workout):
|
|||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
description=(
|
description=(
|
||||||
"Congratulations on completing your daily workout!\n"
|
"Congratulations on completing your daily workout!\n"
|
||||||
"You have been rewarded with `{}` LionCoins. Good job!".format(reward)
|
"You have been rewarded with `{}` LionCoins. Good job!".format(int(reward * user.economy_bonus))
|
||||||
),
|
),
|
||||||
timestamp=dt.datetime.utcnow(),
|
timestamp=dt.datetime.utcnow(),
|
||||||
colour=discord.Color.orange()
|
colour=discord.Color.orange()
|
||||||
|
|||||||
Reference in New Issue
Block a user