All pastes #2073883 Raw Edit

Something

public text v1 · immutable
#2073883 ·published 2011-06-02 21:45 UTC
rendered paste body
Personnage.h

#ifndef DEF_PERSONNAGE
#define DEF_PERSONNAGE

#include <iostream>
#include <string>
#include "Arme.h"

class Personnage
{
    public:

    Personnage();
    Personnage(std::string nomArme, int degatsArme);
    ~Personnage();
    void recevoirDegats(int nbDegats);
    void attaquer(Personnage &attaqueur, Personnage &cible);
    void boirePotionDeVie(int quantitePotion);
    void changerArme(std::string nomNouvelleArme, int degatsNouvelleArme);
    bool estVivant();
    void afficherEtat();

    private:

    int m_vie;
    int m_mana;
    Arme m_arme;
};

#endif


Personnage.cpp
#include "Personnage.h"


using namespace std;


Personnage::Personnage() : m_vie(100), m_mana(100)
{

}

Personnage::Personnage(string nomArme, int degatsArme) : m_vie(100), m_mana(100), m_arme(nomArme, degatsArme)
{

}

Personnage::~Personnage()
{

}

void Personnage::recevoirDegats(int nbDegats)
{
    m_vie -= nbDegats;

    if (m_vie < 0)
    {
        m_vie = 0;
    }
}

void Personnage::attaquer(Personnage &attaquant, Personnage &cible)
{
	int *attaqueur(0);
	attaqueur = &attaquant;
	int *ciblé(0);
	ciblé = &cible;


    cible.recevoirDegats(m_arme.getDegats());

	cout << *attaqueur << " attaque " << *ciblé << endl << endl;

error C2440: '=' : impossible de convertir de 'Personnage *' en 'int *'	

}

void Personnage::boirePotionDeVie(int quantiteViePotion)
{
    m_vie += quantiteViePotion;

    if (m_vie > 100)
    {
        m_vie = 100;
    }
}

void Personnage::changerArme(string nomNouvelleArme, int degatsNouvelleArme)
{
    m_arme.changer(nomNouvelleArme, degatsNouvelleArme);
}

bool Personnage::estVivant()
{
    if (m_vie > 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

void Personnage::afficherEtat()
{
    cout << "Vie : " << m_vie << endl;
    cout << "Mana : " << m_mana << endl;
    m_arme.afficher();
}