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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
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 in descending order
100
- sorted_pets = sorted(pets, key=lambda x: x['configData']['difficulty'], reverse=True)
101
 
102
- # Calculate the number of pets to consider based on luck
103
- num_pets_to_consider = max(1, int(len(sorted_pets) * (luck_multiplier / 10)))
 
104
 
105
- # Select a random pet from the top pets based on luck
106
- rolled_pet = random.choice(sorted_pets[:num_pets_to_consider])
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("You cannot use this look!", ephemeral=True)
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("Your luck has been increased for 30 minutes!", ephemeral=True)
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)