Facebook
From 01Kiko, 3 Months ago, written in Python.
Embed
Download Paste or View Raw
Hits: 213
  1. game_world = {
  2.     "player": {
  3.         "name": "Player 1",
  4.         "level": 1,
  5.         "xp": 0,
  6.         "inventory": {
  7.             "sword": {"power": 10},
  8.             "armor": {"defense": 5},
  9.         },
  10.     },
  11.     "cheat_menu": {
  12.         "health_points": {"description": "Add 100 health points"},
  13.         "max_health_points": {"description": "Set maximum health points to 500"},
  14.         "power_up": {"description": "Increase the power of your sword by 100"},
  15.         "power_down": {"description": "Decrease the power of your sword by 100"},
  16.     },
  17. }
  18.  
  19.  
  20. def activate_cheat(cheat_name):
  21.     player = game_world["player"]
  22.     cheat_effect = game_world["cheat_menu"][cheat_name]
  23.  
  24.     if cheat_name == "health_points":
  25.         player["hp"] += 100
  26.     elif cheat_name == "max_health_points":
  27.         player["max_hp"] = 500
  28.     elif cheat_name == "power_up":
  29.         player["inventory"]["sword"]["power"] += 100
  30.     elif cheat_name == "power_down":
  31.         player["inventory"]["sword"]["power"] -= 100
  32.  
  33.     print(f"Cheat '{cheat_name}' activated: {cheat_effect['description']}")
  34.  
  35.  
  36. # Test the function
  37. activate_cheat("health_points")
  38. activate_cheat("power_up")