coollsd commited on
Commit
7708c7e
·
verified ·
1 Parent(s): a935b4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -99,12 +99,22 @@ async def perform_roll(interaction: discord.Interaction):
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
 
@@ -165,7 +175,7 @@ async def perform_roll(interaction: discord.Interaction):
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)
 
99
  # Sort pets by difficulty
100
  sorted_pets = sorted(pets, key=lambda x: x['configData']['difficulty'])
101
 
102
+ # Define difficulty ranges based on luck
103
+ if luck_multiplier == 1:
104
+ min_difficulty, max_difficulty = 2, 3000
105
+ elif luck_multiplier == 2:
106
+ min_difficulty, max_difficulty = 100, 20000
107
+ else:
108
+ min_difficulty, max_difficulty = 1000, 100000000
109
+
110
+ # Filter pets based on difficulty range
111
+ eligible_pets = [pet for pet in sorted_pets if min_difficulty <= pet['configData']['difficulty'] <= max_difficulty]
112
+
113
+ if not eligible_pets:
114
+ return None
115
 
116
+ # Select a random pet from the eligible pets
117
+ rolled_pet = random.choice(eligible_pets)
118
 
119
  pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'] == rolled_pet['configName']), None)
120
 
 
175
  await interaction.response.send_message("cannot use", ephemeral=True)
176
  return
177
 
178
+ luck_multipliers[user_id] = 2 if user_id not in luck_multipliers else 10
179
  luck_expiration[user_id] = time.time() + 1800 # 30 minutes
180
  luck_button_used.add(user_id)
181
  await interaction.response.send_message("luck Increased", ephemeral=True)