| 221 | return p |
| 222 | |
| 223 | def edit_profile(profiles: dict) -> None: |
| 224 | clear() |
| 225 | print("=== EDIT PROFILES ===\n") |
| 226 | names = list(profiles["players"].keys()) |
| 227 | if not names: |
| 228 | print("No profiles yet.") |
| 229 | pause() |
| 230 | return |
| 231 | for i, n in enumerate(names, start=1): |
| 232 | p = profiles["players"][n] |
| 233 | print(f"{i}) {n} (nick: {p.get('nickname', n)})") |
| 234 | print("0) Back") |
| 235 | c = input("\nChoose: ").strip() |
| 236 | if c == "0": |
| 237 | return |
| 238 | if c.isdigit(): |
| 239 | idx = int(c)-1 |
| 240 | if 0 <= idx < len(names): |
| 241 | key = names[idx] |
| 242 | p = profiles["players"][key] |
| 243 | clear() |
| 244 | print(f"Editing: {key}\n") |
| 245 | new_nick = input(f"New nickname (current: {p.get('nickname', key)}): ").strip() |
| 246 | if new_nick: |
| 247 | p["nickname"] = new_nick |
| 248 | save_json(PROFILES_PATH, profiles) |
| 249 | print("Saved.") |
| 250 | pause() |
| 251 | |
| 252 | # -------------------- Highscores / Leaderboards -------------------- |
| 253 | def init_highscores() -> dict: |