diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 37f2cfb..4eb80bc 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/entity.h b/entity.h index 2790d22..6f65a63 100644 --- a/entity.h +++ b/entity.h @@ -55,11 +55,11 @@ class Entity{ bool dumb=false; stats_t(pstats_t stats) { this->HP=stats.HP; + this->maxHP=stats.maxHP; this->PP=stats.PP; + this->maxPP=stats.maxPP; this->targetHP=stats.targetHP; this->targetPP=stats.targetPP; - this->maxHP=stats.maxHP; - this->maxPP=stats.maxPP; this->baseAtk=stats.baseAtk; this->speed=stats.speed; this->resistances=stats.resistances; @@ -141,7 +141,7 @@ class Entity{ } //Use this for initializing enemies as it lets you specify an object. Entity(Object*obj,pstats_t stats,std::vectormoveSet,std::vectoritems={},int money=0,std::arrayequipment={}) - :obj(obj),stats({stats.HP,stats.PP,stats.targetHP,stats.targetPP,stats.maxHP,stats.maxPP,stats.baseAtk,stats.speed,stats.resistances,stats.damageReduction,stats.smart,stats.dumb}),equipment(equipment),moveSet(moveSet),inventory(items),money(money){ + :obj(obj),stats({HP:stats.HP,maxHP:stats.maxHP,PP:stats.PP,maxPP:stats.maxPP,targetHP:stats.targetHP,targetPP:stats.targetPP,baseAtk:stats.baseAtk,speed:stats.speed,resistances:stats.resistances,damageReduction:stats.damageReduction,smart:stats.smart,dumb:stats.dumb}),equipment(equipment),moveSet(moveSet),inventory(items),money(money){ for (int i=0;i<4;i++) { this->stats.resistances[i]=stats.resistances[i]; } diff --git a/main.cpp b/main.cpp index db873a0..d81e1b8 100644 --- a/main.cpp +++ b/main.cpp @@ -1809,6 +1809,14 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"), GAME_STATE=GameState::GAME_WORLD; SHOPKEEPER_INTERACTING_WITH->ShoppingCompleted(); } + } else { + if (SHOP_ITEMS[SHOP_MENU_CURSOR].second<=MONEY) { + MONEY-=SHOP_ITEMS[SHOP_MENU_CURSOR].second; + DisplayMessageBox("You purchase "+A_An(SHOP_ITEMS[SHOP_MENU_CURSOR].first->name)+" for $"+std::to_string(SHOP_ITEMS[SHOP_MENU_CURSOR].second)+"."); + PARTY_INVENTORY.push_back(SHOP_ITEMS[SHOP_MENU_CURSOR].first); + } else { + DisplayMessageBox("You do not have enough money to purchase "+A_An(SHOP_ITEMS[SHOP_MENU_CURSOR].first->name+".")); + } } } }break; @@ -4858,6 +4866,15 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"), DrawStringPropDecal({pos.x+stringOffset.x+textSize.x+2,pos.y+stringOffset.y},"00",WHITE,{0.4f,0.7f}); DrawLineDecal({pos.x+stringOffset.x+textSize.x+2,pos.y+stringOffset.y+textSize2.y*0.7f},{pos.x+stringOffset.x+textSize.x+textSize2.x*0.4f+2,pos.y+stringOffset.y+textSize2.y*0.7f}); } + + //Returns a version of str with a/an and a space prepended to it followed by the str itself. + std::string A_An(std::string str) { + return startsWithVowel(str)?"an "+str:"a "+str; + } + + bool startsWithVowel(std::string str) { + return str.length()>0&&(str[0]=='a'||str[0]=='e'||str[0]=='i'||str[0]=='o'||str[0]=='u'||str[0]=='A'||str[0]=='E'||str[0]=='I'||str[0]=='O'||str[0]=='U'); + } }; int main()