Beispiel #1
0
bool Wearer::isEqual(ActorFeaturePtr rhs) const
{
  bool equal = false;
  WearerPtr crhs = std::dynamic_pointer_cast<Wearer>(rhs);

  if ( crhs != nullptr )
  {
    equal = true;
    //compare item slots and equipped items
    for (auto slot : ItemSlotType())
    {
      equal &= (hasSlot(slot) == crhs->hasSlot(slot));
      equal &= (isEquipped(slot) == crhs->isEquipped(slot));
      if ( equipped(slot) && crhs->equipped(slot) ) equal &=  ( *(equipped(slot)) == *(crhs->equipped(slot)) );
    }
  }

  return equal;
}
Beispiel #2
0
ActorPtr Wearer::unequip(ItemSlotType slot)
{
  ActorPtr r = equipped(slot);

  if (r)
  {
    _equippedItems->remove(r);
    _itemSlots[slot] = std::make_pair(nullptr, false);
  }

  return r;
}
Beispiel #3
0
ActorPtr Wearer::unequip(ItemSlotType slot)
{
  ActorPtr r = equipped(slot);

  if (r)
  {
    if (!_equippedItems->remove(r))
    {
      throw std::logic_error("Item equipped in slot, but not present in container!");
    }
    _itemSlots[slot] = nullptr;
  }

  return r;
}
Beispiel #4
0
std::string Wearer::debug(const std::string &linebreak)
{
  std::string d = " " + linebreak + "-----WEARER-----"+linebreak;
  for(auto slot : _itemSlots)
  {
    ActorPtr eq = equipped(slot.first);
    bool blocked = isBlocked(slot.first);
    PickablePtr p = eq ? eq->getFeature<Pickable>() : nullptr;
    d += ItemSlotType2Str(slot.first);
    d +=  ": "
        + (eq ? eq->getName() : "<none>")
        + (p ? " [" + toStr(p->getAmount()) + "]" : "" )
        + ( blocked ? " [BLOCKED] " : "" ) + linebreak;
  }
  d.append("----------------"+linebreak);
  return d;
}
Beispiel #5
0
bool Wearer::isEquipped(ItemSlotType slot) const
{
  return (equipped(slot) != nullptr);
}