Permalink
Cannot retrieve contributors at this time
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?
ASCII_Game_Project/player.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
134 lines (79 sloc)
2.29 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} | |
}; | |