Started implementing Castle Wars (not ready to enable yet)

This commit is contained in:
Dan Ginovker
2023-04-10 07:13:54 +00:00
committed by Ryan
parent dd3c957f8b
commit 034cc75a61
32 changed files with 1166 additions and 75 deletions
@@ -372,6 +372,50 @@ public class Container {
return true;
}
/**
* Removes all items from the container that have the passed in IDs
*
* @param ids Array of IDs to remove
* @return {@code True} if all the items got removed, <br> {@code false} if some of the
* found items were null
*/
public boolean removeAll(int[] ids) {
boolean removedAll = true;
for (int id : ids) {
if (!removeAll(id)) {
removedAll = false;
}
}
update();
return removedAll;
}
/**
* Removes all items from the container that have the passed in ID
*
* @param id Item ID to remove all instances of
* @return {@code True} if all the items got removed, <br> {@code false} if some of the
* found items were null
*/
public boolean removeAll(int id) {
ArrayList<Item> matchingIdItems = new ArrayList<>();
for (Item item : this.items) {
// If the item is not null and the item ID matches the ID we're looking for
if (item != null && item.getId() == id) {
// Add the item to the list
matchingIdItems.add(item);
}
}
boolean res = true;
// Remove all the items from the container
for (Item item : matchingIdItems) {
if (!remove(item, false)) {
res = false;
}
}
return res;
}
/**
* Replaces the item on the given slot with the argued item.
*