void MoraleLuckBox::set(const IBonusBearer *node) { OBJ_CONSTRUCTION_CAPTURING_ALL; const int textId[] = {62, 88}; //eg %s \n\n\n {Current Luck Modifiers:} const int noneTxtId = 108; //Russian version uses same text for neutral morale\luck const int neutralDescr[] = {60, 86}; //eg {Neutral Morale} \n\n Neutral morale means your armies will neither be blessed with extra attacks or freeze in combat. const int componentType[] = {CComponent::luck, CComponent::morale}; const int hoverTextBase[] = {7, 4}; const Bonus::BonusType bonusType[] = {Bonus::LUCK, Bonus::MORALE}; int (IBonusBearer::*getValue[])() const = {&IBonusBearer::LuckVal, &IBonusBearer::MoraleVal}; TBonusListPtr modifierList(new BonusList()); if (node) { modifierList = node->getBonuses(Selector::type(bonusType[morale])); bonusValue = (node->*getValue[morale])(); } else bonusValue = 0; int mrlt = (bonusValue>0)-(bonusValue<0); //signum: -1 - bad luck / morale, 0 - neutral, 1 - good hoverText = CGI->generaltexth->heroscrn[hoverTextBase[morale] - mrlt]; baseType = componentType[morale]; text = CGI->generaltexth->arraytxt[textId[morale]]; boost::algorithm::replace_first(text,"%s",CGI->generaltexth->arraytxt[neutralDescr[morale]-mrlt]); if (morale && node && (node->hasBonusOfType(Bonus::UNDEAD) || node->hasBonusOfType(Bonus::BLOCK_MORALE) || node->hasBonusOfType(Bonus::NON_LIVING))) { text += CGI->generaltexth->arraytxt[113]; //unaffected by morale bonusValue = 0; } else if(!morale && node && node->hasBonusOfType(Bonus::BLOCK_LUCK)) { // TODO: there is no text like "Unaffected by luck" so probably we need own text text += CGI->generaltexth->arraytxt[noneTxtId]; bonusValue = 0; } else if(modifierList->empty()) text += CGI->generaltexth->arraytxt[noneTxtId];//no modifiers else { for(auto& elem : *modifierList) { if(elem->val != 0) //no bonuses with value 0 text += "\n" + elem->Description(); } } std::string imageName; if (small) imageName = morale ? "IMRL30": "ILCK30"; else imageName = morale ? "IMRL42" : "ILCK42"; delete image; image = new CAnimImage(imageName, bonusValue + 3); image->moveBy(Point(pos.w/2 - image->pos.w/2, pos.h/2 - image->pos.h/2));//center icon }
//Produção NameDecl NameDeclNode* namedecl(){ printf("Statement'\n"); ModifierListNode* modifiers = modifierList(); IdListNode* idlistdl = idList(); return new NameDeclNode(modifiers,idlistdl); }