Fun little fix for incorrect stats_t struct ordering

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 7e26720c08
commit 7cda0fe1c7
  1. BIN
      C++ProjectTemplate
  2. 6
      entity.h
  3. 17
      main.cpp

Binary file not shown.

@ -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::vector<Battle::Move*>moveSet,std::vector<Item*>items={},int money=0,std::array<Item*,3>equipment={})
: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];
}

@ -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()

Loading…
Cancel
Save