Skip to content
Permalink
main
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
#pragma once
#include <vector>
#include <iostream>
// MAKE THIS A CHILD CLASS?
class Player {
private:
std::string pname;
public:
std::vector<int> party; // would have been used to determine which demons the player has in their party
std::string alignment;
int level;
int HP;
int MP;
int st; // Strength of physical attacks and skills
int ma; // Influences total MP amount and strength and accuracy of magic skills
int vi; // Influences total HP amount
int ag; // Influences physical accuracy, chance of critical, chance of evasion and chance of escaping battle
int lu; // Influences chance of magical evasion, magic accuracy, escaping battle, recovering from ailment
Player(std::string _alignment, int _level,
int _st, int _ma, int _vi, int _ag, int _lu) {
alignment = _alignment;
level = _level;
st = _st;
ma = _ma;
vi = _vi;
ag = _ag;
lu = _lu;
HP = (level + vi) * 6;
MP = (level + ma) * 3;
}
//Name getter
std::string get_pname() {
return pname;
}
//Name setter
void set_pname() {
cin >> pname;
}
//Prints player name
void print_pname() {
std::cout << pname << std::endl;
}
void level_up() {
level += 1;
int stat;
std::cout << "You grow stronger. Choose one stat to improve by 1 point.\n1. Strength\n2. Magic\n"
<< "3. Vitality\n4. Agility\n5. Luck" << std::endl;
// create exception for when anything other than a number from 1 to 5 is input
while (!(cin >> stat) || stat < 1 || stat > 5) /* this condition makes it so if the user inputs anything that is not a number
from 1 to 5, the input is ignored */ {
std::cout << "Choose one of the options above." << std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
if (stat == 1) {
st += 1;
}
else if (stat == 2) {
ma += 1;
}
else if (stat == 3) {
vi += 1;
}
else if (stat == 4) {
ag += 1;
}
else if (stat == 5) {
lu += 1;
}
HP = (level + vi) * 6;
MP = (level + ma) * 3;
}
void print_stats() {
std::cout << "Name: " << pname << "\nAlignment: " << alignment << "\nLevel: "
<< level << "\nHP: "
<< HP << "\nMP: " << MP << "\nStrength: " << st << "\nMagic: " << ma << "\nVitality: " <<
vi << "\nAgility: " << ag << "\nLuck: " << lu << std::endl << std::endl;
}
};