You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
#include "monstre.hpp"
|
|
#include "chevalier.hpp"
|
|
#include <iostream> // cout, endl
|
|
|
|
using namespace std;
|
|
|
|
Monstre::Monstre(string nom, int nbPtsVie, int force)
|
|
: nom{nom}, nbPtsVie{nbPtsVie}, force{force}
|
|
{
|
|
cout << "Monstre " << nom << " créé" << endl;
|
|
}
|
|
|
|
void Monstre::rugir(string message) {
|
|
cout << "--" << nom << "(" << nbPtsVie << ")" << "-- : " << message << endl;
|
|
}
|
|
|
|
Monstre::~Monstre() {
|
|
cout << "destruction du Monstre" << nom << endl;
|
|
}
|
|
|
|
void Monstre::attaquerSournoisement(Chevalier *chevalier) {
|
|
rugir("Je vais te tuer !");
|
|
chevalier->subirAttaque(force);
|
|
}
|
|
|
|
void Monstre::attaquerFranchement(Chevalier *chevalier) {
|
|
rugir("Prends ça " + chevalier->titre);
|
|
chevalier->subirEtContreAttaquer(this);
|
|
}
|
|
|
|
void Monstre::subirContreEtAttaquer(Chevalier *chevalier) {
|
|
nbPtsVie = nbPtsVie - chevalier->puissArme;
|
|
rugir("Je subit l'attaque !!! Aie");
|
|
if(nbPtsVie > 0)
|
|
{
|
|
attaquerFranchement(chevalier);
|
|
}
|
|
else rugir("Je me meurs !! heurg heurg heurg !");
|
|
}
|
|
|
|
Monstre::Monstre()
|
|
: Monstre{"Mr Inconnu", 15,18}
|
|
{
|
|
cout << "Monstre " << nom << " créé" << endl;
|
|
} |