1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <vector>
#include <fstream>
#include <windows.h>
using namespace std;
/*Armor prevents monsters from being
destroyed and must be repaired to work
up to it's maximum capability.*/
class Armor
{
int Weight;
int Armor_Health;
public:
Armor(){};
~Armor(){};
int GetWeight(){return Weight;}
void SetWeight(int x){Weight = x;}
int GetArmor_Health(){return Armor_Health;}
void SetArmor_Health(int x){Armor_Health = x;}
void Steel1();
};
/*Shields defend the monsters from most
damage and regenerate after each battle.*/
class Shield
{
int Weight;
int Defense;
string Resists;
int Shield_Energy;
public:
Shield(){};
~Shield(){};
int GetWeight(){return Weight;}
void SetWeight(int x){Weight = x;}
int GetDefense(){return Defense;}
void SetDefense(int x){Defense = x;}
string GetResists(){return Resists;}
void SetResists(string x){Resists = x;}
int GetShield_Energy(){return Shield_Energy;}
void SetShield_Energy(int x){Shield_Energy = x;}
void Spectral1();
};
/*Monsters are what you use to battle and
they can hold weapons, armor, and shields.*/
class Monster
{
int Weight;
int Monster_Health;
int Monster_Armor;
int Monster_Shields;
int Monster_Damage;
Armor slot1;
Shield slot2;
public:
Monster(){};
~Monster(){};
int GetWeight(){return Weight;}
void SetWeight(int x){Weight = x;}
int GetMonster_Health(){return Monster_Health;}
void SetMonster_Health(int x){Monster_Health = x;}
int GetMonster_Armor(){return Monster_Armor;}
void SetMonster_Armor(int x){Monster_Armor = x;}
int GetMonster_Shields(){return Monster_Shields;}
void SetMonster_Shields(int x){Monster_Shields = x;}
int GetMonster_Damage(){return Monster_Damage;}
void SetMonster_Damage(int x){Monster_Damage = x;}
void Level1();
};
void Armor::Steel1()
{
Weight = 50;
Armor_Health = 150;
}
void Shield::Spectral1()
{
Weight = 50;
Defense = 90;
Resists = "none";
Shield_Energy = 100;
}
void Monster::Level1() //Default Name
{
slot1 = Steel1();
slot2 = Spectral1();
Weight = 50;
Monster_Health = 200;
Monster_Armor = 0;//Not integrated yet. Should be steel 1 stats.
Monster_Shields = 200;//Not integrated yet. Should be spectral 1 stats
Monster_Damage = 10;
}
inline void delay( unsigned long ms )
{
Sleep( ms );
}
void MonsterAttack(Monster & Monster1, Monster & Monster2)
{
//Tests if the monster's shield is equal to 0, if so damage is subtracted from health.
if(Monster2.GetMonster_Shields() == 0)
{Monster2.SetMonster_Health(Monster2.GetMonster_Health() - Monster1.GetMonster_Damage());}
//Tests if the monster's shield is greater than 0, if so damage is subtracted from the shield and monster's health.
if(Monster2.GetMonster_Shields() > 0)
{Monster2.SetMonster_Shields(Monster2.GetMonster_Shields() - Monster1.GetMonster_Damage());
Monster2.SetMonster_Health(Monster2.GetMonster_Health() - Monster1.GetMonster_Damage() / 10);}
//Tests if the monster's shield is less than 0, if so the shield's value is equal to 0.
if(Monster2.GetMonster_Shields() < 0)
{Monster2.SetMonster_Shields(0);}
//Tests if the monster's health is less than 0, if so the monsters's health is equal to 0.
if(Monster2.GetMonster_Health() < 0)
{Monster2.SetMonster_Health(0);}
//Tests if the monster's health is equal to 0, if so the monsters's shield is equal to 0.
if(Monster2.GetMonster_Health() == 0)
{Monster2.SetMonster_Shields(0);}
}
void MonsterRepair(Monster & Monster1)
{
//Sets the monster's shield to 200.
Monster1.SetMonster_Shields(200);
//If the monster's health is less than 200, the monster's health will start repairing up to 200.
while (Monster1.GetMonster_Health() < 200)
{
Monster1.SetMonster_Health(Monster1.GetMonster_Health()+1);
system("CLS");//Sake of posting on forums in 1 file.
cout << "Repairing Monster1" << endl << endl;
cout << "Monster1 Health " << Monster1.GetMonster_Health() << endl;
cout << "Monster1 Shields " << Monster1.GetMonster_Shields()<< endl;
delay(50);
}
}
void BattlePhase (Monster & Monster1, Monster & Monster2)//does the battle phase
{
while (Monster1.GetMonster_Health() > 0 && Monster2.GetMonster_Health() > 0)
{
MonsterAttack(Monster1, Monster2);
MonsterAttack(Monster2, Monster1);
system("CLS");//Sake of posting on forums in 1 file.
cout << "Monster1 Health " << Monster1.GetMonster_Health() << "\t";
cout << "Monster2 Health " << Monster2.GetMonster_Health() << endl;
cout << "Monster1 Shields " << Monster1.GetMonster_Shields()<< "\t";
cout << "Monster2 Shields " << Monster2.GetMonster_Shields()<< endl;
delay(300);
}
MonsterRepair(Monster1);
}
int main(int argc, char *argv[])
{
Monster YourMonster1;
Monster OpponentMonster1;
YourMonster1.Level1();
OpponentMonster1.Level1();
BattlePhase (YourMonster1, OpponentMonster1);
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return 0;
}
|