1
0
This repository has been archived on 2025-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
CPP_Module_04/ex03/MateriaSource.cpp

41 lines
1.5 KiB
C++
Raw Normal View History

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* MateriaSource.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/11 12:17:06 by adjoly #+# #+# */
/* Updated: 2024/12/12 18:55:50 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "MateriaSource.hpp"
#include "AMateria.hpp"
#include "Log.hpp"
#include "MateriaTemplate.hpp"
#include "iostream"
MateriaSource::~MateriaSource(void) {
log("", "MateriaSource", "", "destructor called");
}
void MateriaSource::learnMateria(AMateria *materia) {
for (int i = 0; i < MATERIA_COUNT; i++) {
if (!_materias[i]) {
_materias[i] = materia;
return ;
}
}
std::cout << "can't learn any more materia" << std::endl;
}
AMateria *MateriaSource::createMateria(std::string const &type) {
for (int i = 0; i < MATERIA_COUNT; i++) {
if (_materias[i]->getType() == type) {
return (_materias[i]->clone());
}
}
return (NULL);
}