Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -96,14 +96,15 @@ async def perform_roll(interaction: discord.Interaction):
|
|
96 |
user_id = interaction.user.id
|
97 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
98 |
|
99 |
-
# Sort pets by difficulty
|
100 |
-
sorted_pets = sorted(pets, key=lambda x: x['configData']['difficulty']
|
101 |
|
102 |
-
# Calculate the
|
103 |
-
|
|
|
104 |
|
105 |
-
# Select a random pet from the
|
106 |
-
rolled_pet = random.choice(sorted_pets[:
|
107 |
|
108 |
pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'] == rolled_pet['configName']), None)
|
109 |
|
@@ -161,17 +162,13 @@ async def perform_roll(interaction: discord.Interaction):
|
|
161 |
|
162 |
async def increase_luck_callback(interaction: discord.Interaction):
|
163 |
if interaction.user.id != user_id:
|
164 |
-
await interaction.response.send_message("
|
165 |
-
return
|
166 |
-
|
167 |
-
if user_id in luck_button_used:
|
168 |
-
await interaction.response.send_message("You already used your lick!", ephemeral=True)
|
169 |
return
|
170 |
|
171 |
luck_multipliers[user_id] = 10
|
172 |
luck_expiration[user_id] = time.time() + 1800 # 30 minutes
|
173 |
luck_button_used.add(user_id)
|
174 |
-
await interaction.response.send_message("
|
175 |
|
176 |
increase_luck_button.callback = increase_luck_callback
|
177 |
view.add_item(increase_luck_button)
|
|
|
96 |
user_id = interaction.user.id
|
97 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
98 |
|
99 |
+
# Sort pets by difficulty
|
100 |
+
sorted_pets = sorted(pets, key=lambda x: x['configData']['difficulty'])
|
101 |
|
102 |
+
# Calculate the index based on luck
|
103 |
+
max_index = len(sorted_pets) - 1
|
104 |
+
index = int(max_index * (luck_multiplier - 1) / 9) # Assuming max luck is 10
|
105 |
|
106 |
+
# Select a random pet from the start of the list to the calculated index
|
107 |
+
rolled_pet = random.choice(sorted_pets[:index+1])
|
108 |
|
109 |
pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'] == rolled_pet['configName']), None)
|
110 |
|
|
|
162 |
|
163 |
async def increase_luck_callback(interaction: discord.Interaction):
|
164 |
if interaction.user.id != user_id:
|
165 |
+
await interaction.response.send_message("cannot use", ephemeral=True)
|
|
|
|
|
|
|
|
|
166 |
return
|
167 |
|
168 |
luck_multipliers[user_id] = 10
|
169 |
luck_expiration[user_id] = time.time() + 1800 # 30 minutes
|
170 |
luck_button_used.add(user_id)
|
171 |
+
await interaction.response.send_message("luck Increased", ephemeral=True)
|
172 |
|
173 |
increase_luck_button.callback = increase_luck_callback
|
174 |
view.add_item(increase_luck_button)
|