Most Recent
Forum Legend
Following
New Comments
Locked Topic
Pinned Topic
Requirements: must have Python coding software
Rules: don't fudge the code/results when sending a screenshot of your progress
Goal: try to beat the number 1. person
Credits: ChatGPT for the help with the animations and GUI
Code:
import random
import tkinter as tk
from tkinter import messagebox
# ==================== Configurations ====================
rarities = {
"Common": 60,
"Uncommon": 25,
"Rare": 10,
"Legendary": 3,
"Mythical": 1,
"Divine": 0.5,
"Prismatic": 0.1,
"Secret": 0.01
}
rarity_colors = {
"Common": "#A0A0A0",
"Uncommon": "#1EFF00",
"Rare": "#0070DD",
"Legendary": "#A335EE",
"Mythical": "#FF8000",
"Divine": "#FF0000",
"Prismatic": None, # rainbow animation
"Secret": "#FFD700"
}
rarity_percent_text = {
"Common": "Common 60%",
"Uncommon": "Uncommon 25%",
"Rare": "Rare 10%",
"Legendary": "Legendary 3%",
"Mythical": "Mythical 1%",
"Divine": "Divine 0.5%",
"Prismatic": "Prismatic 0.1%",
"Secret": "Secret 0.01%"
}
rainbow_colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#8B00FF']
secret_colors = ['#FFD700', '#FF69B4', '#DA70D6', '#87CEFA', '#FFFFFF', '#FFEFA0', '#FFD700']
roll_counts = {rarity: 0 for rarity in rarities.keys()}
goals = {
"Roll 10 Prismatics": {"rarity": "Prismatic", "target": 10, "completed": False, "reward_luck": 5},
"Roll 5 Secrets": {"rarity": "Secret", "target": 5, "completed": False, "reward_luck": 10},
"Roll 100 Commons": {"rarity": "Common", "target": 100, "completed": False, "reward_luck": 2}
}
luck = 0
cooldown = 1000
cooldown_reduction_per_goal = 200
is_auto_clicking = False
best_roll = None # Track best roll rarity
# ==================== GUI Setup ====================
root = tk.Tk()
root.title("RNG with Goals, Luck, Cooldown, Reset, Best Roll, and Stats")
root.geometry("520x500")
root.resizable(False, False)
# ==================== Globals for Animations ====================
prismatic_stats_color_index = 0
secret_stats_color_index = 0
prismatic_stats_animation_id = None
secret_stats_animation_id = None
# ==================== Functions ====================
def adjusted_rarities():
base_weights = rarities.copy()
for rarity in base_weights:
if rarity in ["Rare", "Legendary", "Mythical", "Divine", "Prismatic", "Secret"]:
base_weights[rarity] += luck * 0.1
return base_weights
def pick_rarity():
weights = adjusted_rarities()
return random.choices(list(weights.keys()), weights=weights.values())[0]
def start_rainbow_animation(index=0):
color = rainbow_colors[index % len(rainbow_colors)]
rarity_label.config(fg=color)
root.animation_id = root.after(200, start_rainbow_animation, index + 1)
def stop_rainbow_animation():
if hasattr(root, "animation_id"):
root.after_cancel(root.animation_id)
del root.animation_id
def start_secret_animation(index=0):
color = secret_colors[index % len(secret_colors)]
rarity_label.config(fg=color)
root.secret_animation_id = root.after(200, start_secret_animation, index + 1)
def stop_secret_animation():
if hasattr(root, "secret_animation_id"):
root.after_cancel(root.secret_animation_id)
del root.secret_animation_id
def animate_stats(index=0):
global prismatic_stats_color_index, secret_stats_color_index
prismatic_stats_color_index = index % len(rainbow_colors)
secret_stats_color_index = index % len(secret_colors)
prismatic_color = rainbow_colors[prismatic_stats_color_index]
secret_color = secret_colors[secret_stats_color_index]
stats_text.config(state="normal")
stats_text.delete("1.0", tk.END)
for rarity in roll_counts:
count = roll_counts[rarity]
line = f"{rarity}: {count}\n"
stats_text.insert(tk.END, line)
start_index = f"{roll_colors_line_start_index(rarity)}.0"
end_index = f"{roll_colors_line_start_index(rarity)}.{len(line.strip())}"
if rarity == "Prismatic":
stats_text.tag_add("prismatic", start_index, end_index)
elif rarity == "Secret":
stats_text.tag_add("secret", start_index, end_index)
else:
color_static = rarity_colors.get(rarity, "black") or "black"
stats_text.tag_add(rarity, start_index, end_index)
stats_text.tag_config("prismatic", foreground=prismatic_color)
stats_text.tag_config("secret", foreground=secret_color)
for rarity in rarity_colors:
if rarity not in ["Prismatic", "Secret"]:
color_static = rarity_colors.get(rarity, "black") or "black"
stats_text.tag_config(rarity, foreground=color_static)
stats_text.config(state="disabled")
global prismatic_stats_animation_id, secret_stats_animation_id
prismatic_stats_animation_id = root.after(200, animate_stats, index + 1)
secret_stats_animation_id = prismatic_stats_animation_id # use same after callback
def stop_stats_animation():
global prismatic_stats_animation_id, secret_stats_animation_id
if prismatic_stats_animation_id is not None:
root.after_cancel(prismatic_stats_animation_id)
prismatic_stats_animation_id = None
if secret_stats_animation_id is not None:
root.after_cancel(secret_stats_animation_id)
secret_stats_animation_id = None
def roll_colors_line_start_index(rarity):
keys = list(roll_counts.keys())
try:
return keys.index(rarity) + 1
except ValueError:
return 1
def update_best_roll(new_rarity):
global best_roll
if best_roll is None or rarities[new_rarity] < rarities[best_roll]:
best_roll = new_rarity
if new_rarity == "Prismatic":
best_roll_label.config(text=f"Best Roll: {rarity_percent_text[new_rarity]}", fg=rarity_colors[new_rarity] or "black")
elif new_rarity == "Secret":
best_roll_label.config(text=f"Best Roll: {rarity_percent_text[new_rarity]}", fg=rarity_colors[new_rarity])
else:
best_roll_label.config(text=f"Best Roll: {rarity_percent_text[new_rarity]}", fg=rarity_colors[new_rarity])
def check_goals(rarity):
global luck, cooldown, is_auto_clicking
roll_counts[rarity] += 1
update_best_roll(rarity)
for goal_name, goal_info in goals.items():
if not goal_info["completed"] and rarity == goal_info["rarity"]:
if roll_counts[rarity] >= goal_info["target"]:
goal_info["completed"] = True
luck += goal_info["reward_luck"]
messagebox.showinfo(
"Goal Completed!",
f"Congratulations! You completed the goal:\n{goal_name}\n\nLuck increased by {goal_info['reward_luck']}!"
)
update_goals_text()
update_luck_text()
update_statistics()
completed_goals = sum(1 for g in goals.values() if g["completed"])
cooldown = max(200, 1000 - completed_goals * cooldown_reduction_per_goal)
if all(goal["completed"] for goal in goals.values()) and not is_auto_clicking:
is_auto_clicking = True
auto_click()
def update_goals_text():
for label in goals_labels:
label.destroy()
goals_labels.clear()
# No colors or animations here — just plain black text
for goal_name, goal_info in goals.items():
count = roll_counts[goal_info["rarity"]]
status = "✅" if goal_info["completed"] else f"{count}/{goal_info['target']}"
lbl = tk.Label(goals_frame, text=f"{goal_name}: {status}", fg="black", font=("Arial", 10))
lbl.pack(anchor="w")
goals_labels.append(lbl)
def update_luck_text():
luck_label.config(text=f"Luck: {luck} | Cooldown: {cooldown}ms")
def update_statistics():
stop_stats_animation()
animate_stats()
def on_roll():
roll_button.config(state="disabled", text="Cooldown...")
root.after(cooldown, lambda: roll_button.config(state="normal", text="Roll"))
rarity = pick_rarity()
check_goals(rarity)
stop_rainbow_animation()
stop_secret_animation()
if rarity == "Prismatic":
start_rainbow_animation()
elif rarity == "Secret":
start_secret_animation()
else:
rarity_label.config(fg=rarity_colors[rarity])
rarity_label.config(text=rarity_percent_text[rarity])
def auto_click():
if is_auto_clicking:
on_roll()
root.after(cooldown, auto_click)
def reset_game():
global luck, cooldown, is_auto_clicking, best_roll
luck = 0
cooldown = 1000
is_auto_clicking = False
best_roll = None
for key in roll_counts:
roll_counts[key] = 0
for goal in goals.values():
goal["completed"] = False
stop_rainbow_animation()
stop_secret_animation()
stop_stats_animation()
rarity_label.config(text="Roll to get a rarity!", fg="black")
best_roll_label.config(text="Best Roll: None", fg="black")
roll_button.config(state="normal", text="Roll")
stats_text.config(state="normal")
stats_text.delete("1.0", tk.END)
stats_text.config(state="disabled")
update_goals_text()
update_luck_text()
update_statistics()
# ==================== GUI Widgets ====================
roll_button = tk.Button(root, text="Roll", font=("Arial", 12), command=on_roll)
roll_button.pack(pady=10)
reset_button = tk.Button(root, text="Reset Game", font=("Arial", 10), command=reset_game)
reset_button.pack()
result_frame = tk.Frame(root)
result_frame.pack(pady=5)
result_text_label = tk.Label(result_frame, text="Result: ", font=("Arial", 14), fg="black")
result_text_label.pack(side="left")
rarity_label = tk.Label(result_frame, text="Roll to get a rarity!", font=("Arial", 14), fg="black")
rarity_label.pack(side="left")
best_roll_label = tk.Label(root, text="Best Roll: None", font=("Arial", 12, "bold"), fg="black")
best_roll_label.pack(pady=5)
goals_frame = tk.Frame(root)
goals_frame.pack(pady=5)
goals_labels = []
luck_label = tk.Label(root, text="Luck: 0 | Cooldown: 1000ms", font=("Arial", 12))
luck_label.pack()
stats_text = tk.Text(root, width=20, height=10, font=("Arial", 10), state="disabled", bg=root.cget("bg"), bd=0, highlightthickness=0)
stats_text.pack(pady=5)
# ==================== Initialize ====================
update_goals_text()
update_luck_text()
update_statistics()
root.mainloop()