import random
import time
# ------------------------------
# Line 1: Game Constants
# ------------------------------
MAX_HEALTH = 100import [Link].*;
class Player {
String name;
int health;
int energy;
int gold;
List<String> inventory;
static final int MAX_HEALTH = 100;
static final int MAX_ENERGY = 50;
Player(String name) {
[Link] = name;
[Link] = MAX_HEALTH;
[Link] = MAX_ENERGY;
[Link] = 0;
[Link] = new ArrayList<>();
int attack(Enemy enemy) {
if (energy <= 0) {
[Link]("You are too tired to attack!");
return 0;
int damage = new Random().nextInt(11) + 5;
energy -= 5;
[Link](name + " attacks " + [Link] + " for " + damage + " damage!");
return damage;
void heal() {
if ([Link]("Potion")) {
health = [Link](MAX_HEALTH, health + 30);
[Link]("Potion");
[Link](name + " drinks a potion and heals to " + health + " HP!");
} else {
[Link]("No potion available!");
void rest() {
energy = [Link](MAX_ENERGY, energy + 20);
[Link](name + " rests and recovers energy to " + energy + ".");
void status() {
[Link]("--- " + name + "'s Status ---");
[Link]("Health: " + health + "/" + MAX_HEALTH);
[Link]("Energy: " + energy + "/" + MAX_ENERGY);
[Link]("Gold: " + gold);
[Link]("Inventory: " + inventory);
[Link]("---------------------------");
class Enemy {
String type;
int health;
int attackPower;
static final String[] ENEMY_TYPES = {"Goblin", "Orc", "Dragon", "Bandit", "Wolf"};
Enemy() {
Random rand = new Random();
[Link] = ENEMY_TYPES[[Link](ENEMY_TYPES.length)];
[Link] = [Link](61) + 20;
[Link] = [Link](16) + 5;
void attack(Player player) {
int damage = new Random().nextInt(attackPower) + 1;
[Link] -= damage;
[Link](type + " attacks " + [Link] + " for " + damage + " damage!");
public class AdventureGame {
static Scanner scanner = new Scanner([Link]);
static void explore(Player player) {
[Link]("You venture into the unknown...");
try { [Link](1000); } catch (InterruptedException e) {}
String[] encounters = {"enemy", "treasure", "nothing"};
String encounter = encounters[new Random().nextInt([Link])];
if ([Link]("enemy")) {
Enemy enemy = new Enemy();
[Link]("A wild " + [Link] + " appears!");
battle(player, enemy);
} else if ([Link]("treasure")) {
int goldFound = new Random().nextInt(41) + 10;
[Link] += goldFound;
[Link]("You found " + goldFound + " gold!");
if (new Random().nextDouble() < 0.3) {
[Link]("Potion");
[Link]("You also found a Potion!");
} else {
[Link]("Nothing happens. The path is quiet.");
static void battle(Player player, Enemy enemy) {
while ([Link] > 0 && [Link] > 0) {
[Link]("\nChoose an action:");
[Link]("1. Attack");
[Link]("2. Heal");
[Link]("3. Run");
String choice = [Link]();
if ([Link]("1")) {
int damage = [Link](enemy);
[Link] -= damage;
if ([Link] > 0) [Link](player);
} else if ([Link]("2")) {
[Link]();
if ([Link] > 0) [Link](player);
} else if ([Link]("3")) {
[Link]("You run away safely!");
return;
} else {
[Link]("Invalid choice!");
[Link]();
if ([Link] <= 0) {
[Link]("You have been defeated...");
} else if ([Link] <= 0) {
[Link]("You defeated the " + [Link] + "!");
int loot = new Random().nextInt(26) + 5;
[Link] += loot;
[Link]("You loot " + loot + " gold from the enemy.");
}
}
static void shop(Player player) {
[Link]("\nWelcome to the shop!");
[Link]("1. Buy Potion (20 gold)");
[Link]("2. Exit");
String choice = [Link]();
if ([Link]("1")) {
if ([Link] >= 20) {
[Link] -= 20;
[Link]("Potion");
[Link]("You bought a Potion!");
} else {
[Link]("Not enough gold!");
} else {
[Link]("You leave the shop.");
public static void main(String[] args) {
[Link]("Welcome to the Adventure Game!");
[Link]("Enter your hero's name: ");
String name = [Link]();
Player player = new Player(name);
while ([Link] > 0) {
[Link]("\nWhat would you like to do?");
[Link]("1. Explore");
[Link]("2. Rest");
[Link]("3. Shop");
[Link]("4. Status");
[Link]("5. Quit");
String choice = [Link]();
if ([Link]("1")) {
explore(player);
} else if ([Link]("2")) {
[Link]();
} else if ([Link]("3")) {
shop(player);
} else if ([Link]("4")) {
[Link]();
} else if ([Link]("5")) {
[Link]("Thanks for playing!");
break;
} else {
[Link]("Invalid choice!");
[Link]("Game Over.");
MAX_ENERGY = 50
ENEMY_TYPES = ["Goblin", "Orc", "Dragon", "Bandit", "Wolf"]
# ------------------------------
# Line 10: Player Class
# ------------------------------
class Player:
def __init__(self, name):
[Link] = name
[Link] = MAX_HEALTH
[Link] = MAX_ENERGY
[Link] = []
[Link] = 0
def attack(self, enemy):
if [Link] <= 0:
print("You are too tired to attack!")
return 0
damage = [Link](5, 15)
[Link] -= 5
print(f"{[Link]} attacks {[Link]} for {damage} damage!")
return damage
def heal(self):
if "Potion" in [Link]:
[Link] = min(MAX_HEALTH, [Link] + 30)
[Link]("Potion")
print(f"{[Link]} drinks a potion and heals to {[Link]} HP!")
else:
print("No potion available!")
def rest(self):
[Link] = min(MAX_ENERGY, [Link] + 20)
print(f"{[Link]} rests and recovers energy to {[Link]}.")
def status(self):
print(f"--- {[Link]}'s Status ---")
print(f"Health: {[Link]}/{MAX_HEALTH}")
print(f"Energy: {[Link]}/{MAX_ENERGY}")
print(f"Gold: {[Link]}")
print(f"Inventory: {[Link]}")
print("---------------------------")
# ------------------------------
# Line 60: Enemy Class
# ------------------------------
class Enemy:
def __init__(self):
[Link] = [Link](ENEMY_TYPES)
[Link] = [Link](20, 80)
self.attack_power = [Link](5, 20)
def attack(self, player):
damage = [Link](1, self.attack_power)
[Link] -= damage
print(f"{[Link]} attacks {[Link]} for {damage} damage!")
# ------------------------------
# Line 80: Game Functions
# ------------------------------
def explore(player):
print("You venture into the unknown...")
[Link](1)
encounter = [Link](["enemy", "treasure", "nothing"])
if encounter == "enemy":
enemy = Enemy()
print(f"A wild {[Link]} appears!")
battle(player, enemy)
elif encounter == "treasure":
gold_found = [Link](10, 50)
[Link] += gold_found
print(f"You found {gold_found} gold!")
if [Link]() < 0.3:
[Link]("Potion")
print("You also found a Potion!")
else:
print("Nothing happens. The path is quiet.")
def battle(player, enemy):
while [Link] > 0 and [Link] > 0:
print("\nChoose an action:")
print("1. Attack")
print("2. Heal")
print("3. Run")
choice = input("> ")
if choice == "1":
damage = [Link](enemy)
[Link] -= damage
if [Link] > 0:
[Link](player)
elif choice == "2":
[Link]()
if [Link] > 0:
[Link](player)
elif choice == "3":
print("You run away safely!")
return
else:
print("Invalid choice!")
[Link]()
if [Link] <= 0:
print("You have been defeated...")
elif [Link] <= 0:
print(f"You defeated the {[Link]}!")
loot = [Link](5, 30)
[Link] += loot
print(f"You loot {loot} gold from the enemy.")
def shop(player):
print("\nWelcome to the shop!")
print("1. Buy Potion (20 gold)")
print("2. Exit")
choice = input("> ")
if choice == "1":
if [Link] >= 20:
[Link] -= 20
[Link]("Potion")
print("You bought a Potion!")
else:
print("Not enough gold!")
else:
print("You leave the shop.")
# ------------------------------
# Line 150: Main Game Loop
# ------------------------------
def main():
print("Welcome to the Adventure Game!")
name = input("Enter your hero's name: ")
player = Player(name)
while [Link] [Link].*;
class Player {
String name;
int health;
int energy;
int gold;
List<String> inventory;
static final int MAX_HEALTH = 100;
static final int MAX_ENERGY = 50;
Player(String name) {
[Link] = name;
[Link] = MAX_HEALTH;
[Link] = MAX_ENERGY;
[Link] = 0;
[Link] = new ArrayList<>();
int attack(Enemy enemy) {
if (energy <= 0) {
[Link]("You are too tired to attack!");
return 0;
int damage = new Random().nextInt(11) + 5;
energy -= 5;
[Link](name + " attacks " + [Link] + " for " + damage + " damage!");
return damage;
void heal() {
if ([Link]("Potion")) {
health = [Link](MAX_HEALTH, health + 30);
[Link]("Potion");
[Link](name + " drinks a potion and heals to " + health + " HP!");
} else {
[Link]("No potion available!");
}
void rest() {
energy = [Link](MAX_ENERGY, energy + 20);
[Link](name + " rests and recovers energy to " + energy + ".");
void status() {
[Link]("--- " + name + "'s Status ---");
[Link]("Health: " + health + "/" + MAX_HEALTH);
[Link]("Energy: " + energy + "/" + MAX_ENERGY);
[Link]("Gold: " + gold);
[Link]("Inventory: " + inventory);
[Link]("---------------------------");
class Enemy {
String type;
int health;
int attackPower;
static final String[] ENEMY_TYPES = {"Goblin", "Orc", "Dragon", "Bandit", "Wolf"};
Enemy() {
Random rand = new Random();
[Link] = ENEMY_TYPES[[Link](ENEMY_TYPES.length)];
[Link] = [Link](61) + 20;
[Link] = [Link](16) + 5;
}
void attack(Player player) {
int damage = new Random().nextInt(attackPower) + 1;
[Link] -= damage;
[Link](type + " attacks " + [Link] + " for " + damage + " damage!");
public class AdventureGame {
static Scanner scanner = new Scanner([Link]);
static void explore(Player player) {
[Link]("You venture into the unknown...");
try { [Link](1000); } catch (InterruptedException e) {}
String[] encounters = {"enemy", "treasure", "nothing"};
String encounter = encounters[new Random().nextInt([Link])];
if ([Link]("enemy")) {
Enemy enemy = new Enemy();
[Link]("A wild " + [Link] + " appears!");
battle(player, enemy);
} else if ([Link]("treasure")) {
int goldFound = new Random().nextInt(41) + 10;
[Link] += goldFound;
[Link]("You found " + goldFound + " gold!");
if (new Random().nextDouble() < 0.3) {
[Link]("Potion");
[Link]("You also found a Potion!");
} else {
[Link]("Nothing happens. The path is quiet.");
static void battle(Player player, Enemy enemy) {
while ([Link] > 0 && [Link] > 0) {
[Link]("\nChoose an action:");
[Link]("1. Attack");
[Link]("2. Heal");
[Link]("3. Run");
String choice = [Link]();
if ([Link]("1")) {
int damage = [Link](enemy);
[Link] -= damage;
if ([Link] > 0) [Link](player);
} else if ([Link]("2")) {
[Link]();
if ([Link] > 0) [Link](player);
} else if ([Link]("3")) {
[Link]("You run away safely!");
return;
} else {
[Link]("Invalid choice!");
}
[Link]();
if ([Link] <= 0) {
[Link]("You have been defeated...");
} else if ([Link] <= 0) {
[Link]("You defeated the " + [Link] + "!");
int loot = new Random().nextInt(26) + 5;
[Link] += loot;
[Link]("You loot " + loot + " gold from the enemy.");
static void shop(Player player) {
[Link]("\nWelcome to the shop!");
[Link]("1. Buy Potion (20 gold)");
[Link]("2. Exit");
String choice = [Link]();
if ([Link]("1")) {
if ([Link] >= 20) {
[Link] -= 20;
[Link]("Potion");
[Link]("You bought a Potion!");
} else {
[Link]("Not enough gold!");
} else {
[Link]("You leave the shop.");
}
}
public static void main(String[] args) {
[Link]("Welcome to the Adventure Game!");
[Link]("Enter your hero's name: ");
String name = [Link]();
Player player = new Player(name);
while ([Link] > 0) {
[Link]("\nWhat would you like to do?");
[Link]("1. Explore");
[Link]("2. Rest");
[Link]("3. Shop");
[Link]("4. Status");
[Link]("5. Quit");
String choice = [Link]();
if ([Link]("1")) {
explore(player);
} else if ([Link]("2")) {
[Link]();
} else if ([Link]("3")) {
shop(player);
} else if ([Link]("4")) {
[Link]();
} else if ([Link]("5")) {
[Link]("Thanks for playing!");
break;
} else {
[Link]("Invalid choice!");
[Link]("Game Over.");
}th > 0:
print("\nWhat would you like to do?")
def shop(player):
print("\nWelcome to the shop!")
print("1. Buy Potion (20 gold)")
print("2. Exit")