| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* MateriaSource.cpp :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2025/12/24 15:47:01 by bchanot #+# #+# */
- /* Updated: 2025/12/24 15:49:20 by bchanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include "MateriaSource.hpp"
- #include <string.h>
- /*
- ** ------------------------------- CONSTRUCTOR --------------------------------
- */
- MateriaSource::MateriaSource()
- {
- for (int i = 0; i < 4; i++)
- this->_items[i] = NULL;
- }
- MateriaSource::MateriaSource( const MateriaSource & src )
- {
- for (int i = 0; i < 4; i++)
- this->_items[i] = src._items[i]->clone();
- }
- /*
- ** -------------------------------- DESTRUCTOR --------------------------------
- */
- MateriaSource::~MateriaSource()
- {
- }
- /*
- ** --------------------------------- OVERLOAD ---------------------------------
- */
- MateriaSource & MateriaSource::operator=( MateriaSource const & rhs )
- {
- if ( this != &rhs )
- {
- for (int i = 0; i < 4; i++) {
- this->_items[i] = rhs._items[i]->clone();
- }
- }
- return *this;
- }
- std::ostream & operator<<( std::ostream & o, MateriaSource const & i )
- {
- (void)i;
- //o << "Value = " << i.getValue();
- return o;
- }
- /*
- ** --------------------------------- METHODS ----------------------------------
- */
- void MateriaSource::learnMateria(AMateria* source) {
- if (source) {
- for (int i = 0; i < 4; i++) {
- if (!this->_items[i]) {
- this->_items[i] = source->clone();
- return ;
- }
- }
- }
- }
- AMateria* MateriaSource::createMateria(std::string const & type){
- for (int i = 0; i < 4; i++) {
- if (this->_items[i] && !type.compare(this->_items[i]->getType())) {
- return this->_items[i]->clone();
- }
- }
- return NULL;
- }
- /*
- ** --------------------------------- ACCESSOR ---------------------------------
- */
- /* ************************************************************************** */
|