Initialize files from GitLab repository
This commit is contained in:
71
lib/people/Opponent.cpp
Normal file
71
lib/people/Opponent.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "../../include/people/Opponent.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
// This constructor just initializes the User to null.
|
||||
|
||||
Opponent::Opponent()
|
||||
{
|
||||
name = "Stick McStickington";
|
||||
current_health = 0;
|
||||
max_health = 0;
|
||||
level = 1;
|
||||
base_damage = 1;
|
||||
max_damage = 1;
|
||||
}
|
||||
|
||||
Opponent::Opponent(string opponent_name, int opponent_level, int base, int max)
|
||||
{
|
||||
name = opponent_name;
|
||||
current_health = opponent_level * 100;
|
||||
max_health = current_health;
|
||||
level = opponent_level;
|
||||
base_damage = base;
|
||||
max_damage = max;
|
||||
|
||||
}
|
||||
|
||||
//SETTER FUNCTIONS
|
||||
void Opponent::setOpponentHealth(int damage_taken)
|
||||
{
|
||||
current_health = current_health - damage_taken;
|
||||
}
|
||||
|
||||
|
||||
// GETTER FUNCTIONS
|
||||
string Opponent::getOpponentName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
int Opponent::getOpponentHealth()
|
||||
{
|
||||
return current_health;
|
||||
}
|
||||
|
||||
int Opponent::getOpponentMaxHealth()
|
||||
{
|
||||
return max_health;
|
||||
}
|
||||
|
||||
int Opponent::getOpponentLevel()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
int Opponent::getOpponentBaseDamage()
|
||||
{
|
||||
return base_damage;
|
||||
}
|
||||
|
||||
int Opponent::getOpponentMaxDamage()
|
||||
{
|
||||
return max_damage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
170
lib/people/User.cpp
Normal file
170
lib/people/User.cpp
Normal file
@@ -0,0 +1,170 @@
|
||||
#include "../../include/people/User.h"
|
||||
#include "../../include/items/Weapon.h" // include the Weapon header file
|
||||
#include "../../include/items/Armor.h"
|
||||
#include "../../include/items/Potion.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// This constructor just initializes the User to null.
|
||||
|
||||
User::User(string username, Weapon current_weapons[], Armor current_armor[], Potion current_potions[])
|
||||
{
|
||||
name = username;
|
||||
current_health = 100;
|
||||
max_health = 100;
|
||||
level = 1;
|
||||
xp_points = 0;
|
||||
xp_needed = 500;
|
||||
credits = 500;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
equipped_weapon[i] = current_weapons[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
equipped_armor[i] = current_armor[i];
|
||||
}
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
equipped_potions[i] = current_potions[i];
|
||||
}
|
||||
}
|
||||
|
||||
//SETTER FUNCTIONS
|
||||
void User::setUserName(string username)
|
||||
{
|
||||
name = username;
|
||||
}
|
||||
|
||||
void User::setUserHealth(int damage_taken)
|
||||
{
|
||||
current_health = current_health - damage_taken;
|
||||
|
||||
// Set Health to zero if it goes below 0
|
||||
if (current_health < 0)
|
||||
{
|
||||
current_health = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void User::setHealthAfterPurchase(int armor_amount_added)
|
||||
{
|
||||
current_health += armor_amount_added;
|
||||
}
|
||||
|
||||
void User::setUserHealthFull(int full_health)
|
||||
{
|
||||
current_health = full_health;
|
||||
}
|
||||
|
||||
void User::setMaxHealth(Armor current_armor[])
|
||||
{
|
||||
int armor_rating = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
armor_rating += current_armor[i].getArmorHealth();
|
||||
}
|
||||
max_health = 100 + armor_rating;
|
||||
}
|
||||
|
||||
void User::setUserCredits(int current_credits)
|
||||
{
|
||||
credits = current_credits;
|
||||
}
|
||||
|
||||
void User::giveUserCredits(int credits_added)
|
||||
{
|
||||
credits += credits_added;
|
||||
}
|
||||
|
||||
void User::setUserXP(int xp_earned)
|
||||
{
|
||||
xp_points += xp_earned;
|
||||
}
|
||||
|
||||
void User::resetUserXP(int xp_remaining)
|
||||
{
|
||||
xp_points = xp_remaining;
|
||||
}
|
||||
|
||||
|
||||
void User::setUserXPNeeded(int level)
|
||||
{
|
||||
xp_needed = (level * pow(100, 1.2)) + (level * 100) + (level * 10) + (level * pow(1, 2));
|
||||
xp_needed = floor(xp_needed); // Round down to nearest whole number
|
||||
}
|
||||
|
||||
void User::usePotion(int potion_amount)
|
||||
{
|
||||
current_health += potion_amount;
|
||||
// Make sure potion doesn't overheal
|
||||
if (current_health > max_health)
|
||||
{
|
||||
current_health = max_health;
|
||||
}
|
||||
}
|
||||
|
||||
void User::levelUpUser(int current_level)
|
||||
{
|
||||
level = current_level + 1;
|
||||
}
|
||||
|
||||
// GETTER FUNCTIONS
|
||||
string User::getUserName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
int User::getUserHealth()
|
||||
{
|
||||
return current_health;
|
||||
}
|
||||
|
||||
int User::getUserMaxHealth()
|
||||
{
|
||||
return max_health;
|
||||
}
|
||||
|
||||
int User::getUserLevel()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
int User::getUserXP()
|
||||
{
|
||||
return xp_points;
|
||||
}
|
||||
|
||||
int User::getUserCredits()
|
||||
{
|
||||
return credits;
|
||||
}
|
||||
|
||||
int User::getUserXPNeeded()
|
||||
{
|
||||
return xp_needed;
|
||||
}
|
||||
|
||||
Weapon User::getUserWeapon(int input)
|
||||
{
|
||||
while (input < 0 && input > 1) // assuming the array size is 2
|
||||
{
|
||||
cout << "Please enter a valid input" << endl;
|
||||
cin >> input;
|
||||
}
|
||||
return equipped_weapon[input];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user