this is going to be allot of work!!
This commit is contained in:
parent
fb54d1c7e8
commit
95d416da26
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@ -0,0 +1,12 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
@ -6,11 +6,11 @@
|
||||
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||
# +#+ #
|
||||
# Created: 2025/03/24 15:14:58 by whaffman #+# #+# #
|
||||
# Updated: 2025/04/05 16:49:25 by whaffman ######## odam.nl #
|
||||
# Updated: 2025/04/14 22:41:56 by whaffman ######## odam.nl #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME=
|
||||
SRC= main.cpp
|
||||
NAME= Materia
|
||||
SRC= main.cpp AMateria.cpp Ice.cpp Cure.cpp Character.cpp MateriaSource.cpp
|
||||
|
||||
-include ../common.mk
|
||||
|
||||
33
ex03/inc/AMateria.hpp
Normal file
33
ex03/inc/AMateria.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* AMateria.hpp :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/04/14 22:12:51 by whaffman #+# #+# */
|
||||
/* Updated: 2025/04/14 22:35:00 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "ICharacter.hpp"
|
||||
|
||||
class AMateria
|
||||
{
|
||||
protected:
|
||||
std::string type;
|
||||
|
||||
public:
|
||||
AMateria() = default;
|
||||
AMateria(AMateria const &other);
|
||||
AMateria(std::string const &type);
|
||||
virtual ~AMateria();
|
||||
AMateria &operator=(AMateria const &other);
|
||||
|
||||
std::string const &getType() const; // Returns the materia type
|
||||
virtual AMateria *clone() const = 0;
|
||||
virtual void use(ICharacter &target);
|
||||
|
||||
};
|
||||
41
ex03/inc/Character.hpp
Normal file
41
ex03/inc/Character.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* Character.hpp :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/04/14 22:23:59 by whaffman #+# #+# */
|
||||
/* Updated: 2025/04/14 22:29:01 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include "ICharacter.hpp"
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
#include "colors.h"
|
||||
|
||||
class Character : public ICharacter
|
||||
{
|
||||
private:
|
||||
std::string name;
|
||||
AMateria *inventory[4];
|
||||
|
||||
public:
|
||||
Character();
|
||||
Character(std::string const &name);
|
||||
Character(Character const &other);
|
||||
~Character() override;
|
||||
Character &operator=(Character const &other);
|
||||
|
||||
std::string const &getName() const override;
|
||||
void equip(AMateria *m) override;
|
||||
void unequip(int idx) override;
|
||||
void use(int idx, ICharacter &target) override;
|
||||
|
||||
void printInventory() const;
|
||||
|
||||
};
|
||||
|
||||
32
ex03/inc/Cure.hpp
Normal file
32
ex03/inc/Cure.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* Cure.hpp :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/04/14 22:21:38 by whaffman #+# #+# */
|
||||
/* Updated: 2025/04/14 22:29:08 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include "AMateria.hpp"
|
||||
|
||||
#include "ICharacter.hpp"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "colors.h"
|
||||
|
||||
class Cure : public AMateria
|
||||
{
|
||||
public:
|
||||
Cure();
|
||||
Cure(Cure const &other);
|
||||
~Cure() override;
|
||||
Cure &operator=(Cure const &other);
|
||||
|
||||
AMateria *clone() const override;
|
||||
void use(ICharacter &target) override;
|
||||
|
||||
};
|
||||
25
ex03/inc/ICharacter.hpp
Normal file
25
ex03/inc/ICharacter.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ICharacter.hpp :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/04/14 22:14:07 by whaffman #+# #+# */
|
||||
/* Updated: 2025/04/14 22:14:28 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "AMateria.hpp"
|
||||
|
||||
class ICharacter
|
||||
{
|
||||
public:
|
||||
virtual ~ICharacter() {}
|
||||
virtual std::string const &getName() const = 0;
|
||||
virtual void equip(AMateria *m) = 0;
|
||||
virtual void unequip(int idx) = 0;
|
||||
virtual void use(int idx, ICharacter &target) = 0;
|
||||
};
|
||||
23
ex03/inc/IMateriaSource.hpp
Normal file
23
ex03/inc/IMateriaSource.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* IMateriaSource.hpp :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/04/14 22:25:03 by whaffman #+# #+# */
|
||||
/* Updated: 2025/04/14 22:25:53 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include "AMateria.hpp"
|
||||
#include <string>
|
||||
|
||||
class IMateriaSource
|
||||
{
|
||||
public:
|
||||
virtual ~IMateriaSource() {}
|
||||
virtual void learnMateria(AMateria *m) = 0;
|
||||
virtual AMateria *createMateria(std::string const &type) = 0;
|
||||
};
|
||||
30
ex03/inc/Ice.hpp
Normal file
30
ex03/inc/Ice.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* Ice.hpp :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/04/14 22:23:22 by whaffman #+# #+# */
|
||||
/* Updated: 2025/04/14 22:23:50 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include "AMateria.hpp"
|
||||
#include "ICharacter.hpp"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "colors.h"
|
||||
|
||||
class Ice : public AMateria
|
||||
{
|
||||
public:
|
||||
Ice();
|
||||
Ice(Ice const &other);
|
||||
~Ice() override;
|
||||
Ice &operator=(Ice const &other);
|
||||
|
||||
AMateria *clone() const override;
|
||||
void use(ICharacter &target) override;
|
||||
};
|
||||
29
ex03/inc/MateriaSource.hpp
Normal file
29
ex03/inc/MateriaSource.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* MateriaSource.hpp :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/04/14 22:26:01 by whaffman #+# #+# */
|
||||
/* Updated: 2025/04/14 22:26:45 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include "IMateriaSource.hpp"
|
||||
#include <string>
|
||||
|
||||
class MateriaSource : public IMateriaSource
|
||||
{
|
||||
private:
|
||||
AMateria *materia[4];
|
||||
public:
|
||||
MateriaSource();
|
||||
MateriaSource(MateriaSource const &other);
|
||||
~MateriaSource() override;
|
||||
MateriaSource &operator=(MateriaSource const &other);
|
||||
|
||||
void learnMateria(AMateria *m) override;
|
||||
AMateria *createMateria(std::string const &type) override;
|
||||
};
|
||||
37
ex03/src/AMateria.cpp
Normal file
37
ex03/src/AMateria.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "AMateria.hpp"
|
||||
#include "ICharacter.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
AMateria::AMateria() : type("default")
|
||||
{
|
||||
}
|
||||
|
||||
AMateria::AMateria(AMateria const & other)
|
||||
{
|
||||
}
|
||||
|
||||
AMateria::AMateria(std::string const & type) : type(type)
|
||||
{
|
||||
}
|
||||
|
||||
AMateria::~AMateria()
|
||||
{
|
||||
}
|
||||
|
||||
AMateria & AMateria::operator=(AMateria const & other)
|
||||
{
|
||||
if (this != &other)
|
||||
type = other.type;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string const & AMateria::getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
void AMateria::use(ICharacter & target)
|
||||
{
|
||||
std::cout << "AMateria::use called on " << target.getName() << std::endl;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user