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/demons.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
201 lines (117 sloc)
3.49 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> | |
// Standard super class used by player Demons and Enemy demons | |
class Demon { | |
private: | |
std::string name; | |
public: | |
std::string race; | |
std::string alignment; | |
std::string flag; | |
int level; | |
int HP; | |
int battle_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 | |
std::vector<std::string> magic_skill_list; | |
int damage; | |
Demon(std::string _flag, std::string _name, std::string _race, std::string _alignment, int _level, | |
int _st, int _ma, int _vi, int _ag, int _lu) | |
/* these values will be used as growth values/rates */ | |
{ | |
flag = _flag; | |
name = _name; | |
race = _race; | |
alignment = _alignment; | |
level = _level; | |
st = _st; | |
ma = _ma; | |
vi = _vi; | |
ag = _ag; | |
lu = _lu; | |
HP = (level + vi) * 6; | |
battle_HP = HP; | |
MP = (level + ma) * 3; | |
} | |
void print_name() { | |
std::cout << name; | |
} | |
void print_stats() { | |
std::cout << "UNIQUE FLAG: " << flag << "\nName: " << name << "\nRace : " << race << "\nAlignment : " << alignment << "\nLevel : " | |
<< level << "\nHP: " | |
<< battle_HP << "/" << HP << "\nMP: " << MP << "\nStrength: " << st << "\nMagic: " << ma << "\nVitality: " << | |
vi << "\nAgility: " << ag << "\nLuck: " << lu << std::endl << std::endl; | |
} | |
void level_up() { | |
level += 1; | |
int stat; | |
std::cout << name << " grows 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 (!(std::cin >> stat) || stat < 1 || stat > 5) { | |
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; | |
battle_HP = HP; | |
} | |
int normal_attack() { | |
damage = st * 2; | |
std::cout << damage << std::endl; | |
return damage; | |
} | |
int phys_skill(std::string phys_name, int skill_power) { | |
damage = ((level + st) * skill_power)/15; | |
for (int i = 0; i < phys_name.length(); i++) { | |
phys_name[i] = toupper(phys_name[i]); | |
} | |
std::cout << phys_name << std::endl; | |
std::cout << damage << std::endl; | |
return damage; | |
} | |
int hp_phys_skill(std::string hphys_name, int skill_power) { | |
damage = HP * skill_power * 0.0114; | |
for (int i = 0; i < hphys_name.length(); i++) { | |
hphys_name[i] = toupper(hphys_name[i]); | |
} | |
std::cout << hphys_name << std::endl; | |
std::cout << damage << std::endl; | |
return damage; | |
} | |
int magic_skill(std::string magic_name, int skill_power) { | |
damage = (skill_power + (skill_power* (ma / 30)))/1.5; | |
for (int i = 0; i < magic_name.length(); i++) { | |
magic_name[i] = toupper(magic_name[i]); | |
} | |
std::cout << magic_name << std::endl; | |
std::cout << damage << std::endl; | |
return damage; | |
} | |
// finally working properly | |
int inflict_damage(Demon* other) { | |
other->battle_HP = other->battle_HP - damage; | |
return other->battle_HP; | |
} | |
}; |