Spaces:
Paused
Paused
Update petroll.py
Browse files- petroll.py +28 -9
petroll.py
CHANGED
|
@@ -34,12 +34,31 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 34 |
user_id = interaction.user.id
|
| 35 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
| 36 |
|
|
|
|
| 37 |
sorted_pets = sorted(pets, key=lambda x: x['configData']['difficulty'])
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'] == rolled_pet['configName']), None)
|
| 45 |
|
|
@@ -70,7 +89,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 70 |
if user_id in luck_expiration:
|
| 71 |
remaining_time = int(luck_expiration[user_id] - time.time())
|
| 72 |
if remaining_time > 0:
|
| 73 |
-
luck_percentage = (luck_multiplier - 1) *
|
| 74 |
luck_text = f"\nYou have {remaining_time // 60} minutes and {remaining_time % 60} seconds of luck left! ({luck_percentage}% luck)"
|
| 75 |
else:
|
| 76 |
del luck_multipliers[user_id]
|
|
@@ -113,17 +132,17 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 113 |
view.add_item(sell_button)
|
| 114 |
|
| 115 |
if user_id not in first_luck_claimed:
|
| 116 |
-
first_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Claim
|
| 117 |
|
| 118 |
async def first_luck_callback(interaction: discord.Interaction):
|
| 119 |
if interaction.user.id != user_id:
|
| 120 |
await interaction.response.send_message("You cannot use this button.", ephemeral=True)
|
| 121 |
return
|
| 122 |
|
| 123 |
-
luck_multipliers[user_id] =
|
| 124 |
first_luck_claimed.add(user_id)
|
| 125 |
|
| 126 |
-
await interaction.response.send_message("You've claimed
|
| 127 |
|
| 128 |
for item in view.children:
|
| 129 |
if item.custom_id == "first_luck":
|
|
@@ -148,7 +167,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 148 |
return
|
| 149 |
|
| 150 |
current_luck = luck_multipliers.get(user_id, 1)
|
| 151 |
-
new_luck = min(current_luck + 1,
|
| 152 |
luck_multipliers[user_id] = new_luck
|
| 153 |
luck_expiration[user_id] = time.time() + 1800
|
| 154 |
|
|
@@ -157,7 +176,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 157 |
used_luck_opportunities[user_id].add(luck_opportunities[user_id])
|
| 158 |
|
| 159 |
luck_percentage = (new_luck - 1) * 100
|
| 160 |
-
await interaction.response.send_message(f"Your luck has been increased to {luck_percentage}% for 30 minutes!", ephemeral=True)
|
| 161 |
|
| 162 |
for item in view.children:
|
| 163 |
if item.custom_id == interaction.custom_id:
|
|
|
|
| 34 |
user_id = interaction.user.id
|
| 35 |
luck_multiplier = luck_multipliers.get(user_id, 1)
|
| 36 |
|
| 37 |
+
# Sort pets by difficulty (rarity)
|
| 38 |
sorted_pets = sorted(pets, key=lambda x: x['configData']['difficulty'])
|
| 39 |
|
| 40 |
+
# Divide pets into tiers
|
| 41 |
+
tier_size = len(sorted_pets) // 5
|
| 42 |
+
tiers = [sorted_pets[i:i+tier_size] for i in range(0, len(sorted_pets), tier_size)]
|
| 43 |
|
| 44 |
+
# Adjust probabilities based on luck
|
| 45 |
+
tier_probabilities = [0.5, 0.25, 0.15, 0.07, 0.03]
|
| 46 |
+
luck_boost = (luck_multiplier - 1) * 0.1 # 10% boost per luck level
|
| 47 |
+
for i in range(len(tier_probabilities)):
|
| 48 |
+
if i < len(tier_probabilities) - 1:
|
| 49 |
+
tier_probabilities[i] -= luck_boost
|
| 50 |
+
tier_probabilities[i+1] += luck_boost
|
| 51 |
+
|
| 52 |
+
# Ensure probabilities are non-negative and sum to 1
|
| 53 |
+
tier_probabilities = [max(0, p) for p in tier_probabilities]
|
| 54 |
+
total = sum(tier_probabilities)
|
| 55 |
+
tier_probabilities = [p / total for p in tier_probabilities]
|
| 56 |
+
|
| 57 |
+
# Select tier based on probabilities
|
| 58 |
+
selected_tier = random.choices(tiers, weights=tier_probabilities)[0]
|
| 59 |
+
|
| 60 |
+
# Select pet from the chosen tier
|
| 61 |
+
rolled_pet = random.choice(selected_tier)
|
| 62 |
|
| 63 |
pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'] == rolled_pet['configName']), None)
|
| 64 |
|
|
|
|
| 89 |
if user_id in luck_expiration:
|
| 90 |
remaining_time = int(luck_expiration[user_id] - time.time())
|
| 91 |
if remaining_time > 0:
|
| 92 |
+
luck_percentage = (luck_multiplier - 1) * 10
|
| 93 |
luck_text = f"\nYou have {remaining_time // 60} minutes and {remaining_time % 60} seconds of luck left! ({luck_percentage}% luck)"
|
| 94 |
else:
|
| 95 |
del luck_multipliers[user_id]
|
|
|
|
| 132 |
view.add_item(sell_button)
|
| 133 |
|
| 134 |
if user_id not in first_luck_claimed:
|
| 135 |
+
first_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Claim 10% Luck Forever", custom_id="first_luck")
|
| 136 |
|
| 137 |
async def first_luck_callback(interaction: discord.Interaction):
|
| 138 |
if interaction.user.id != user_id:
|
| 139 |
await interaction.response.send_message("You cannot use this button.", ephemeral=True)
|
| 140 |
return
|
| 141 |
|
| 142 |
+
luck_multipliers[user_id] = 2 # 10% luck
|
| 143 |
first_luck_claimed.add(user_id)
|
| 144 |
|
| 145 |
+
await interaction.response.send_message("You've claimed 10% luck forever!", ephemeral=True)
|
| 146 |
|
| 147 |
for item in view.children:
|
| 148 |
if item.custom_id == "first_luck":
|
|
|
|
| 167 |
return
|
| 168 |
|
| 169 |
current_luck = luck_multipliers.get(user_id, 1)
|
| 170 |
+
new_luck = min(current_luck + 0.1, 2) # Max 20% luck
|
| 171 |
luck_multipliers[user_id] = new_luck
|
| 172 |
luck_expiration[user_id] = time.time() + 1800
|
| 173 |
|
|
|
|
| 176 |
used_luck_opportunities[user_id].add(luck_opportunities[user_id])
|
| 177 |
|
| 178 |
luck_percentage = (new_luck - 1) * 100
|
| 179 |
+
await interaction.response.send_message(f"Your luck has been increased to {luck_percentage:.1f}% for 30 minutes!", ephemeral=True)
|
| 180 |
|
| 181 |
for item in view.children:
|
| 182 |
if item.custom_id == interaction.custom_id:
|