Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -95,8 +95,12 @@ async def perform_roll(interaction: discord.Interaction):
|
|
95 |
user_id = interaction.user.id
|
96 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
97 |
|
|
|
|
|
|
|
|
|
98 |
# Calculate total difficulty
|
99 |
-
total_difficulty = sum(1 /
|
100 |
|
101 |
# Generate a random number between 0 and total_difficulty
|
102 |
random_value = random.uniform(0, total_difficulty)
|
@@ -104,7 +108,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
104 |
# Select a pet based on the random value
|
105 |
cumulative_probability = 0
|
106 |
for pet in pets:
|
107 |
-
cumulative_probability += 1 /
|
108 |
if random_value <= cumulative_probability:
|
109 |
rolled_pet = pet
|
110 |
break
|
@@ -153,14 +157,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):
|
@@ -170,7 +174,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
170 |
luck_expiration[user_id] = time.time() + 1800 # 30 minutes
|
171 |
else:
|
172 |
luck_multipliers[user_id] *= 10
|
173 |
-
await interaction.response.send_message(f"luck
|
174 |
|
175 |
increase_luck_button.callback = increase_luck_callback
|
176 |
view.add_item(increase_luck_button)
|
|
|
95 |
user_id = interaction.user.id
|
96 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
97 |
|
98 |
+
# Adjust difficulty based on luck
|
99 |
+
for pet in pets:
|
100 |
+
pet['configData']['difficulty'] *= luck_multiplier
|
101 |
+
|
102 |
# Calculate total difficulty
|
103 |
+
total_difficulty = sum(1 / pet['configData']['difficulty'] for pet in pets)
|
104 |
|
105 |
# Generate a random number between 0 and total_difficulty
|
106 |
random_value = random.uniform(0, total_difficulty)
|
|
|
108 |
# Select a pet based on the random value
|
109 |
cumulative_probability = 0
|
110 |
for pet in pets:
|
111 |
+
cumulative_probability += 1 / pet['configData']['difficulty']
|
112 |
if random_value <= cumulative_probability:
|
113 |
rolled_pet = pet
|
114 |
break
|
|
|
157 |
if result:
|
158 |
await interaction.followup.send(embed=result[0], view=result[1])
|
159 |
else:
|
160 |
+
await interaction.followup.send("errer.")
|
161 |
|
162 |
roll_again_button.callback = roll_again_callback
|
163 |
|
164 |
view = discord.ui.View()
|
165 |
view.add_item(roll_again_button)
|
166 |
|
167 |
+
if random.random() < 0.2:
|
168 |
increase_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Increase Luck", custom_id="increase_luck")
|
169 |
|
170 |
async def increase_luck_callback(interaction: discord.Interaction):
|
|
|
174 |
luck_expiration[user_id] = time.time() + 1800 # 30 minutes
|
175 |
else:
|
176 |
luck_multipliers[user_id] *= 10
|
177 |
+
await interaction.response.send_message(f"luck increase! Current luck: {luck_multipliers[user_id]}x", ephemeral=True)
|
178 |
|
179 |
increase_luck_button.callback = increase_luck_callback
|
180 |
view.add_item(increase_luck_button)
|