void CreatureAttributes::consumeBodyParts(const Creature* c, const CreatureAttributes& other) { for (BodyPart part : ENUM_ALL(BodyPart)) if (other.bodyParts[part] > bodyParts[part]) { if (bodyParts[part] + 1 == other.bodyParts[part]) c->you(MsgType::GROW, "a " + getBodyPartName(part)); else c->you(MsgType::GROW, toString(other.bodyParts[part] - bodyParts[part]) + " " + getBodyPartName(part) + "s"); bodyParts[part] = other.bodyParts[part]; } }
string CreatureAttributes::bodyDescription() const { vector<string> ret; bool anyLimbs = false; auto listParts = {BodyPart::ARM, BodyPart::LEG, BodyPart::WING}; if (*humanoid) listParts = {BodyPart::WING}; for (BodyPart part : listParts) if (int num = numBodyParts(part)) { ret.push_back(getPluralText(getBodyPartName(part), num)); anyLimbs = true; } if (*humanoid) { bool noArms = numBodyParts(BodyPart::ARM) == 0; bool noLegs = numBodyParts(BodyPart::LEG) == 0; if (noArms && noLegs) ret.push_back("no limbs"); else if (noArms) ret.push_back("no arms"); else if (noLegs) ret.push_back("no legs"); } else if (!anyLimbs) ret.push_back("no limbs"); if (numBodyParts(BodyPart::HEAD) == 0) ret.push_back("no head"); if (ret.size() > 0) return " with " + combine(ret); else return ""; }
string CreatureAttributes::bodyDescription() const { vector<string> ret; for (BodyPart part : {BodyPart::ARM, BodyPart::LEG, BodyPart::WING}) if (int num = numBodyParts(part)) ret.push_back(getPlural(getBodyPartName(part), num)); if (isHumanoid() && numBodyParts(BodyPart::HEAD) == 0) ret.push_back("no head"); if (ret.size() > 0) return " with " + combine(ret); else return ""; }
PItem CreatureAttributes::getBodyPartItem(BodyPart part) { return ItemFactory::corpse(getName().bare() + " " + getBodyPartName(part), getName().bare() + " " + getBodyPartBone(part), *weight / 8, isMinionFood() ? ItemClass::FOOD : ItemClass::CORPSE); }