Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -95,19 +95,14 @@ async def perform_roll(interaction: discord.Interaction):
|
|
95 |
user_id = interaction.user.id
|
96 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
97 |
|
98 |
-
#
|
99 |
-
|
100 |
-
|
101 |
-
#
|
102 |
-
|
103 |
-
|
104 |
-
# Select a pet
|
105 |
-
|
106 |
-
for pet in sorted(pets, key=lambda x: x['configData']['difficulty'], reverse=True):
|
107 |
-
cumulative_probability += pet['configData']['difficulty'] * luck_multiplier
|
108 |
-
if random_value <= cumulative_probability:
|
109 |
-
rolled_pet = pet
|
110 |
-
break
|
111 |
|
112 |
pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'] == rolled_pet['configName']), None)
|
113 |
|
@@ -153,14 +148,14 @@ async def perform_roll(interaction: discord.Interaction):
|
|
153 |
if result:
|
154 |
await interaction.followup.send(embed=result[0], view=result[1])
|
155 |
else:
|
156 |
-
await interaction.followup.send("errer")
|
157 |
|
158 |
roll_again_button.callback = roll_again_callback
|
159 |
|
160 |
view = discord.ui.View()
|
161 |
view.add_item(roll_again_button)
|
162 |
|
163 |
-
if random.random() < 0.2:
|
164 |
increase_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Increase Luck", custom_id="increase_luck")
|
165 |
|
166 |
async def increase_luck_callback(interaction: discord.Interaction):
|
|
|
95 |
user_id = interaction.user.id
|
96 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
97 |
|
98 |
+
# Sort pets by difficulty
|
99 |
+
sorted_pets = sorted(pets, key=lambda x: x['configData']['difficulty'])
|
100 |
+
|
101 |
+
# Calculate the index based on luck
|
102 |
+
index = int((len(sorted_pets) - 1) * (1 - 1/luck_multiplier))
|
103 |
+
|
104 |
+
# Select a random pet from the start of the list to the calculated index
|
105 |
+
rolled_pet = random.choice(sorted_pets[:index+1])
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'] == rolled_pet['configName']), None)
|
108 |
|
|
|
148 |
if result:
|
149 |
await interaction.followup.send(embed=result[0], view=result[1])
|
150 |
else:
|
151 |
+
await interaction.followup.send("errer.")
|
152 |
|
153 |
roll_again_button.callback = roll_again_callback
|
154 |
|
155 |
view = discord.ui.View()
|
156 |
view.add_item(roll_again_button)
|
157 |
|
158 |
+
if random.random() < 0.2:
|
159 |
increase_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Increase Luck", custom_id="increase_luck")
|
160 |
|
161 |
async def increase_luck_callback(interaction: discord.Interaction):
|