mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
Simplify implementation and fix bugs of Kaito, Dancing Shadow (#10639)
Implement PermanentReferenceInCollectionPredicate used by that convert existing cards to use new Predicate as needed Replaces PermanentInListPredicate for longer term effects
This commit is contained in:
parent
8128e9935d
commit
c3f7a9ab21
5 changed files with 84 additions and 166 deletions
|
|
@ -20,6 +20,6 @@ public class PermanentInListPredicate implements Predicate<Permanent> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return permanents.contains(input);
|
||||
return (permanents != null && permanents.contains(input));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
package mage.filter.predicate.permanent;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author notgreat
|
||||
*/
|
||||
public class PermanentReferenceInCollectionPredicate implements Predicate<Permanent> {
|
||||
private final Collection<MageObjectReference> references;
|
||||
|
||||
public PermanentReferenceInCollectionPredicate(Collection<MageObjectReference> references) {
|
||||
//Note: it is assumed that the collection passed in isn't ever mutated afterwards
|
||||
this.references = references;
|
||||
}
|
||||
public PermanentReferenceInCollectionPredicate(Collection<Permanent> permanents, Game game) {
|
||||
this.references = permanents.stream().map((p) -> new MageObjectReference(p, game))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return (references != null &&
|
||||
references.contains(new MageObjectReference(input, game)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue