Spaces:
Building
Building
Update petroll.py
Browse files- petroll.py +95 -5
petroll.py
CHANGED
@@ -10,6 +10,7 @@ luck_multipliers = {}
|
|
10 |
luck_expiration = {}
|
11 |
luck_opportunities = {}
|
12 |
used_luck_opportunities = set()
|
|
|
13 |
|
14 |
async def perform_roll(interaction: discord.Interaction):
|
15 |
async def fetch_data(url):
|
@@ -111,7 +112,29 @@ async def perform_roll(interaction: discord.Interaction):
|
|
111 |
sell_button.callback = sell_pet_callback
|
112 |
view.add_item(sell_button)
|
113 |
|
114 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
luck_opportunities[user_id] = luck_opportunities.get(user_id, 0) + 1
|
116 |
increase_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Increase Luck", custom_id=f"increase_luck_{luck_opportunities[user_id]}")
|
117 |
|
@@ -120,15 +143,18 @@ async def perform_roll(interaction: discord.Interaction):
|
|
120 |
await interaction.response.send_message("You cannot use this button.", ephemeral=True)
|
121 |
return
|
122 |
|
123 |
-
if user_id in used_luck_opportunities:
|
124 |
-
await interaction.response.send_message("You have already used your luck
|
125 |
return
|
126 |
|
127 |
current_luck = luck_multipliers.get(user_id, 1)
|
128 |
new_luck = min(current_luck + 1, 10)
|
129 |
luck_multipliers[user_id] = new_luck
|
130 |
luck_expiration[user_id] = time.time() + 1800
|
131 |
-
|
|
|
|
|
|
|
132 |
|
133 |
luck_percentage = (new_luck - 1) * 100
|
134 |
await interaction.response.send_message(f"Your luck has been increased to {luck_percentage}% for 30 minutes!", ephemeral=True)
|
@@ -157,4 +183,68 @@ async def petroll(interaction: discord.Interaction):
|
|
157 |
async def balance(interaction: discord.Interaction):
|
158 |
user_id = interaction.user.id
|
159 |
current_balance = user_cash.get(user_id, 0)
|
160 |
-
await interaction.response.send_message(f"Your current balance is ${current_balance}.", ephemeral=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
luck_expiration = {}
|
11 |
luck_opportunities = {}
|
12 |
used_luck_opportunities = set()
|
13 |
+
first_luck_claimed = set()
|
14 |
|
15 |
async def perform_roll(interaction: discord.Interaction):
|
16 |
async def fetch_data(url):
|
|
|
112 |
sell_button.callback = sell_pet_callback
|
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 100% Luck Forever", custom_id="first_luck")
|
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] = 10 # 100% luck
|
124 |
+
first_luck_claimed.add(user_id)
|
125 |
+
|
126 |
+
await interaction.response.send_message("You've claimed 100% luck forever!", ephemeral=True)
|
127 |
+
|
128 |
+
for item in view.children:
|
129 |
+
if item.custom_id == "first_luck":
|
130 |
+
view.remove_item(item)
|
131 |
+
break
|
132 |
+
await interaction.message.edit(view=view)
|
133 |
+
|
134 |
+
first_luck_button.callback = first_luck_callback
|
135 |
+
view.add_item(first_luck_button)
|
136 |
+
|
137 |
+
elif random.random() < 0.6 and luck_opportunities.get(user_id, 0) < 4:
|
138 |
luck_opportunities[user_id] = luck_opportunities.get(user_id, 0) + 1
|
139 |
increase_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Increase Luck", custom_id=f"increase_luck_{luck_opportunities[user_id]}")
|
140 |
|
|
|
143 |
await interaction.response.send_message("You cannot use this button.", ephemeral=True)
|
144 |
return
|
145 |
|
146 |
+
if user_id in used_luck_opportunities and len(used_luck_opportunities[user_id]) >= 4:
|
147 |
+
await interaction.response.send_message("You have already used all your luck opportunities.", ephemeral=True)
|
148 |
return
|
149 |
|
150 |
current_luck = luck_multipliers.get(user_id, 1)
|
151 |
new_luck = min(current_luck + 1, 10)
|
152 |
luck_multipliers[user_id] = new_luck
|
153 |
luck_expiration[user_id] = time.time() + 1800
|
154 |
+
|
155 |
+
if user_id not in used_luck_opportunities:
|
156 |
+
used_luck_opportunities[user_id] = set()
|
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)
|
|
|
183 |
async def balance(interaction: discord.Interaction):
|
184 |
user_id = interaction.user.id
|
185 |
current_balance = user_cash.get(user_id, 0)
|
186 |
+
await interaction.response.send_message(f"Your current balance is ${current_balance}.", ephemeral=True)
|
187 |
+
|
188 |
+
@app_commands.command(name="dice", description="Roll the dice and bet")
|
189 |
+
async def dice(interaction: discord.Interaction, bet: int):
|
190 |
+
await roll_dice(interaction, bet)
|
191 |
+
|
192 |
+
async def roll_dice(interaction: discord.Interaction, bet: int):
|
193 |
+
user_id = interaction.user.id
|
194 |
+
balance = user_cash.get(user_id, 0)
|
195 |
+
|
196 |
+
if bet <= 0:
|
197 |
+
await interaction.response.send_message("Bet Higher than 0 Idiot.")
|
198 |
+
return
|
199 |
+
|
200 |
+
if bet > balance:
|
201 |
+
await interaction.response.send_message(f"You don't have enough cash. Your current balance is ${balance:.2f}")
|
202 |
+
return
|
203 |
+
|
204 |
+
embed = discord.Embed(title="Dice Roll", description=f"{interaction.user.name} is betting ${bet:.2f}", color=0x787878)
|
205 |
+
embed.add_field(name="Current Balance", value=f"${balance:.2f}", inline=False)
|
206 |
+
|
207 |
+
roll_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll the Dice", custom_id="roll_dice")
|
208 |
+
|
209 |
+
async def roll_dice_callback(interaction: discord.Interaction):
|
210 |
+
nonlocal balance
|
211 |
+
result = random.choice(["win", "lose"])
|
212 |
+
|
213 |
+
if result == "win":
|
214 |
+
winnings = bet
|
215 |
+
balance += winnings
|
216 |
+
result_text = f"You won ${winnings:.2f}!"
|
217 |
+
else:
|
218 |
+
balance -= bet
|
219 |
+
result_text = f"You lost ${bet:.2f}."
|
220 |
+
|
221 |
+
user_cash[user_id] = balance
|
222 |
+
|
223 |
+
embed.clear_fields()
|
224 |
+
embed.add_field(name="Result", value=result_text, inline=False)
|
225 |
+
embed.add_field(name="New Balance", value=f"${balance:.2f}", inline=False)
|
226 |
+
|
227 |
+
roll_again_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll Again", custom_id="roll_again")
|
228 |
+
|
229 |
+
async def roll_again_callback(interaction: discord.Interaction):
|
230 |
+
if interaction.user.id == user_id:
|
231 |
+
await roll_dice(interaction, bet)
|
232 |
+
else:
|
233 |
+
await interaction.response.send_message("you cant roll this", ephemeral=True)
|
234 |
+
|
235 |
+
roll_again_button.callback = roll_again_callback
|
236 |
+
|
237 |
+
new_view = discord.ui.View()
|
238 |
+
new_view.add_item(roll_again_button)
|
239 |
+
|
240 |
+
await interaction.response.edit_message(embed=embed, view=new_view)
|
241 |
+
|
242 |
+
roll_button.callback = roll_dice_callback
|
243 |
+
|
244 |
+
view = discord.ui.View()
|
245 |
+
view.add_item(roll_button)
|
246 |
+
|
247 |
+
if interaction.response.is_done():
|
248 |
+
await interaction.followup.send(embed=embed, view=view)
|
249 |
+
else:
|
250 |
+
await interaction.response.send_message(embed=embed, view=view)
|