Text-Adventure/GameObject.h
2023-11-16 00:44:12 +08:00

64 lines
1.5 KiB
C++

//
// Created by tqcq on 2023/11/14.
//
#ifndef TEXTADV_GAMEOBJECT_H
#define TEXTADV_GAMEOBJECT_H
#include "Serializable.h"
#include <string>
class GameObject : public Serializable {
public:
enum Type {
Default, // GameObject
Food, // FoodObject
TYPE_MAX_COUNT,
};
static int game_object_id_counter;
/**
* @brief Create a GameObject object
*/
static std::map<int, GameObject*> game_object_map;
static GameObject* getGameObjectById(int id);
/**
* @brief Create a GameObject object
* @param type
* @return
*/
static GameObject* CreateGameObject(Type type, bool add_to_map = true);
static void AddGameObject(GameObject* object);
GameObject();
GameObject(const std::string &name, const std::string &keyword, const std::string &description);
~GameObject() override;
virtual std::string getInfo() const;
const std::string& getName() const;
void setName(const std::string& name);
const std::string& getKeyword() const;
void setKeyword(const std::string& keyword);
const std::string& getDescription() const;
void setDescription(const std::string& description);
int getGameObjectId() const;
virtual Type getObjectType() const;
std::string ToString() const override;
void FromString(const std::string &str) override;
protected:
int game_object_id;
Type object_type;
std::string name;
std::string keyword;
std::string description;
};
#endif //TEXTADV_GAMEOBJECT_H