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 "equipment.h"
void Equipment::randomRarity(){
srand (time(NULL));
int randomR = (rand() % 100) + 1;
if(randomR < 40){
rarity = "common";
}
else if(randomR >= 40 && randomR < 60){
rarity = "uncommon";
}
else if(randomR >=60 && randomR < 75){
rarity = "rare";
}
else if(randomR >=75 && randomR < 90){
rarity = "epic";
}
else{
rarity = "legendary";
}
}
void Equipment::bonusStats(){
int randomStat;
if(rarity == "uncommon"){
srand (time(NULL));
randomStat = (rand() % 5);
stats[randomStat] += 3;
}
else if (rarity == "rare"){
srand (time(NULL));
randomStat = (rand() % 5);
stats[randomStat] += 5;
srand (time(NULL) + 1);
randomStat = (rand() % 5);
stats[randomStat] += 5;
}
else if (rarity == "epic"){
srand (time(NULL));
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 1);
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 2);
randomStat = (rand() % 5);
stats[randomStat] += 7;
}
else if (rarity == "epic"){
srand (time(NULL));
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 1);
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 2);
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 3);
randomStat = (rand() % 5);
stats[randomStat] += 7;
}
else if (rarity == "legendary"){
srand (time(NULL));
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 1);
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 2);
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 3);
randomStat = (rand() % 5);
stats[randomStat] += 7;
srand (time(NULL) + 4);
randomStat = (rand() % 5);
stats[randomStat] += 7;
}
}
void Equipment::getStats(){
erase();
mvprintw(LINES/2 - 1,(COLS-strlen(("Rarity: " + rarity).c_str()))/2,"%s", ("Rarity: " + rarity).c_str());
mvprintw(LINES/2,(COLS-strlen(("Strength: " + to_string(stats[0])).c_str()))/2,"%s", ("Strength: " + to_string(stats[0])).c_str());
mvprintw(LINES/2 + 1,(COLS-strlen(("Intelligence: " + to_string(stats[1])).c_str()))/2,"%s", ("Intelligence: " + to_string(stats[1])).c_str());
mvprintw(LINES/2 + 2,(COLS-strlen(("Dexterity: " + to_string(stats[2])).c_str()))/2,"%s", ("Dexterity: " + to_string(stats[2])).c_str());
mvprintw(LINES/2 + 3,(COLS-strlen(("Hp: " + to_string(stats[3])).c_str()))/2,"%s", ("Hp: " + to_string(stats[3])).c_str());
mvprintw(LINES/2 + 4,(COLS-strlen(("Condition: " + to_string(stats[4])).c_str()))/2,"%s", ("Condition: " + to_string(stats[4])).c_str());
refresh();
}
void Weapon::randomWeapon(){
srand (time(NULL));
int randomW = (rand() % 2) + 1;
if (randomW == 1){
weaponType = "sword";
}
else{
weaponType = "staff";
}
}
void Armor::randomArmor(){
srand (time(NULL));
int randomW = (rand() % 5) + 1;
if (randomW == 1){
armorType = "helmet";
}
else if (randomW == 2){
armorType = "chestplate";
}
else if (randomW == 3){
armorType = "gloves";
}
else if (randomW == 4){
armorType = "leggings";
}
else{
armorType = "boots";
}
}
void Weapon::baseStats(){
if(weaponType == "sword"){
stats[0] += 5;
}
else if (weaponType == "staff"){
stats[1] += 5;
}
}
Armor::Armor(){
randomRarity();
if(rarity != "common"){
bonusStats();
}
randomArmor();
}
string Weapon::getWeaponT(){
return weaponType;
}
string Armor::getArmorT(){
return armorType;
}