This repository has been archived on 2022-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
Ecosysteme/src/sel.cpp

32 lines
836 B
C++
Raw Normal View History

#include "../includes/sel.hpp"
#include "../includes/univers.hpp"
Sel::Sel(const int univers_ID, const int index): Organisme(univers_ID, true, 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;
}
}