(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
|
||||
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.
|
||||
"""
|
||||
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
|
||||
if flush:
|
||||
self.flush()
|
||||
|
||||
@@ -427,7 +427,7 @@ class TimeSlot:
|
||||
reward += guild_settings.accountability_bonus.value
|
||||
|
||||
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):
|
||||
"""
|
||||
|
||||
@@ -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))
|
||||
|
||||
# Finally, send the amount and the ack message
|
||||
target_lion.addCoins(amount, ignorebonus=True)
|
||||
target_lion.addCoins(amount)
|
||||
source_lion.addCoins(-amount)
|
||||
|
||||
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
|
||||
target_coins_to_set = target_lion.coins + amount
|
||||
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:
|
||||
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
|
||||
else:
|
||||
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:
|
||||
# Give the user the refund
|
||||
lion = Lion.fetch(self.guild.id, member.id)
|
||||
lion.addCoins(price, ignorebonus=True)
|
||||
lion.addCoins(price)
|
||||
|
||||
# Notify the user
|
||||
embed = discord.Embed(
|
||||
|
||||
@@ -65,7 +65,7 @@ def _scan(guild):
|
||||
if member.voice.self_stream or member.voice.self_video:
|
||||
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():
|
||||
|
||||
@@ -350,7 +350,7 @@ class Tasklist:
|
||||
# Rewarding process, now that we know what we need to reward
|
||||
# Add coins
|
||||
user = Lion.fetch(self.member.guild.id, self.member.id)
|
||||
user.addCoins(reward_coins)
|
||||
user.addCoins(reward_coins, bonus=True)
|
||||
|
||||
# Mark tasks as rewarded
|
||||
taskids = [task['taskid'] for task in reward_tasks]
|
||||
|
||||
@@ -130,12 +130,12 @@ async def workout_complete(member, workout):
|
||||
|
||||
settings = GuildSettings(member.guild.id)
|
||||
reward = settings.workout_reward.value
|
||||
user.addCoins(reward)
|
||||
user.addCoins(reward, bonus=True)
|
||||
|
||||
settings.event_log.log(
|
||||
"{} completed their daily workout and was rewarded `{}` coins! (`{:.2f}` minutes)".format(
|
||||
member.mention,
|
||||
reward,
|
||||
int(reward * user.economy_bonus),
|
||||
workout.duration / 60,
|
||||
), title="Workout Completed"
|
||||
)
|
||||
@@ -143,7 +143,7 @@ async def workout_complete(member, workout):
|
||||
embed = discord.Embed(
|
||||
description=(
|
||||
"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(),
|
||||
colour=discord.Color.orange()
|
||||
|
||||
Reference in New Issue
Block a user