bookwormtwilight

Conquer the World (Version 1.4 Refresh)

Sep 2nd, 2026
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 28.23 KB | Source Code | 0 0
  1. import json
  2. import random
  3. import time
  4. import timeit
  5.  
  6. # ----------
  7. # game data configs
  8. # ----------
  9.  
  10. ENEMIES = {
  11.     # Windmill Town
  12.     "WT1": {
  13.         "name": "Bandit",
  14.         "island": "Windmill Town",
  15.         "damage": 5,
  16.         "health": 25,
  17.         "miss": 2,
  18.         "power": None,
  19.         "exp": 10,
  20.         "money": 100,
  21.         "drops": [("Bandit Leather [Common Item]", 3)],
  22.     },
  23.     "WT2": {
  24.         "name": "Rouge Bandit",
  25.         "island": "Windmill Town",
  26.         "damage": 30,
  27.         "health": 150,
  28.         "miss": 3,
  29.         "power": "Weak Smash",
  30.         "exp": 30,
  31.         "money": 150,
  32.         "drops": [
  33.             ("Black Leather [Common Item]", 3),
  34.             ("Weak Smash [Uncommon Power]", 4),
  35.         ],
  36.     },
  37.     # Marine Island
  38.     "MI1": {
  39.         "name": "Navy Lieutenant",
  40.         "island": "Marine Island",
  41.         "damage": 55,
  42.         "health": 275,
  43.         "miss": 3,
  44.         "power": None,
  45.         "exp": 50,
  46.         "money": 200,
  47.         "drops": [("Marine Hat [Common Item]", 3)],
  48.     },
  49.     "MI2": {
  50.         "name": "Navy Captain",
  51.         "island": "Marine Island",
  52.         "damage": 80,
  53.         "health": 400,
  54.         "miss": 4,
  55.         "power": "Flying Slash",
  56.         "exp": 70,
  57.         "money": 250,
  58.         "drops": [("Flying Slash [Uncommon Power]", 4)],
  59.     },
  60.     "MI3": {
  61.         "name": "Captain Morgy",
  62.         "island": "Marine Island",
  63.         "damage": 130,
  64.         "health": 650,
  65.         "miss": 4,
  66.         "power": "Smash",
  67.         "exp": 110,
  68.         "money": 350,
  69.         "is_boss": True,
  70.         "boss_chance": 10,  # 1 in 10 chance to spawn
  71.         "drops": [
  72.             ("Morgan's Axe [Very Rare Item]", 7),
  73.             ("Smash [Rare Power]", 5),
  74.         ],
  75.     },
  76.     # Gray Town
  77.     "GT1": {
  78.         "name": "Stout Squatter",
  79.         "island": "Gray Town",
  80.         "damage": 105,
  81.         "health": 525,
  82.         "miss": 5,
  83.         "power": None,
  84.         "exp": 90,
  85.         "money": 300,
  86.         "drops": [("Platinum Robot Head [Ancient Item]", 300)],
  87.     },
  88.     "GT2": {
  89.         "name": "Squatter Commander",
  90.         "island": "Gray Town",
  91.         "damage": 130,
  92.         "health": 650,
  93.         "miss": 5,
  94.         "power": "Flying Slash",
  95.         "exp": 110,
  96.         "money": 350,
  97.         "drops": [("Platinum Robot Torso [Ancient Item]", 300)],
  98.     },
  99.     # Sandy Barren
  100.     "SB1": {
  101.         "name": "Desert Watcher",
  102.         "island": "Sandy Barren",
  103.         "damage": 155,
  104.         "health": 775,
  105.         "miss": 5,
  106.         "power": "Weak Smash",
  107.         "exp": 130,
  108.         "money": 400,
  109.         "drops": [
  110.             ("Sandy Cloth [Common Item]", 3),
  111.             ("Weak Smash [Uncommon Power]", 4),
  112.         ],
  113.     },
  114.     "SB2": {
  115.         "name": "Desert Knight",
  116.         "island": "Sandy Barren",
  117.         "damage": 180,
  118.         "health": 900,
  119.         "miss": 5,
  120.         "power": "Flying Slash",
  121.         "exp": 150,
  122.         "money": 450,
  123.         "drops": [("Heat-Treated Helmet [Ultra Rare]", 70)],
  124.     },
  125.     # Kingfisher Depths
  126.     "KD1": {
  127.         "name": "Deepsea Abyssal",
  128.         "island": "Kingfisher Depths - Fight",
  129.         "damage": 205,
  130.         "health": 1025,
  131.         "miss": 5,
  132.         "power": "Weak Smash",
  133.         "exp": 180,
  134.         "money": 500,
  135.         "drops": [
  136.             ("Deepsea Coral [Common Item]", 3),
  137.             ("Weak Smash [Uncommon Power]", 4),
  138.         ],
  139.     },
  140.     "KD2": {
  141.         "name": "Coral Guardian",
  142.         "island": "Kingfisher Depths - Castle",
  143.         "damage": 230,
  144.         "health": 1150,
  145.         "miss": 5,
  146.         "power": "Flying Slash",
  147.         "exp": 210,
  148.         "money": 550,
  149.         "drops": [
  150.             ("Aquamarine Pearl [Rare Item]", 12),
  151.             ("Flying Slash [Uncommon Power]", 4),
  152.         ],
  153.     },
  154.     "KD3": {
  155.         "name": "Abyssal Kraken",
  156.         "island": "Kingfisher Depths - Abyssal Reef",
  157.         "damage": 310,
  158.         "health": 1550,
  159.         "miss": 4,
  160.         "power": "Smash",
  161.         "exp": 350,
  162.         "money": 800,
  163.         "is_boss": True,
  164.         "boss_chance": 10,  # 1 in 10 chance to spawn
  165.         "drops": [
  166.             ("Kraken Tentacle Trident [Very Rare Item]", 25),
  167.             ("Smash [Rare Power]", 5),
  168.         ],
  169.     },
  170.     # Beast Jungle
  171.     "BJ1": {
  172.         "name": "Jungle Hunter",          # Level 100
  173.         "island": "Beast Jungle",
  174.         "damage": 255,
  175.         "health": 1275,
  176.         "miss": 5,
  177.         "power": "Weak Smash",
  178.         "exp": 230,
  179.         "money": 600,
  180.         "drops": [
  181.             ("Jungle Pelt [Common Item]", 3),
  182.             ("Weak Smash [Uncommon Power]", 4),
  183.         ],
  184.     },
  185.     "BJ2": {
  186.         "name": "Wild Chimpanzee",        # Level 110
  187.         "island": "Beast Jungle",
  188.         "damage": 280,
  189.         "health": 1400,
  190.         "miss": 5,
  191.         "power": "Weak Smash",
  192.         "exp": 250,
  193.         "money": 650,
  194.         "drops": [
  195.             ("Sharp Fang [Common Item]", 3),
  196.             ("Weak Smash [Uncommon Power]", 4),
  197.         ],
  198.     },
  199.     "BJ3": {
  200.         "name": "Stone Tomb Guardian",   # Level 120
  201.         "island": "Beast Jungle - Stone Tomb",
  202.         "damage": 305,
  203.         "health": 1525,
  204.         "miss": 5,
  205.         "power": "Flying Slash",
  206.         "exp": 270,
  207.         "money": 700,
  208.         "drops": [
  209.             ("Ancient Relic [Uncommon Item]", 5),
  210.             ("Flying Slash [Uncommon Power]", 4),
  211.         ],
  212.     },
  213.     "BJ4": {
  214.         "name": "Alpha Tiger",            # Level 130
  215.         "island": "Beast Jungle",
  216.         "damage": 330,
  217.         "health": 1650,
  218.         "miss": 4,
  219.         "power": "Flying Slash",
  220.         "exp": 290,
  221.         "money": 750,
  222.         "drops": [
  223.             ("Tiger Striped Hide [Rare Item]", 12),
  224.             ("Flying Slash [Uncommon Power]", 4),
  225.         ],
  226.     },
  227. }
  228.  
  229. POWERS_DATA = {
  230.     "Smash": {
  231.         "full_name": "Smash [Rare Power]",
  232.         "mult": 1.5,
  233.         "desc": "The Enemy's head hits the ground forming a large crack!",
  234.     },
  235.     "Weak Smash": {
  236.         "full_name": "Weak Smash [Uncommon Power]",
  237.         "mult": 1.1,
  238.         "desc": "The Enemy's head hits the ground forming a large crack!",
  239.     },
  240.     "Flying Slash": {
  241.         "full_name": "Flying Slash [Uncommon Power]",
  242.         "mult": 1.2,
  243.         "desc": "A sharp wind strikes the enemy!",
  244.     },
  245. }
  246.  
  247. ISLANDS = {
  248.     "Windmill Town": {
  249.         "travel_lvl": "0-10",
  250.         "arrival_msg": "steps in the grassy plain, the windmills scattered around the island create a peaceful ambience.",
  251.         "menu": "A. Fight | B. Travel | C. Upgrades | D. Stats | E. Inventory | F. Boat Shop | G. Paper | H. Behind Windmill",
  252.     },
  253.     "Marine Island": {
  254.         "travel_lvl": "20-30 (50 BOSS)",
  255.         "arrival_msg": "arrives at the island, covered in marine domes. Strong military willpower fills the air!",
  256.         "menu": "A. Fight | B. Travel | C. Upgrades | D. Stats | E. Inventory | F. Fishing | G. Fallen Note | H. Hero Recruiter",
  257.     },
  258.     "Gray Town": {
  259.         "travel_lvl": "40-50",
  260.         "arrival_msg": "looks around the gray, foggy island. Large piles of rubbish are scattered everywhere.",
  261.         "menu": "A. Fight | B. Travel | C. Upgrades | D. Stats | E. Inventory",
  262.     },
  263.     "Sandy Barren": {
  264.         "travel_lvl": "60-70",
  265.         "arrival_msg": "steps on the hot sand trickling with heat, spotting a nearby desert village.",
  266.         "menu": "A. Fight | B. Travel | C. Upgrades | D. Stats | E. Inventory | F. Pyramid",
  267.     },
  268.     "Kingfisher Depths": {
  269.         "travel_lvl": "80-90 (120 BOSS)",
  270.         "arrival_msg": "arrives at the beautiful underwater city, protected by aquabubble gear.",
  271.         "menu": "A. Fight | B. Travel | C. Upgrades | D. Stats | E. Inventory | F. Castle | G. City | H. Abyssal Reef",
  272.     },
  273.     "Beast Jungle": {
  274.         "travel_lvl": "100-130",
  275.         "arrival_msg": "arrives at the deep jungle, with plants, trees, and wildlife everywhere.",
  276.         "menu": "A. Fight | B. Travel | C. Upgrades | D. Stats | E. Inventory | F. Stone Tomb",
  277.     },
  278. }
  279.  
  280. BOAT_SPEEDS = {
  281.     "Old Boat": 10,
  282.     "Normal Boat": 5,
  283.     "Speedboat": 3,
  284.     "Lightspeed Yacht": 1,
  285. }
  286.  
  287. # ---------
  288. # player class
  289. # ----------
  290.  
  291.  
  292. class Player:
  293.  
  294.     def __init__(self, name="Roger"):
  295.         self.name = name
  296.         self.money = 0
  297.         self.points = 0
  298.         self.damage_points = 0
  299.         self.health_points = 0
  300.         self.base_damage = 5
  301.         self.base_health = 25
  302.         self.experience = 0
  303.         self.exp_needed = 2
  304.         self.put_points_amount = 1
  305.         self.delete_amount = 1
  306.  
  307.         self.inventory = []
  308.         self.power_inventory = []
  309.         self.max_powers = 5
  310.  
  311.         self.island = "Windmill Town"
  312.         self.boat = "Old Boat"
  313.         self.hero = False
  314.         self.villain = False
  315.         self.reputation = 0
  316.         self.bounty = 0
  317.  
  318.     @property
  319.     def max_health(self):
  320.         return self.base_health + (self.health_points * 25)
  321.  
  322.     @property
  323.     def damage(self):
  324.         return self.base_damage + (self.damage_points * 5)
  325.  
  326.     @property
  327.     def power_level(self):
  328.         return self.damage_points + self.health_points + self.points
  329.  
  330.     def add_exp(self, amount):
  331.         self.experience += amount
  332.         print(f"+{amount} Exp!")
  333.         while self.experience >= self.exp_needed:
  334.             self.experience -= self.exp_needed
  335.             self.exp_needed += 8
  336.             self.points += 1
  337.             print("✨ Level Up! +1 Stat Point!")
  338.  
  339.     def show_stats(self):
  340.         print("\n----------\nStats\n----------")
  341.         print(f"Power Level: {self.power_level}")
  342.         print(f"Damage: {self.damage} | Health: {self.max_health}")
  343.         print(f"Points Available: {self.points}")
  344.         print(f"Money: ${self.money}")
  345.         print(f"EXP: {self.experience}/{self.exp_needed}")
  346.         print(f"Hero: {'Yes' if self.hero else 'No'}")
  347.         print(f"Villain: {'Yes' if self.villain else 'No'}")
  348.         print(f"Reputation: {self.reputation} | Bounty: {self.bounty}")
  349.  
  350.     def manage_upgrades(self):
  351.         print(f"\nPoints Available: {self.points}")
  352.         print(
  353.             f"Dmg Pts: {self.damage_points} | HP Pts: {self.health_points} | Power Level: {self.power_level}"
  354.         )
  355.         choice = (
  356.             input(
  357.                 "A. Damage Points | B. Health Points | C. Set Allocation Amount | ?. Back: "
  358.             )
  359.             .strip()
  360.             .upper()
  361.         )
  362.  
  363.         if choice == "A":
  364.             self._allocate_points("damage")
  365.         elif choice == "B":
  366.             self._allocate_points("health")
  367.         elif choice == "C":
  368.             val = get_int_input("Set Allocation Amount: ", default=1)
  369.             self.put_points_amount = max(1, val)
  370.             print(f"Set point allocation step to {self.put_points_amount}.")
  371.  
  372.     def _allocate_points(self, stat_type):
  373.         if self.points <= 0:
  374.             print("No Points Available!")
  375.             return
  376.  
  377.         to_add = min(self.points, self.put_points_amount)
  378.         self.points -= to_add
  379.  
  380.         if stat_type == "damage":
  381.             self.damage_points += to_add
  382.             print(f"+{to_add} Damage Point(s)!")
  383.         else:
  384.             self.health_points += to_add
  385.             print(f"+{to_add} Health Point(s)!")
  386.  
  387.     def manage_inventory(self):
  388.         from collections import Counter
  389.        
  390.         # Count identical items
  391.         item_counts = Counter(self.inventory)
  392.        
  393.         # Format inventory as: "Item Name (4x)" or "Item Name" if count > 1
  394.         formatted_inventory = [
  395.             f"{item} ({count}x)" if count > 1 else item
  396.             for item, count in item_counts.items()
  397.         ]
  398.        
  399.         print(f"\nInventory ({len(self.inventory)} total items):")
  400.         if not formatted_inventory:
  401.             print("  [Empty]")
  402.         else:
  403.             for display_str in formatted_inventory:
  404.                 print(f"  - {display_str}")
  405.        
  406.         choice = (
  407.             input(
  408.                 "\nA. Delete Item | B. Set Delete Amount | C. Delete All of Item | D. Powers Menu | ?. Back: "
  409.             )
  410.             .strip()
  411.             .upper()
  412.         )
  413.  
  414.         if choice == "A":
  415.             item = input("Item name to delete: ").strip()
  416.             for _ in range(self.delete_amount):
  417.                 if item in self.inventory:
  418.                     self.inventory.remove(item)
  419.                     print(f"Deleted 1x {item}.")
  420.                 else:
  421.                     print(f"No '{item}' found.")
  422.                     break
  423.  
  424.         elif choice == "B":
  425.             self.delete_amount = max(
  426.                 1, get_int_input("Set Delete Amount: ", default=1)
  427.             )
  428.             print(f"Delete amount set to {self.delete_amount}.")
  429.  
  430.         elif choice == "C":
  431.             item = input("Item name to remove completely: ").strip()
  432.             count = self.inventory.count(item)
  433.             if count > 0:
  434.                 self.inventory = [i for i in self.inventory if i != item]
  435.                 print(f"Removed all {count}x {item}.")
  436.             else:
  437.                 print(f"No '{item}' found.")
  438.  
  439.         elif choice == "D":
  440.             self.manage_powers()
  441.  
  442.     def manage_powers(self):
  443.         choice = (
  444.             input("\nA. Equip Power | B. Unequip Power | ?. Back: ")
  445.             .strip()
  446.             .upper()
  447.         )
  448.         print(
  449.             f"Equipped Powers ({len(self.power_inventory)}/{self.max_powers}): {self.power_inventory}"
  450.         )
  451.  
  452.         if choice == "A":
  453.             if len(self.power_inventory) >= self.max_powers:
  454.                 print("Max Powers Equipped!")
  455.                 return
  456.             p_name = input("Type power item name from inventory: ").strip()
  457.             if p_name in self.inventory and p_name not in self.power_inventory:
  458.                 self.power_inventory.append(p_name)
  459.                 print(f"Successfully Equipped '{p_name}'!")
  460.             else:
  461.                 print("Item not in inventory or already equipped.")
  462.  
  463.         elif choice == "B":
  464.             p_name = input("Type power item name to unequip: ").strip()
  465.             if p_name in self.power_inventory:
  466.                 self.power_inventory.remove(p_name)
  467.                 print(f"Successfully Unequipped '{p_name}'.")
  468.             else:
  469.                 print("Power not equipped.")
  470.  
  471.     # --- Save & Load Implementation ---
  472.     def to_dict(self):
  473.         return {
  474.             "name": self.name,
  475.             "money": self.money,
  476.             "points": self.points,
  477.             "damage_points": self.damage_points,
  478.             "health_points": self.health_points,
  479.             "base_damage": self.base_damage,
  480.             "base_health": self.base_health,
  481.             "experience": self.experience,
  482.             "exp_needed": self.exp_needed,
  483.             "put_points_amount": self.put_points_amount,
  484.             "delete_amount": self.delete_amount,
  485.             "inventory": self.inventory,
  486.             "power_inventory": self.power_inventory,
  487.             "max_powers": self.max_powers,
  488.             "island": self.island,
  489.             "boat": self.boat,
  490.             "hero": self.hero,
  491.             "villain": self.villain,
  492.             "reputation": self.reputation,
  493.             "bounty": self.bounty,
  494.         }
  495.  
  496.     def save_game(self, filename="savegame.json"):
  497.         try:
  498.             with open(filename, "w") as f:
  499.                 json.dump(self.to_dict(), f, indent=4)
  500.             print("\n💾 Game saved successfully!")
  501.         except Exception as e:
  502.             print(f"\n❌ Save failed: {e}")
  503.  
  504.     @classmethod
  505.     def load_game(cls, filename="savegame.json"):
  506.         try:
  507.             with open(filename, "r") as f:
  508.                 data = json.load(f)
  509.             player = cls(name=data.get("name", "Roger"))
  510.             for key, val in data.items():
  511.                 setattr(player, key, val)
  512.             print("\n💾 Game loaded successfully!")
  513.             return player
  514.         except FileNotFoundError:
  515.             print("\n❌ No save file found.")
  516.             return None
  517.         except Exception as e:
  518.             print(f"\n❌ Error loading save file: {e}")
  519.             return None
  520.  
  521.  
  522. # ----------
  523. # helper func
  524. # ----------
  525.  
  526.  
  527. def get_int_input(prompt, default=0):
  528.     val = input(prompt).strip()
  529.     return int(val) if val.isdigit() else default
  530.  
  531.  
  532. def travel_system(player):
  533.     print("\n----------\nIslands\n----------")
  534.     for key, data in ISLANDS.items():
  535.         print(f"- {key} [Power Level {data['travel_lvl']}]")
  536.  
  537.     if player.hero:
  538.         print("PG. Paradise Guild")
  539.     if player.villain:
  540.         print("VL. Villain's Lair")
  541.  
  542.     choice = (
  543.         input(
  544.             "Pick Island Name or initial (A=Windmill, B=Marine, C=Gray, D=Sandy, E=Kingfisher, F=Beast Jungle): "
  545.         )
  546.         .strip()
  547.         .upper()
  548.     )
  549.  
  550.     dest_map = {
  551.         "A": "Windmill Town",
  552.         "B": "Marine Island",
  553.         "C": "Gray Town",
  554.         "D": "Sandy Barren",
  555.         "E": "Kingfisher Depths",
  556.         "F": "Beast Jungle",
  557.         "PG": "Paradise Guild",
  558.         "VL": "Villain's Lair",
  559.     }
  560.  
  561.     target = dest_map.get(choice, None)
  562.     if target and target in ISLANDS:
  563.         print(f"\n{player.name}: *Travelling...*")
  564.         time.sleep(BOAT_SPEEDS.get(player.boat, 5))
  565.         player.island = target
  566.         print(
  567.             f"Arrived at {target}!\n{player.name} {ISLANDS[target]['arrival_msg']}"
  568.         )
  569.     else:
  570.         print("Cancelled or Invalid Island.")
  571.  
  572.  
  573. # ----------
  574. # combat
  575. # ----------
  576.  
  577.  
  578. def start_combat(player, location_override=None):
  579.     target_island = location_override if location_override else player.island
  580.  
  581.     available = {
  582.         k: v for k, v in ENEMIES.items() if v["island"] == target_island
  583.     }
  584.     if not available:
  585.         print("No enemies found in this area.")
  586.         return
  587.  
  588.     print("\nEnemies:")
  589.     for k, v in available.items():
  590.         print(f"{k}. {v['name']}")
  591.     print("?. Back")
  592.  
  593.     choice = input("Select Enemy: ").strip().upper()
  594.     if choice == "?" or choice not in available:
  595.         print("Combat cancelled.")
  596.         return
  597.  
  598.     enemy_data = available[choice]
  599.  
  600.     if enemy_data.get("is_boss", False):
  601.         if random.randint(1, enemy_data["boss_chance"]) != 1:
  602.             print(
  603.                 f"\nLooks like {enemy_data['name']} is not here right now..."
  604.             )
  605.             return
  606.         print("\n[BOSS ENCOUNTER!]")
  607.  
  608.     enemy_hp = enemy_data["health"]
  609.     enemy_max_hp = enemy_data["health"]
  610.     player_hp = player.max_health
  611.  
  612.     enemy_power_lvl = round(enemy_data["damage"] / 5 + enemy_hp / 25) - 2
  613.     print(
  614.         f"\n{enemy_data['name']} [PL {enemy_power_lvl}] vs. {player.name} [PL {player.power_level}]"
  615.     )
  616.  
  617.     while enemy_hp > 0 and player_hp > 0:
  618.         print(
  619.             f"\n{enemy_data['name']}: {enemy_hp}/{enemy_max_hp} | You: {player_hp}/{player.max_health}"
  620.         )
  621.         timer_start = timeit.default_timer()
  622.         act = input("A. Attack | B. Use Powers | C. Flee: ").strip().upper()
  623.         elapsed = timeit.default_timer() - timer_start
  624.  
  625.         if act == "A":
  626.             if elapsed < 5:
  627.                 dmg = player.damage
  628.                 enemy_hp -= dmg
  629.                 print(f"You dealt {dmg} damage to {enemy_data['name']}!")
  630.             else:
  631.                 print("Took too long! Your attack missed!")
  632.  
  633.         elif act == "B":
  634.             print(f"\nEquipped Powers: {player.power_inventory}")
  635.             p_used = input(
  636.                 "Type Power Name (e.g. Smash, Flying Slash): "
  637.             ).strip()
  638.  
  639.             if p_used in POWERS_DATA and elapsed < 10:
  640.                 p_info = POWERS_DATA[p_used]
  641.                 if p_info["full_name"] in player.power_inventory:
  642.                     dmg = round(player.damage * p_info["mult"])
  643.                     enemy_hp -= dmg
  644.                     print(
  645.                         f"You unleashed '{p_used}' dealing {dmg} damage! {p_info['desc']}"
  646.                     )
  647.                 else:
  648.                     print("Power not equipped or invalid! Missed!")
  649.             else:
  650.                 print("Invalid power or timed out! Missed!")
  651.  
  652.         elif act == "C":
  653.             print("You fled the battle safely!")
  654.             return
  655.  
  656.         if enemy_hp <= 0:
  657.             break
  658.  
  659.         time.sleep(1)
  660.         if random.randint(1, enemy_data["miss"]) == 1:
  661.             print(f"{enemy_data['name']} Missed!")
  662.         else:
  663.             e_dmg = enemy_data["damage"]
  664.             player_hp -= e_dmg
  665.             print(f"{enemy_data['name']} dealt {e_dmg} damage!")
  666.  
  667.             if (
  668.                 enemy_data["power"]
  669.                 and random.randint(1, 3) == 1
  670.                 and enemy_data["power"] in POWERS_DATA
  671.             ):
  672.                 bonus_dmg = round(
  673.                     e_dmg * POWERS_DATA[enemy_data["power"]]["mult"] * 0.3
  674.                 )
  675.                 player_hp -= bonus_dmg
  676.                 print(
  677.                     f"{enemy_data['name']} unleashed '{enemy_data['power']}' for +{bonus_dmg} extra damage!"
  678.                 )
  679.  
  680.     if player_hp <= 0:
  681.         print(f"\n{player.name} got badly beaten up... Better luck next time.")
  682.     elif enemy_hp <= 0:
  683.         print(f"\nYou Defeated The {enemy_data['name']}!")
  684.         player.money += enemy_data["money"]
  685.         print(f"+${enemy_data['money']}!")
  686.  
  687.         # --- Diminishing EXP Returns Logic ---
  688.         level_difference = player.power_level - enemy_power_lvl
  689.         gained_exp = enemy_data["exp"]
  690.  
  691.         if level_difference > 9:
  692.             gained_exp = max(1, round(enemy_data["exp"] * 0.1))
  693.             print("⚠️ Enemy level is too low! EXP gained reduced by 90%.")
  694.  
  695.         player.add_exp(gained_exp)
  696.  
  697.         for item_name, chance in enemy_data.get("drops", []):
  698.             if random.randint(1, chance) == 1:
  699.                 player.inventory.append(item_name)
  700.                 print(f"DROPPED: '{item_name}'!")
  701.  
  702.  
  703. def fishing_activity(player):
  704.     print("\nFishing...")
  705.     time.sleep(3)
  706.     if random.randint(1, 2) == 1:
  707.         res = random.randint(1, 4)
  708.         if res == 1:
  709.             player.money += 300
  710.             print("Caught old boots and sold them for $300!")
  711.         elif res == 2:
  712.             player.inventory.append("Old Pile of Clothes [Uncommon Item]")
  713.             print("Found Old Pile of Clothes [Uncommon Item]!")
  714.         elif res == 3:
  715.             player.inventory.append("Gold Nuggets [Uncommon Item]")
  716.             print("Found Gold Nuggets [Uncommon Item]!")
  717.         elif res == 4:
  718.             if random.randint(1, 18) == 1:
  719.                 player.inventory.append("Golden Swordfish [Very Rare Item]")
  720.                 print("CAUGHT: Golden Swordfish [Very Rare Item]!")
  721.             else:
  722.                 print("A rare Golden Swordfish got away...")
  723.     else:
  724.         print("You didn't catch anything this time.")
  725.  
  726.  
  727. def cheat_menu(player):
  728.     print("\n[ CHEAT / RESTORE MENU ]")
  729.     print(
  730.         "A. Money | B. Damage Pts | C. Health Pts | D. Teleport | E. Add Item | F. Set Points | G. Set Boat"
  731.     )
  732.     opt = input("Choice: ").strip().upper()
  733.  
  734.     if opt == "A":
  735.         player.money = get_int_input("Set Money: ")
  736.     elif opt == "B":
  737.         player.damage_points = get_int_input("Set Damage Points: ")
  738.     elif opt == "C":
  739.         player.health_points = get_int_input("Set Health Points: ")
  740.     elif opt == "D":
  741.         isl = input("Island Name: ").strip()
  742.         player.island = isl
  743.     elif opt == "E":
  744.         itm = input("Item Name: ").strip()
  745.         amt = get_int_input("Amount: ", default=1)
  746.         for _ in range(amt):
  747.             player.inventory.append(itm)
  748.         print(f"Added {amt}x {itm}.")
  749.     elif opt == "F":
  750.         player.points = get_int_input("Set Stat Points: ")
  751.     elif opt == "G":
  752.         player.boat = input("Boat Name: ").strip()
  753.  
  754.  
  755. # ----------
  756. # game loop
  757. # ----------
  758.  
  759.  
  760. def main():
  761.     print(
  762.         "Conquer The World • Version 1.4 Refresh • Inspired by Blox Fruits/One Piece"
  763.     )
  764.  
  765.     player = None
  766.     load_choice = (
  767.         input("Would you like to load a saved game? (Y/N): ").strip().upper()
  768.     )
  769.     if load_choice == "Y":
  770.         player = Player.load_game()
  771.  
  772.     if not player:
  773.         p_name = input("Enter your character name (Default 'Roger'): ").strip()
  774.         player = Player(name=p_name if p_name else "Roger")
  775.  
  776.     while True:
  777.         current_isl = player.island
  778.         isl_info = ISLANDS.get(current_isl, {})
  779.  
  780.         print(f"\n----------\n{current_isl}\n----------")
  781.         prompt = isl_info.get(
  782.             "menu",
  783.             "A. Fight | B. Travel | C. Upgrades | D. Stats | E. Inventory",
  784.         )
  785.         print(f"{prompt} | S. Save Game | Q. Quit")
  786.         action = input("Choice: ").strip().upper()
  787.  
  788.         if action == "A":
  789.             if current_isl == "Kingfisher Depths":
  790.                 start_combat(
  791.                     player, location_override="Kingfisher Depths - Fight"
  792.                 )
  793.             else:
  794.                 start_combat(player)
  795.  
  796.         elif action == "B":
  797.             travel_system(player)
  798.         elif action == "C":
  799.             player.manage_upgrades()
  800.         elif action == "D":
  801.             player.show_stats()
  802.         elif action == "E":
  803.             player.manage_inventory()
  804.         elif action == "F":
  805.             if current_isl == "Windmill Town":
  806.                 print(f"\nMoney: ${player.money}")
  807.                 b_choice = (
  808.                     input(
  809.                         "A. Normal Boat ($2500) | B. Speedboat ($10000) | C. Yacht ($250000): "
  810.                     )
  811.                     .strip()
  812.                     .upper()
  813.                 )
  814.                 costs = {
  815.                     "A": ("Normal Boat", 2500),
  816.                     "B": ("Speedboat", 10000),
  817.                     "C": ("Lightspeed Yacht", 250000),
  818.                 }
  819.                 if b_choice in costs:
  820.                     b_name, cost = costs[b_choice]
  821.                     if player.money >= cost:
  822.                         player.money -= cost
  823.                         player.boat = b_name
  824.                         print(f"Purchased {b_name}!")
  825.                     else:
  826.                         print("Not enough cash!")
  827.             elif current_isl == "Marine Island":
  828.                 fishing_activity(player)
  829.             elif current_isl == "Kingfisher Depths":
  830.                 start_combat(
  831.                     player, location_override="Kingfisher Depths - Castle"
  832.                 )
  833.             elif current_isl == "Beast Jungle":
  834.                 start_combat(
  835.                     player, location_override="Beast Jungle - Stone Tomb"
  836.                 )
  837.  
  838.         elif action == "G":
  839.             if current_isl == "Windmill Town":
  840.                 print(
  841.                     "\nPaper: Welcome to Conquer The World! Defeat enemies, gain exp, and upgrade stats!"
  842.                 )
  843.             elif current_isl == "Marine Island":
  844.                 print(
  845.                     "\nFallen Note: Darkbane... The ultimate villain. We lost against him."
  846.                 )
  847.  
  848.         elif action == "H":
  849.             if current_isl == "Windmill Town":
  850.                 rec = input("Join Villains? (Y/N): ").strip().upper()
  851.                 if rec == "Y":
  852.                     player.villain, player.hero = True, False
  853.                     print("Registered as Villain!")
  854.             elif current_isl == "Marine Island":
  855.                 rec = input("Join Heroes? (Y/N): ").strip().upper()
  856.                 if rec == "Y":
  857.                     player.hero, player.villain = True, False
  858.                     print("Registered as Hero!")
  859.             elif current_isl == "Kingfisher Depths":
  860.                 start_combat(
  861.                     player,
  862.                     location_override="Kingfisher Depths - Abyssal Reef",
  863.                 )
  864.  
  865.         elif action == "S":
  866.             player.save_game()
  867.  
  868.         elif action == "Q":
  869.             confirm = input("Save before quitting? (Y/N): ").strip().upper()
  870.             if confirm == "Y":
  871.                 player.save_game()
  872.             print("Thanks for playing!")
  873.             break
  874.  
  875.         elif action == "Z":
  876.             cheat_menu(player)
  877.  
  878.  
  879. if __name__ == "__main__":
  880.     main()
  881.  
  882. # notes to self: (1,3) are for commons, (1,4-8) are for uncommons, (1,9-14) are for rares, (1,15-50) are for Very Rares, (1,51-100) are for Ultra Rares, (1,101-300) are for Ancients and (1,301+) are for Mythics1
Tags: python coding
Advertisement
Add Comment
Please, Sign In to add comment