#ifndef ITEM_H #define ITEM_H #include "pixelGameEngine.h" using namespace olc; #include "battle.h" #include "defines.h" enum class ItemName{ COOKIE, EGG, PIZZA, MIRACLE_FOOD_LUNCH, CRACKED_BAT, TEE_BALL_BAT, LIGHT_JACKET, HEAVY_JACKET, COPPER_BRACELET, KEY_TO_THE_PALACE, BOMB, }; namespace EquipSlot{ enum Equip{ WEAPON, ARMOR, ACCESSORY, NONE }; } namespace Consumable{ enum{ FRIENDLY, ENEMY, FRIENDLY_PERMANENT, //This item does not get used up when used. ENEMY_PERMANENT, //This item does not get used up when used. NOT_A_CONSUMABLE }; } enum class ItemAction{ HPRECOVERY, PPRECOVERY, ATKINCREASE, HPINCREASE, PPINCREASE, SPDINCREASE, LEARNMOVE, }; struct ItemStatsStruct{ int hpRecovery=0; int ppRecovery=0; int atkIncrease=0; int spdIncrease=0; int hpIncrease=0; int ppIncrease=0; Battle::Move*learnAbility=nullptr; int damage=0; int rollDmg=0; int attack=0; int defense=0; EquipSlot::Equip equip=EquipSlot::NONE; //Whether or not this is equipment. bool important=false; //If an item's important it can't be discarded. int consumable=Consumable::NOT_A_CONSUMABLE; //Whether or not this item is consumed when used. }; struct CustomItemMessage{ std::wstring s=L""; ItemAction a=ItemAction::HPRECOVERY; }; class Item{ public: std::string name; std::string description; Battle::Move*battlemove=nullptr; ItemStatsStruct stats; std::vector messages; Item(std::string name,std::string desc,ItemStatsStruct stats={hpRecovery:0,ppRecovery:0,atkIncrease:0,spdIncrease:0,hpIncrease:0,ppIncrease:0,learnAbility:nullptr,damage:0,rollDmg:0,attack:0,defense:0,equip:EquipSlot::NONE,important:false,consumable:Consumable::NOT_A_CONSUMABLE},Battle::Move*battlemove=nullptr) :name(name),description(desc),stats(stats),battlemove(battlemove){ if (stats.hpRecovery) {messages.push_back({L"$USER recovers "+std::to_wstring(stats.hpRecovery)+L" HP.",ItemAction::HPRECOVERY});} if (stats.ppRecovery) {messages.push_back({L"$USER recovers "+std::to_wstring(stats.ppRecovery)+L" PP.",ItemAction::PPRECOVERY});} if (stats.atkIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.atkIncrease)+L" ATK point"+(stats.atkIncrease==1?L"":L"s")+L".",ItemAction::ATKINCREASE});} if (stats.hpIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.hpIncrease)+L" HP point"+(stats.hpIncrease==1?L"":L"s")+L".",ItemAction::HPINCREASE});} if (stats.ppIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.ppIncrease)+L" PP point"+(stats.ppIncrease==1?L"":L"s")+L".",ItemAction::PPINCREASE});} if (stats.spdIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.spdIncrease)+L" SPD point"+(stats.spdIncrease==1?L"":L"s")+L".",ItemAction::SPDINCREASE});} if (stats.learnAbility!=nullptr) {messages.push_back({L"$USER gains the ability to use "+transform_to(stats.learnAbility->name)+L" "+((stats.learnAbility->grade!=0)?std::wstring(1,stats.learnAbility->grade):L"")+L"!",ItemAction::LEARNMOVE});} } }; #endif