refactor
This commit is contained in:
@@ -33,35 +33,9 @@ struct Achievement
|
||||
Achievement() = default;
|
||||
};
|
||||
|
||||
// Achievements configuration manager
|
||||
class AchievementsConfig {
|
||||
public:
|
||||
static AchievementsConfig& getInstance() {
|
||||
static AchievementsConfig instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool loadFromXML(const std::string& filepath);
|
||||
const Achievement* getAchievementById(int id) const;
|
||||
const std::unordered_map<int, Achievement>& getAllAchievements() const { return m_achievements; }
|
||||
|
||||
private:
|
||||
AchievementsConfig() = default;
|
||||
~AchievementsConfig() = default;
|
||||
AchievementsConfig(const AchievementsConfig&) = delete;
|
||||
AchievementsConfig& operator=(const AchievementsConfig&) = delete;
|
||||
|
||||
std::unordered_map<int, Achievement> m_achievements;
|
||||
|
||||
// Helper methods for parsing
|
||||
void parseAchievement(tinyxml2::XMLElement* achievementElement);
|
||||
void parseRequirements(tinyxml2::XMLElement* achievementElement, Achievement& achievement);
|
||||
std::string getAttributeValue(tinyxml2::XMLElement* element, const char* attribute, const std::string& defaultValue = "");
|
||||
int getAttributeValueInt(tinyxml2::XMLElement* element, const char* attribute, int defaultValue = 0);
|
||||
bool getAttributeValueBool(tinyxml2::XMLElement* element, const char* attribute, bool defaultValue = false);
|
||||
};
|
||||
|
||||
// Helper functions for enum conversions
|
||||
ActionType stringToActionType(const std::string& str);
|
||||
// Achievements configuration functions
|
||||
bool loadAchievementsFromXML(const std::string& filepath);
|
||||
const Achievement* getAchievementById(uint16_t id);
|
||||
const std::unordered_map<uint16_t, Achievement>& getAllAchievements();
|
||||
|
||||
} // namespace cursebreaker
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <tinyxml2.h>
|
||||
|
||||
#include "constants.h"
|
||||
#include "items.hpp" // for stringToSkillType
|
||||
|
||||
namespace cursebreaker {
|
||||
|
||||
@@ -34,32 +33,9 @@ struct Harvestable
|
||||
Harvestable() = default;
|
||||
};
|
||||
|
||||
// Harvestables configuration manager
|
||||
class HarvestablesConfig {
|
||||
public:
|
||||
static HarvestablesConfig& getInstance() {
|
||||
static HarvestablesConfig instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool loadFromXML(const std::string& filepath);
|
||||
const Harvestable* getHarvestableById(int id) const;
|
||||
const std::unordered_map<int, Harvestable>& getAllHarvestables() const { return m_harvestables; }
|
||||
|
||||
private:
|
||||
HarvestablesConfig() = default;
|
||||
~HarvestablesConfig() = default;
|
||||
HarvestablesConfig(const HarvestablesConfig&) = delete;
|
||||
HarvestablesConfig& operator=(const HarvestablesConfig&) = delete;
|
||||
|
||||
std::unordered_map<int, Harvestable> m_harvestables;
|
||||
|
||||
// Helper methods for parsing
|
||||
void parseHarvestable(tinyxml2::XMLElement* harvestableElement);
|
||||
void parseLoot(tinyxml2::XMLElement* harvestableElement, Harvestable& harvestable);
|
||||
std::string getAttributeValue(tinyxml2::XMLElement* element, const char* attribute, const std::string& defaultValue = "");
|
||||
int getAttributeValueInt(tinyxml2::XMLElement* element, const char* attribute, int defaultValue = 0);
|
||||
bool getAttributeValueBool(tinyxml2::XMLElement* element, const char* attribute, bool defaultValue = false);
|
||||
};
|
||||
// Harvestables configuration functions
|
||||
bool loadHarvestablesFromXML(const std::string& filepath);
|
||||
const Harvestable* getHarvestableById(uint16_t id);
|
||||
const std::unordered_map<uint16_t, Harvestable>& getAllHarvestables();
|
||||
|
||||
} // namespace cursebreaker
|
||||
@@ -62,42 +62,9 @@ struct Item {
|
||||
Item() = default;
|
||||
};
|
||||
|
||||
// Helper functions for enum conversions
|
||||
StatType stringToStatType(const std::string& str);
|
||||
ItemCategory stringToItemCategory(const std::string& str);
|
||||
ItemType stringToItemType(const std::string& str);
|
||||
Tool stringToTool(const std::string& str);
|
||||
SkillType stringToSkillType(const std::string& str);
|
||||
WorkbenchType stringToWorkbenchType(const std::string& str);
|
||||
GenstatType stringToGenstatType(const std::string& str);
|
||||
|
||||
// Items configuration manager
|
||||
class ItemsConfig {
|
||||
public:
|
||||
static ItemsConfig& getInstance() {
|
||||
static ItemsConfig instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool loadFromXML(const std::string& filepath);
|
||||
const Item* getItemById(int id) const;
|
||||
const std::unordered_map<int, Item>& getAllItems() const { return m_items; }
|
||||
|
||||
private:
|
||||
ItemsConfig() = default;
|
||||
~ItemsConfig() = default;
|
||||
ItemsConfig(const ItemsConfig&) = delete;
|
||||
ItemsConfig& operator=(const ItemsConfig&) = delete;
|
||||
|
||||
std::unordered_map<int, Item> m_items;
|
||||
|
||||
// Helper methods for parsing
|
||||
void parseItem(tinyxml2::XMLElement* itemElement);
|
||||
void parseStats(tinyxml2::XMLElement* itemElement, Item& item);
|
||||
void parseCraftings(tinyxml2::XMLElement* itemElement, Item& item);
|
||||
std::string getAttributeValue(tinyxml2::XMLElement* element, const char* attribute, const std::string& defaultValue = "");
|
||||
int getAttributeValueInt(tinyxml2::XMLElement* element, const char* attribute, int defaultValue = 0);
|
||||
bool getAttributeValueBool(tinyxml2::XMLElement* element, const char* attribute, bool defaultValue = false);
|
||||
};
|
||||
// Items configuration functions
|
||||
bool loadItemsFromXML(const std::string& filepath);
|
||||
const Item* getItemById(uint16_t id);
|
||||
const std::unordered_map<uint16_t, Item>& getAllItems();
|
||||
|
||||
} // namespace cursebreaker
|
||||
|
||||
@@ -30,32 +30,9 @@ struct LootTable
|
||||
LootTable() = default;
|
||||
};
|
||||
|
||||
// Loot configuration manager
|
||||
class LootConfig {
|
||||
public:
|
||||
static LootConfig& getInstance() {
|
||||
static LootConfig instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool loadFromXML(const std::string& filepath);
|
||||
const LootTable* getLootTableById(int id) const;
|
||||
const std::unordered_map<int, LootTable>& getAllLootTables() const { return m_lootTables; }
|
||||
|
||||
private:
|
||||
LootConfig() = default;
|
||||
~LootConfig() = default;
|
||||
LootConfig(const LootConfig&) = delete;
|
||||
LootConfig& operator=(const LootConfig&) = delete;
|
||||
|
||||
std::unordered_map<int, LootTable> m_lootTables;
|
||||
|
||||
// Helper methods for parsing
|
||||
void parseLootTable(tinyxml2::XMLElement* lootTableElement);
|
||||
void parseEntries(tinyxml2::XMLElement* lootTableElement, LootTable& lootTable);
|
||||
std::string getAttributeValue(tinyxml2::XMLElement* element, const char* attribute, const std::string& defaultValue = "");
|
||||
int getAttributeValueInt(tinyxml2::XMLElement* element, const char* attribute, int defaultValue = 0);
|
||||
bool getAttributeValueBool(tinyxml2::XMLElement* element, const char* attribute, bool defaultValue = false);
|
||||
};
|
||||
// Loot configuration functions
|
||||
bool loadLootTablesFromXML(const std::string& filepath);
|
||||
const LootTable* getLootTableById(uint16_t id);
|
||||
const std::unordered_map<uint16_t, LootTable>& getAllLootTables();
|
||||
|
||||
} // namespace cursebreaker
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <tinyxml2.h>
|
||||
|
||||
#include "constants.h"
|
||||
#include "items.hpp" // for stringToStatType
|
||||
|
||||
namespace cursebreaker {
|
||||
|
||||
@@ -36,33 +35,9 @@ struct NPC
|
||||
NPC() = default;
|
||||
};
|
||||
|
||||
// NPCs configuration manager
|
||||
class NPCsConfig {
|
||||
public:
|
||||
static NPCsConfig& getInstance() {
|
||||
static NPCsConfig instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool loadFromXML(const std::string& filepath);
|
||||
const NPC* getNPCById(int id) const;
|
||||
const std::unordered_map<int, NPC>& getAllNPCs() const { return m_npcs; }
|
||||
|
||||
private:
|
||||
NPCsConfig() = default;
|
||||
~NPCsConfig() = default;
|
||||
NPCsConfig(const NPCsConfig&) = delete;
|
||||
NPCsConfig& operator=(const NPCsConfig&) = delete;
|
||||
|
||||
std::unordered_map<int, NPC> m_npcs;
|
||||
|
||||
// Helper methods for parsing
|
||||
void parseNPC(tinyxml2::XMLElement* npcElement);
|
||||
void parseStats(tinyxml2::XMLElement* npcElement, NPC& npc);
|
||||
void parseLoot(tinyxml2::XMLElement* npcElement, NPC& npc);
|
||||
std::string getAttributeValue(tinyxml2::XMLElement* element, const char* attribute, const std::string& defaultValue = "");
|
||||
int getAttributeValueInt(tinyxml2::XMLElement* element, const char* attribute, int defaultValue = 0);
|
||||
bool getAttributeValueBool(tinyxml2::XMLElement* element, const char* attribute, bool defaultValue = false);
|
||||
};
|
||||
// NPCs configuration functions
|
||||
bool loadNPCsFromXML(const std::string& filepath);
|
||||
const NPC* getNPCById(uint16_t id);
|
||||
const std::unordered_map<uint16_t, NPC>& getAllNPCs();
|
||||
|
||||
} // namespace cursebreaker
|
||||
@@ -30,32 +30,9 @@ struct Shop
|
||||
Shop() = default;
|
||||
};
|
||||
|
||||
// Shops configuration manager
|
||||
class ShopsConfig {
|
||||
public:
|
||||
static ShopsConfig& getInstance() {
|
||||
static ShopsConfig instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool loadFromXML(const std::string& filepath);
|
||||
const Shop* getShopById(int id) const;
|
||||
const std::unordered_map<int, Shop>& getAllShops() const { return m_shops; }
|
||||
|
||||
private:
|
||||
ShopsConfig() = default;
|
||||
~ShopsConfig() = default;
|
||||
ShopsConfig(const ShopsConfig&) = delete;
|
||||
ShopsConfig& operator=(const ShopsConfig&) = delete;
|
||||
|
||||
std::unordered_map<int, Shop> m_shops;
|
||||
|
||||
// Helper methods for parsing
|
||||
void parseShop(tinyxml2::XMLElement* shopElement);
|
||||
void parseInventory(tinyxml2::XMLElement* shopElement, Shop& shop);
|
||||
std::string getAttributeValue(tinyxml2::XMLElement* element, const char* attribute, const std::string& defaultValue = "");
|
||||
int getAttributeValueInt(tinyxml2::XMLElement* element, const char* attribute, int defaultValue = 0);
|
||||
bool getAttributeValueBool(tinyxml2::XMLElement* element, const char* attribute, bool defaultValue = false);
|
||||
};
|
||||
// Shops configuration functions
|
||||
bool loadShopsFromXML(const std::string& filepath);
|
||||
const Shop* getShopById(uint16_t id);
|
||||
const std::unordered_map<uint16_t, Shop>& getAllShops();
|
||||
|
||||
} // namespace cursebreaker
|
||||
Reference in New Issue
Block a user