Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <string>
#include <cctype>
#include "character.h"
/* Constructor for any character object. */
Character::Character()
{
id = 1; /* Used for identifying characters that might have the same same. */
max_HP = 1;
current_HP = 1;
defense = 1; /* This will be subtracted from any incoming damage. */
strength = 1; /* The base amount of damage the character will inflict while attacking. */
char_class = "Peasant"; /* Placeholder for the time being. Might be used to implement class specific abilities. */
}
/* Method used for creating a character. Currently it is setup to create a player character. */
void Character::new_character()
{
std::string choice; /* Variable to store the player's choice to create or not create a new character. */
std::cout << "Would you like to create your hero? (Y/N)\n"; std::cin >> choice;
if ( choice == "Y" || choice == "y") /* If the player confirms, a base character will be created with random attributes set for a base character. */
{
max_HP = rand() % 30+10;
current_HP = max_HP;
defense = rand() % 5;
strength = rand() % 10+6;
/* Comfirmation of the attributes is displayed to the player. */
std::cout << "\n" << std::endl;
std::cout << "A hero has been created with " << max_HP << " max hitpoints" << std::endl;
std::cout << current_HP << " current hitpoints" << std::endl;
std::cout << strength << " strength" << std::endl;
std::cout << defense << " defense" << std::endl;
std::cout << "and of the class " << char_class << ". \n" << std::endl;
}
else
{
/* In case the user does not want to create a character and not play. */
std::cout << "Guess the world will end." << std::endl;
exit(0);
}
}