diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 455b8bb..8025e94 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 92c08b1..7a39c24 100644 --- a/main.cpp +++ b/main.cpp @@ -308,18 +308,19 @@ enum class BattleMoveName{ PKFIRE_O, }; +enum class ItemName{ + COOKIE, + EGG, + PIZZA, + CRACKED_BAT, + LIGHT_JACKET, + KEY_TO_THE_PALACE, +}; + using convert_t = std::codecvt_utf8; std::wstring_convert strconverter; - -std::string to_string(std::wstring wstr) -{ - return strconverter.to_bytes(wstr); -} - -std::wstring to_wstring(std::string str) -{ - return strconverter.from_bytes(str); -} +std::string to_string(std::wstring wstr){return strconverter.to_bytes(wstr);} +std::wstring to_wstring(std::string str){return strconverter.from_bytes(str);} namespace Battle{ class Move{ @@ -348,6 +349,35 @@ namespace Battle{ }; } +namespace EquipSlot{ + enum Equip{ + WEAPON, + ARMOR, + ACCESSORY, + NONE + }; +} + +struct ItemStatsStruct{ + int hpRecovery=0; + int ppRecovery=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. + bool consumable=false; //Whether or not this item is consumed when used. +}; + +class Item{ + public: + std::string name; + std::string description; + Battle::Move*battlemove=nullptr; + ItemStatsStruct stats; + Item(std::string name,std::string desc,ItemStatsStruct stats={0,0,0,0,EquipSlot::NONE,false,false},Battle::Move*battlemove=nullptr) + :name(name),description(desc),stats(stats),battlemove(battlemove){} +}; + class Entity{ private: int HP=0; @@ -369,13 +399,15 @@ class Entity{ int selectedTarget = 0; Battle::Move*selectedMove = nullptr; //The index of the selected move. int channelTimeRemaining = 0; //The amount of channel time left until move can be performed. - vd2d channelPos = {0,0}; //Where are channel is happening. + vd2d channelPos = {0,0}; //Where our channel is happening. + std::vector inventory; //Used mostly for enemy spoils. + std::array equipment; //Equipment this character is using. //Used for initializing players. - Entity(int HP,int maxHP,int PP,int maxPP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,int damageReduction=0,bool smart=false,bool dumb=false) - :Entity(nullptr,HP,maxHP,PP,maxPP,baseAtk,resistances,speed,moveSet,damageReduction,smart,dumb){} + Entity(int HP,int maxHP,int PP,int maxPP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,std::vectoritems={},std::arrayequipment={},int damageReduction=0,bool smart=false,bool dumb=false) + :Entity(nullptr,HP,maxHP,PP,maxPP,baseAtk,resistances,speed,moveSet,items,equipment,damageReduction,smart,dumb){} //Use this for initializing enemies as it lets you specify an object. - Entity(Object*obj,int HP,int maxHP,int PP,int maxPP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,int damageReduction=0,bool smart=false,bool dumb=false) - :obj(obj),HP(HP),maxHP(maxHP),PP(PP),maxPP(maxPP),baseAtk(baseAtk),speed(speed),moveSet(moveSet),damageReduction(damageReduction),smart(smart),dumb(dumb){ + Entity(Object*obj,int HP,int maxHP,int PP,int maxPP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,std::vectoritems={},std::arrayequipment={},int damageReduction=0,bool smart=false,bool dumb=false) + :obj(obj),HP(HP),maxHP(maxHP),PP(PP),maxPP(maxPP),baseAtk(baseAtk),speed(speed),equipment(equipment),moveSet(moveSet),damageReduction(damageReduction),inventory(items),smart(smart),dumb(dumb){ for (int i=0;i<4;i++) { this->resistances[i]=resistances[i]; } @@ -527,6 +559,7 @@ public: bool ANYKEYPRESSED=false; bool ACTIONKEYPRESSED=false; std::vector> BATTLE_MOVELIST_DISPLAY; + std::vector PARTY_INVENTORY; std::map ADDITIONAL_FONT_VALS = { {α,0},{β,1},{γ,2},{Ω,3},{Σ,4}, }; @@ -549,6 +582,7 @@ public: std::vector PARTICLES; std::vector DAMAGE_NUMBERS; std::map,vd2d> MOVEMENT_GRID; + std::mapITEMLIST; vi2d SELECTED_MOVE_SQUARE; Effect*CURRENT_EFFECT=nullptr; @@ -570,6 +604,7 @@ public: EnableLayer(layer::COLLISION,false); SetupMoveList(); + SetupItemList(); SetupPartyMemberStats(); SetupAnimations(); SetupObjectInfo(); @@ -2219,6 +2254,15 @@ goes on a very long time, I hope you can understand this is only for testing pur MOVELIST[BattleMoveName::PKFIRE_O]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",OMEGA,360,100,ㅍ 32,7,0,false,{0,0,20,0}); } + void SetupItemList() { //hpRecovery,ppRecovery,attack,dmgReduction,equip,important,consumable + ITEMLIST[ItemName::COOKIE]=new Item("Cookie","A delightful little treat. Restores 40 HP.",{hpRecovery:40,consumable:true}); + ITEMLIST[ItemName::EGG]=new Item("Egg","Did it come before or after the chicken? Restores 60 HP.",{hpRecovery:60,consumable:true}); + ITEMLIST[ItemName::PIZZA]=new Item("Pizza","A scrumptious meal filled with lots of cheese. Restores 200 HP.",{hpRecovery:200,consumable:true}); + ITEMLIST[ItemName::CRACKED_BAT]=new Item("Cracked Bat","Has some dents in it, but you can probably still dents things with it yourself.",{attack:4,equip:EquipSlot::WEAPON}); + ITEMLIST[ItemName::LIGHT_JACKET]=new Item("Light Jacket","Fits just fine.",{defense:2,equip:EquipSlot::ARMOR}); + ITEMLIST[ItemName::KEY_TO_THE_PALACE]=new Item("Key to the Palace","Lets you access a Palace.",{important:true}); + } + void SetupAnimations() { CreateSprite("terrainmap.png"); CreateSprite("additionalFont.png"); @@ -2726,7 +2770,7 @@ goes on a very long time, I hope you can understand this is only for testing pur for (int i=0;iobjs.size();i++) { Entity*ent=ENCOUNTER_LIST[id]->objs[i]; Object*newObj=new Object(ent->obj->id,ent->obj->name,ent->obj->GetPos(),ent->obj->spr,ent->obj->GetScale(),ent->obj->color,ent->obj->animationSpd,ent->obj->temp); - ents.push_back(new Entity(newObj,ent->GetHP(),ent->maxHP,ent->PP,ent->maxPP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->damageReduction,ent->smart,ent->dumb)); + ents.push_back(new Entity(newObj,ent->GetHP(),ent->maxHP,ent->PP,ent->maxPP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->inventory,ent->equipment,ent->damageReduction,ent->smart,ent->dumb)); } Encounter*data=new Encounter(id,pos,ENCOUNTER_LIST[id]->playerPos,ents,chance); data->chance=chance;