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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -18
app.py CHANGED
@@ -99,22 +99,12 @@ 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
- # 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
 
@@ -145,7 +135,8 @@ async def perform_roll(interaction: discord.Interaction):
145
  if user_id in luck_expiration:
146
  remaining_time = int(luck_expiration[user_id] - time.time())
147
  if remaining_time > 0:
148
- luck_text = f"\nYou have {remaining_time // 60} minutes and {remaining_time % 60} seconds of luck left!"
 
149
  else:
150
  del luck_multipliers[user_id]
151
  del luck_expiration[user_id]
@@ -175,10 +166,14 @@ async def perform_roll(interaction: discord.Interaction):
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)
182
 
183
  increase_luck_button.callback = increase_luck_callback
184
  view.add_item(increase_luck_button)
 
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
 
 
135
  if user_id in luck_expiration:
136
  remaining_time = int(luck_expiration[user_id] - time.time())
137
  if remaining_time > 0:
138
+ luck_percentage = (luck_multiplier - 1) * 100
139
+ luck_text = f"\nYou have {remaining_time // 60} minutes and {remaining_time % 60} seconds of luck left! (x{luck_percentage}% luck)"
140
  else:
141
  del luck_multipliers[user_id]
142
  del luck_expiration[user_id]
 
166
  await interaction.response.send_message("cannot use", ephemeral=True)
167
  return
168
 
169
+ if user_id in luck_button_used:
170
+ await interaction.response.send_message("You've already used your luck", ephemeral=True)
171
+ return
172
+
173
+ luck_multipliers[user_id] = 2
174
  luck_expiration[user_id] = time.time() + 1800 # 30 minutes
175
  luck_button_used.add(user_id)
176
+ await interaction.response.send_message("your luck has been increased to x100% for 30 minutes!", ephemeral=True)
177
 
178
  increase_luck_button.callback = increase_luck_callback
179
  view.add_item(increase_luck_button)