31 lines
830 B
C++
31 lines
830 B
C++
#include "../includes/sel.hpp"
|
|
#include "../includes/univers.hpp"
|
|
|
|
Sel::Sel(const int univers_ID, const int index): Organisme(univers_ID, index) {
|
|
m_correspondance[ID] = _m_lettre;
|
|
}
|
|
|
|
Sel::Sel(const int univers_ID): Organisme(univers_ID) {
|
|
m_correspondance[ID] = _m_lettre;
|
|
}
|
|
|
|
Sel::~Sel(void) {
|
|
// On se supprime du vecteur
|
|
auto debut = Univers::m_organismes_univers[m_univers_ID].begin();
|
|
auto fin = Univers::m_organismes_univers[m_univers_ID].end();
|
|
auto it = std::find(debut, fin, this);
|
|
if(it != fin) {
|
|
Univers::m_organismes_univers[m_univers_ID].erase(it);
|
|
}
|
|
|
|
// On ajoute une herbe à la place
|
|
new Herbe(m_univers_ID, m_index);
|
|
}
|
|
|
|
void Sel::action(void) {
|
|
if(m_age == 1) { // devient de l'herbe au bout d'un tour
|
|
delete this;
|
|
} else {
|
|
++m_age;
|
|
}
|
|
}
|