diff --git a/core/src/com/riiablo/attributes/StatList.java b/core/src/com/riiablo/attributes/StatList.java index 05b71ceb..aa0a6c8c 100644 --- a/core/src/com/riiablo/attributes/StatList.java +++ b/core/src/com/riiablo/attributes/StatList.java @@ -367,6 +367,10 @@ public final class StatList { return Arrays.binarySearch(ids, startingOffset(list), endingOffset(list), stat) >= 0; } + public boolean contains(int list, short stat, int param) { + return indexOf(list, stat, param) >= 0; + } + public int indexOf(int list, short stat, int param) { final int listStart = startingOffset(list); final int listEnd = endingOffset(list); diff --git a/core/src/com/riiablo/attributes/StatListGetter.java b/core/src/com/riiablo/attributes/StatListGetter.java index 9226accc..3ec07376 100644 --- a/core/src/com/riiablo/attributes/StatListGetter.java +++ b/core/src/com/riiablo/attributes/StatListGetter.java @@ -37,6 +37,11 @@ public final class StatListGetter implements Iterable { return stats.contains(list, stat); } + /** @see StatList#contains(int, short) */ + public boolean contains(StatGetter stat) { + return stats.contains(list, stat.id(), stat.param()); + } + /** @see StatList#indexOf(int, short) */ public StatGetter get(short stat) { final int index = indexOf(stat); @@ -48,6 +53,17 @@ public final class StatListGetter implements Iterable { return tuple.set(stats, index); } + /** @see StatList#indexOf(int, short, int) */ + public StatGetter get(StatGetter stat) { + final int index = stats.indexOf(list, stat.id(), stat.param()); + if (index < 0) { + log.warn("stats({}) list({}) did not contain stat({})", stats, list, stat); + return null; + } + + return tuple.set(stats, index); + } + /** @see StatList#firstIndexOf(int, short) */ StatGetter first(short stat) { final int index = stats.firstIndexOf(list, stat);