mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
New Method to filter a card pool based on a Predicate
This method will be used during the validation of each deck section.
This commit is contained in:
@@ -457,4 +457,20 @@ public class CardPool extends ItemPool<PaperCard> {
|
||||
}
|
||||
return filteredPool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a predicate to this CardPool's cards.
|
||||
* @param predicate the Predicate to apply to this CardPool
|
||||
* @return a new CardPool made from this CardPool with only the cards that agree with the provided Predicate
|
||||
*/
|
||||
public CardPool getFilteredPoolWithCardsCount(Predicate<PaperCard> predicate){
|
||||
CardPool filteredPool = new CardPool();
|
||||
for(Entry<PaperCard, Integer> entry : this.items.entrySet()){
|
||||
PaperCard pc = entry.getKey();
|
||||
int count = entry.getValue();
|
||||
if(predicate.apply(pc))
|
||||
filteredPool.add(pc, count);
|
||||
}
|
||||
return filteredPool;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user