mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-20 09:17:29 +07:00
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:
parent
07ad2d4af2
commit
cac5236225
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user