123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include "ItemFilter.h"
- #include "ItemType.h"
- #include "Item.h"
- #include "ItemSlot.h"
- ItemFilter::ItemFilter()
- : ReferenceCounter()
- {}
- bool ItemFilter::matchItem(const Item* zItem) const
- {
- return 1;
- }
- bool ItemFilter::matchSourceSlot(ItemSlot* zSlot) const
- {
- return zSlot->zStack() ? matchItem(zSlot->zStack()->zItem()) : 0;
- }
- bool ItemFilter::matchTargetSlot(ItemSlot* zSlot) const
- {
- return 1;
- }
- CombinedItemFilter::CombinedItemFilter(ItemFilter* filterA, ItemFilter* filterB, std::function<bool(bool, bool)> op)
- : ItemFilter(),
- filterA(filterA),
- filterB(filterB),
- op(op)
- {}
- bool CombinedItemFilter::matchItem(const Item* zItem) const
- {
- return op(filterA->matchItem(zItem), filterB->matchItem(zItem));
- }
- AnyItemFilter::AnyItemFilter()
- : ItemFilter()
- {}
- bool AnyItemFilter::matchItem(const Item* zItem) const
- {
- return true;
- }
- TypeItemFilter::TypeItemFilter(const ItemType* zType)
- : ItemFilter(),
- zType(zType)
- {}
- bool TypeItemFilter::matchItem(const Item* zItem) const
- {
- return zItem->zItemType() == zType;
- }
- SpecificSlotFilter::SpecificSlotFilter(int sourceSlotId, int targetSlotId)
- : ItemFilter(),
- sourceSlotId(sourceSlotId),
- targetSlotId(targetSlotId)
- {}
- bool SpecificSlotFilter::matchSourceSlot(ItemSlot* zSlot) const
- {
- return sourceSlotId == zSlot->getId();
- }
- bool SpecificSlotFilter::matchTargetSlot(ItemSlot* zSlot) const
- {
- return targetSlotId == zSlot->getId();
- }
|