void consumeAttr(optional<T>& mine, const optional<T>& his, vector<string>& adjectives, const string& adj) { if (consumeProb() && !mine && his) { mine = *his; if (!adj.empty()) adjectives.push_back(adj); } }
void consumeAttr(T& mine, const T& his, vector<string>& adjectives, const string& adj) { if (consumeProb() && mine < his) { mine = his; if (!adj.empty()) adjectives.push_back(adj); } }
void CreatureAttributes::consumeEffects(const EnumMap<LastingEffect, int>& permanentEffects) { for (LastingEffect effect : ENUM_ALL(LastingEffect)) if (permanentEffects[effect] > 0 && !isAffectedPermanently(effect) && consumeProb() && LastingEffects::canConsume(effect)) { addPermanentEffect(effect, 1); } }
void consumeAttr(T& mine, const T& his, vector<string>& adjectives, const string& adj, const int& cap) { int hisCapped = (his > cap) ? cap : his; if (consumeProb() && mine < hisCapped) { mine = hisCapped; if (!adj.empty()) adjectives.push_back(adj); } }
void consumeAttr(Skillset& mine, const Skillset& his, vector<string>& adjectives) { bool was = false; for (SkillId id : his.getAllDiscrete()) if (!mine.hasDiscrete(id) && Skill::get(id)->transferOnConsumption() && consumeProb()) { mine.insert(id); was = true; } for (SkillId id : ENUM_ALL(SkillId)) { if (!Skill::get(id)->isDiscrete() && mine.getValue(id) < his.getValue(id)) { mine.setValue(id, his.getValue(id)); was = true; } } if (was) adjectives.push_back("more skillfull"); }
void consumeAttr(Gender& mine, const Gender& his, vector<string>& adjectives) { if (consumeProb() && mine != his) { mine = his; adjectives.emplace_back(mine == Gender::male ? "more masculine" : "more feminine"); } }
void consumeAttr(Gender& mine, const Gender& his, vector<string>& adjectives) { if (consumeProb() && mine != his) { mine = his; adjectives.emplace_back(get(mine, "more masculine", "more feminine", "more neuter")); } }