Skip to content

Commit 60a9b54

Browse files
committed
Add code for XP multiplier logic
1 parent bb8a488 commit 60a9b54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def add_xp(self, amount: float) -> None: # add XP
4444
Add XP (experience points) to the user.
4545
amount - the amount to add XP.
4646
"""
47+
if (
48+
amount == self.last_item_clicked
49+
): # check if amount is the same as last item clicked
50+
self.multiplier += 1 # increase multiplier
51+
else:
52+
self.multiplier = (
53+
1 # reset multiplier if amount is not the same as last item clicked
54+
)
55+
self.last_item_clicked = amount # set last item clicked to amount
4756
self.xp += amount * self.multiplier # add XP by amount
4857
self.total_xp += amount * self.multiplier # add total XP by amount
4958
self.check_level_up() # check if user has leveled up

0 commit comments

Comments
 (0)