CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Character.hpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* Character.hpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/05/29 23:52:24 by kamitsui #+# #+# */
9/* Updated: 2025/05/29 23:52:26 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
24#ifndef CHARACTER_HPP
25#define CHARACTER_HPP
26
27#include "AMateria.hpp" // Required for AMateria* in inventory and method parameters
28#include "ICharacter.hpp" // Inherits from this interface
29#include <string> // For std::string to store the character's name
30
39class Character : public ICharacter {
40 private:
41 std::string name;
42 AMateria *inventory[4];
43
44 public:
45 Character(std::string const &name);
46 Character(const Character &other);
47 Character &operator=(const Character &other);
48 virtual ~Character();
49
50 std::string const &getName() const;
51 void equip(AMateria *m);
52 void unequip(int idx);
53 void use(int idx, ICharacter &target);
54 bool isMateriaEquipped(int idx) const;
55 AMateria *getMateriaAtSlot(int idx) const;
56};
57
58#endif
Declares the AMateria abstract base class.
Declares the ICharacter interface.
Represents an abstract base class for all magical materias.
Definition AMateria.hpp:42
Represents a character capable of equipping and using Materias.
Definition Character.hpp:39
Character & operator=(const Character &other)
Copy assignment operator for Character. Assigns values from another Character object,...
Definition Character.cpp:64
bool isMateriaEquipped(int idx) const
Checks if a Materia is equipped at a specific inventory slot.
void unequip(int idx)
Unequips a Materia from a specific inventory slot. The Materia object itself is NOT deleted,...
virtual ~Character()
Destroys the Character object. Deallocates all dynamically allocated Materia objects currently in the...
Definition Character.cpp:88
AMateria * getMateriaAtSlot(int idx) const
Gets a pointer to the Materia at a specific inventory slot.
void use(int idx, ICharacter &target)
Uses the Materia at a specific inventory slot on a target character. Performs bounds checking and che...
std::string const & getName() const
Gets the name of the character.
void equip(AMateria *m)
Equips a Materia into the first available inventory slot (0-3). If the inventory is full,...
An interface for any character that can interact with Materias.