Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Personagem {
- protected:
- string nome;
- int vida;
- int atk;
- int def;
- int level;
- public:
- Personagem(string n, int v, int a, int d) {
- nome = n;
- vida = v;
- atk = a;
- def = d;
- level = 1;
- }
- string getNome() {
- return nome;
- }
- int getVida() {
- return vida;
- }
- int getAtk() {
- return atk;
- }
- int getDef() {
- return def;
- }
- int getLevel() {
- return level;
- }
- void setNome(string novoNome) {
- nome = novoNome;
- }
- bool estaVivo() {
- return (vida > 0);
- }
- void descricao() {
- cout << "*************" << endl;
- cout << "Nome: " << nome << endl;
- cout << "Level: " << level << endl;
- cout << "Vida: " << vida << endl;
- cout << "Atk: " << atk << endl;
- cout << "Def: " << def << endl;
- cout << "*************" << endl;
- }
- virtual void atacar(Personagem* alvo) = 0;
- virtual void receberAtaque(int dano) = 0;
- };
- class Heroi : public Personagem {
- protected:
- //Equipamentos
- public:
- Heroi(string n, int v, int a, int d)
- : Personagem(n, v, a, d) {
- }
- void atacar(Personagem* alvo) {
- int dano = atk;
- alvo->receberAtaque(dano);
- }
- void receberAtaque(int dano) {
- int danoFinal = dano - def;
- vida = vida - danoFinal;
- }
- };
- class Inimigo : public Personagem {
- protected:
- //Experiencia fornecida ao ser derrotado
- //Itens derrubados ao ser derrotado
- public:
- Inimigo(string n, int v, int a, int d)
- : Personagem(n, v, a, d) {
- }
- void atacar(Personagem* alvo) {
- int danoFinal = atk * 2;
- alvo->receberAtaque(danoFinal);
- }
- void receberAtaque(int dano) {
- int danoFinal = dano * 0.8;
- vida = vida - danoFinal;
- }
- };
- int main()
- {
- Heroi* sam = new Heroi("Samuel", 100, 25, 5);
- Inimigo* mar = new Inimigo("Marcus", 100, 11, 3);
- while (sam->estaVivo() && mar->estaVivo()) {
- sam->atacar(mar);
- mar->atacar(sam);
- sam->descricao();
- mar->descricao();
- }
- if (sam->estaVivo()) {
- cout << "Samuel eh o grande Vendor" << endl;
- }
- if (mar->estaVivo()) {
- cout << "Eu ja sabia!!! sdufhsudfhsd" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment