Added support for using StatGetter on StatListGetter operations

Added support for using StatGetter on StatListGetter operations
Created StatList#contains(int,short,int) to check a specific stat with param
This commit is contained in:
Collin Smith 2020-09-03 14:26:35 -07:00
parent 07ad2d4af2
commit cac5236225
2 changed files with 20 additions and 0 deletions

View File

@ -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);

View File

@ -37,6 +37,11 @@ public final class StatListGetter implements Iterable<StatGetter> {
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<StatGetter> {
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);