Added Penalty System
This commit is contained in:
45
commands.py
45
commands.py
@@ -45,13 +45,14 @@ def register(tree: app_commands.CommandTree):
|
||||
# -------------------
|
||||
# /match
|
||||
# -------------------
|
||||
from constants import ENABLED_WORKOUTS
|
||||
|
||||
enabled_workouts = [
|
||||
app_commands.Choice(name=name, value=name)
|
||||
for name, value in WORKOUTS.items()
|
||||
if value > 0
|
||||
app_commands.Choice(name=name, value=name)
|
||||
for name in ENABLED_WORKOUTS.keys()
|
||||
]
|
||||
|
||||
@tree.command(name="match", description="Log a Valorant match")
|
||||
@tree.command(name="match_temp", description="Log a Valorant match")
|
||||
@app_commands.describe(
|
||||
result="Match result",
|
||||
rr_change="RR gained or lost",
|
||||
@@ -97,11 +98,43 @@ def register(tree: app_commands.CommandTree):
|
||||
)
|
||||
return
|
||||
|
||||
new_rank, new_rr = apply_rr(user["rank"], user["rr"], rr_change)
|
||||
# Enforce RR direction based on result
|
||||
rr_delta = abs(rr_change)
|
||||
|
||||
per_death = WORKOUTS[workout]
|
||||
if result == "LOSS":
|
||||
rr_delta *= -1
|
||||
|
||||
new_rank, new_rr = apply_rr(
|
||||
user["rank"],
|
||||
user["rr"],
|
||||
rr_delta
|
||||
)
|
||||
|
||||
per_death = ENABLED_WORKOUTS.get(workout, 0)
|
||||
|
||||
if per_death == 0:
|
||||
await interaction.response.send_message(
|
||||
"❌ That workout is currently disabled.",
|
||||
ephemeral=True
|
||||
)
|
||||
return
|
||||
|
||||
# Base workout calculation
|
||||
workout_total = deaths * per_death
|
||||
|
||||
# Loss penalty
|
||||
if result == "LOSS":
|
||||
workout_total += 10
|
||||
|
||||
bonus_text = " (+10 loss penalty)" if result == "LOSS" else ""
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"🏆 Match logged\n"
|
||||
f"**Result:** {result}\n"
|
||||
f"**Rank:** {new_rank} ({new_rr} RR)\n"
|
||||
f"**Workout:** {workout} × {workout_total}{bonus_text}"
|
||||
)
|
||||
|
||||
cur.execute("""
|
||||
UPDATE users
|
||||
SET
|
||||
|
||||
Reference in New Issue
Block a user