diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp index a04399d..0bf1d99 100644 --- a/src/saland/Game.cpp +++ b/src/saland/Game.cpp @@ -28,6 +28,7 @@ https://github.com/sago007/saland #include "GameRegion.hpp" #include "Game.hpp" #include "GameShop.hpp" +#include "GameItems.hpp" #include "model/World.hpp" #include "../sagotmx/tmx_struct.h" #include "../sago/SagoMisc.hpp" @@ -230,14 +231,24 @@ void ApplyEquippedItems(Player& player) { auto it = player.item_inventory.find(itemName); if (it != player.item_inventory.end()) { // Item is in inventory, apply its effects - if (itemName == "armor_basic_pants") { - player.visible_bottom = "pants_1"; - } - if (itemName == "armor_pirate_shirt_sky" && player.race == "female") { - player.visible_top = "pirate_shirt_sky"; - } - if (itemName == "armor_blouse_black" && player.race == "female") { - player.visible_top = "blouse_black"; + if (itemExists(itemName)) { + const ItemDef& item = getItem(itemName); + // Check if player race matches armor restrictions + bool race_allowed = item.armor_restriction.empty(); + for (const std::string& allowed_race : item.armor_restriction) { + if (allowed_race == player.race) { + race_allowed = true; + break; + } + } + if (race_allowed) { + if (!item.armor_upper_body.empty()) { + player.visible_top = item.armor_upper_body; + } + if (!item.armor_lower_body.empty()) { + player.visible_bottom = item.armor_lower_body; + } + } } } } diff --git a/src/saland/GameItems.cpp b/src/saland/GameItems.cpp index 00efb57..79cc4e3 100644 --- a/src/saland/GameItems.cpp +++ b/src/saland/GameItems.cpp @@ -79,6 +79,21 @@ static void ReadItemFile(const std::string& filename) { if (member.name == "pickup") { new_item.pickup = member.value.GetBool(); } + if (member.name == "armor_upper_body") { + new_item.armor_upper_body = member.value.GetString(); + } + if (member.name == "armor_lower_body") { + new_item.armor_lower_body = member.value.GetString(); + } + if (member.name == "armor_restriction") { + if (member.value.IsArray()) { + for (const auto& restriction : member.value.GetArray()) { + if (restriction.IsString()) { + new_item.armor_restriction.push_back(restriction.GetString()); + } + } + } + } } all_items[new_item.itemid] = new_item; } diff --git a/src/saland/GameItems.hpp b/src/saland/GameItems.hpp index 23c516c..d2660f3 100644 --- a/src/saland/GameItems.hpp +++ b/src/saland/GameItems.hpp @@ -35,6 +35,9 @@ struct ItemDef { bool isDestructible = true; float health = 10.0f; bool pickup = false; + std::string armor_upper_body = ""; + std::string armor_lower_body = ""; + std::vector armor_restriction; }; const ItemDef& getItem(const std::string& itemName);