#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
// define the player class
class Player {
public:
string name;
int maxHealth;
int currentHealth;
int hunger;
int thirst;
int currentStamina;
int maxStamina;
vector<string> inventory;
bool isAlive;
// constructor
Player(string playerName) {
name = playerName;
maxHealth = 100;
currentHealth = 100;
hunger = 0;
thirst = 0;
maxStamina = 100;
currentStamina = 100;
isAlive = true;
}
// methods for eating, drinking, and taking damage
void eat(int foodValue) {
hunger -= foodValue;
if (hunger < 0) hunger = 0;
currentHealth += foodValue;
if (currentHealth > maxHealth) currentHealth = maxHealth;
}
void drink(int waterValue) {
thirst -= waterValue;
if (thirst < 0) thirst = 0;
currentHealth += waterValue;
if (currentHealth > maxHealth) currentHealth = maxHealth;
}
void takeDamage(int damage) {
currentHealth -= damage;
if (currentHealth <= 0) {
isAlive = false;
cout << "You have died. Game over." << endl;
}
}
// method for adding items to inventory
void addItem(string item) {
inventory.push_back(item);
}
// method for using items in inventory
void useItem(int index) {
string item = inventory[index];
if (item == "bandage") {
currentHealth += 20;
if (currentHealth > maxHealth) currentHealth = maxHealth;
inventory.erase(inventory.begin() + index);
} else if (item == "water bottle") {
drink(20);
inventory.erase(inventory.begin() + index);
} else if (item == "food ration") {
eat(20);
inventory.erase(inventory.begin() + index);
}
}
// method for regenerating stamina
void regenerateStamina() {
currentStamina += 5;
if (currentStamina > maxStamina) currentStamina = maxStamina;
}
// method for sprinting
void sprint() {
if (currentStamina >= 20) {
currentStamina -= 20;
cout << "You are now sprinting." << endl;
} else {
cout << "Not enough stamina to sprint." << endl;
}
}
// method for jumping
void jump() {
if (currentStamina >= 10) {
currentStamina -= 10;
cout << "You jump and feel alive!" << endl;
} else {
cout << "Not enough stamina to jump." << endl;
}
}
};
// define the world class
class World {
public:
int seed;
vector<vector<int>> terrain;
vector<string> enemyTypes;
vector<string> items;
vector<int> enemySpawnRate;
vector<int> itemSpawnRate;
// constructor
World(int worldSeed) {
seed = worldSeed;
enemyTypes = {"zombie", "wolf", "bear", "bandit"};
enemySpawnRate = {5, 2, 1, 3};
items = {"bandage", "water bottle", "