Archived
0

add minimum supply and minimum demand to vendor filter

This commit is contained in:
iMoHax
2016-12-05 17:45:34 +03:00
parent e557206bce
commit c96f8d320b
6 changed files with 73 additions and 9 deletions

View File

@@ -14,12 +14,18 @@ public class VendorFilter {
private boolean illegalOnly;
private boolean dontBuy;
private boolean dontSell;
private long minSupply;
private long minDemand;
private final Collection<Item> buyExcludes;
private final Collection<Item> sellExcludes;
public VendorFilter() {
buyExcludes = new ArrayList<>();
sellExcludes = new ArrayList<>();
minSupply = 0;
minDemand = 0;
dontSell = false;
dontBuy = false;
skipIllegal = false;
illegalOnly = false;
}
@@ -32,6 +38,22 @@ public class VendorFilter {
this.disable = disable;
}
public long getMinSupply() {
return minSupply;
}
public void setMinSupply(long minSupply) {
this.minSupply = minSupply;
}
public long getMinDemand() {
return minDemand;
}
public void setMinDemand(long minDemand) {
this.minDemand = minDemand;
}
public boolean isSkipIllegal() {
return skipIllegal;
}
@@ -100,8 +122,8 @@ public class VendorFilter {
if (disable) return false;
if (skipIllegal && offer.isIllegal()) return true;
switch (offer.getType()) {
case SELL: return dontSell || sellExcludes.contains(offer.getItem());
case BUY: return dontBuy || (illegalOnly && !offer.isIllegal()) || buyExcludes.contains(offer.getItem());
case SELL: return dontSell || sellExcludes.contains(offer.getItem()) || (offer.getCount() > 0 && offer.getCount() < minSupply);
case BUY: return dontBuy || (illegalOnly && !offer.isIllegal()) || buyExcludes.contains(offer.getItem()) || (offer.getCount() > 0 && offer.getCount() < minDemand);
}
return false;
}

View File

@@ -21,4 +21,24 @@ public class SimpleGroup implements Group {
public GROUP_TYPE getType() {
return type;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SimpleGroup)) return false;
SimpleGroup that = (SimpleGroup) o;
if (!name.equals(that.name)) return false;
if (type != that.type) return false;
return true;
}
@Override
public int hashCode() {
int result = name.hashCode();
result = 31 * result + type.hashCode();
return result;
}
}