Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <string>
- using namespace std;
- class Skill{
- public:
- string nome;
- int dmg;
- int cost;
- Skill(string n, int d, int c)
- {
- this->nome = n;
- this->dmg = d;
- this->cost = c;
- }
- Skill()
- {
- this->nome = "Indefinido";
- this->dmg = 0;
- this->cost = 0;
- }
- };
- class Jogador{
- public:
- string nome;
- int hp;
- int hpT;
- int mp;
- int mpT;
- Skill skills[5];
- Jogador(string n, int h, int m)
- {
- this->nome = n;
- this->hp = h;
- this->hpT = h;
- this->mp = m;
- this->mpT = m;
- }
- Jogador()
- {
- this->nome = "Indefinido";
- this->hp = 0;
- this->mp = 0;
- this->hpT = 0;
- this->mpT = 0;
- }
- void listaSkills()
- {
- cout << endl;
- for (int i=0; i<5; i++)
- {
- cout << i+1 <<" - " << this->skills[i].nome << endl;
- }
- }
- int hpAfterAttackFrom(Jogador j, int i)
- {
- if (this->hp - j.skills[i].dmg <= 0)
- {
- return 0;
- }
- else return this->hp - j.skills[i].dmg;
- }
- };
- class Combate{
- public:
- int turno;
- int input;
- int maxAttacks;
- Jogador j1;
- Jogador j2;
- Combate(Jogador j1, Jogador j2)
- {
- this->j1 = j1;
- this->j2 = j2;
- this->turno = 0;
- this->maxAttacks = 6;
- }
- bool CheckPlayers()
- {
- if (j1.hp <= 0 || j2.hp <= 0)
- {
- return false;
- }
- else return true;
- }
- void Luta()
- {
- if (this->turno%2 == 0)
- {
- this->turno += 1;
- cout << "Como " << j1.nome << " reagira?";
- j1.listaSkills();
- input = 0;
- while(input==0)
- {
- cin >> input;
- if (input > 0 && input < maxAttacks)
- {
- j2.hp = j2.hpAfterAttackFrom(j1, input-1);
- j1.mp -= j1.skills[input-1].cost;
- }
- else input = 0;
- }
- }
- else
- {
- this->turno += 1;
- cout << "Como " << j2.nome << " reagira?";
- j2.listaSkills();
- input = 0;
- while(input==0)
- {
- cin >> input;
- if (input > 0 && input < maxAttacks)
- {
- j1.hp = j1.hpAfterAttackFrom(j2, input-1);
- j2.mp -= j2.skills[input-1].cost;
- }
- else input = 0;
- }
- }
- }
- void mostraStatus()
- {
- cout << j1.nome << " = HP: " << j1.hp << "/" << j1.hpT << " / MP: " << j1.mp << "/" << j1.mpT << endl;
- cout << j2.nome << " = HP: " << j2.hp << "/" << j2.hpT << " / MP: " << j2.mp << "/" << j2.mpT << endl;
- }
- };
- int main()
- {
- Jogador jo1("Jogador1", 80, 50);
- Jogador jo2("Jogador2", 150, 0);
- jo1.skills[0] = Skill("Jato de Agua", 10, 5);
- jo1.skills[1] = Skill("Surf", 12, 8);
- jo1.skills[2] = Skill();
- jo1.skills[3] = Skill();
- jo1.skills[4] = Skill("Ataque Basico", 2, 0);
- jo2.skills[0] = Skill("Lanca Chamas", 10, 6);
- jo2.skills[1] = Skill("Terremoto", 15, 10);
- jo2.skills[2] = Skill();
- jo2.skills[3] = Skill();
- jo2.skills[4] = Skill("Ataque Basico", 2, 0);
- Combate Game(jo1,jo2);
- bool onGame = true;
- while (onGame)
- {
- system("cls");
- Game.mostraStatus();
- Game.Luta();
- onGame = Game.CheckPlayers();
- }
- cout << "O jogo acabou!";
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement