mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Updated how locked filters are handled (#4984)
This commit is contained in:
parent
3dfa2943d4
commit
ceecd90347
5 changed files with 20 additions and 12 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -68,6 +67,9 @@ public class FilterCard extends FilterObject<Card> {
|
|||
}
|
||||
|
||||
public void add(ObjectPlayerPredicate predicate) {
|
||||
if (isLockedFilter()) {
|
||||
throw new UnsupportedOperationException("You may not modify a locked filter");
|
||||
}
|
||||
extraPredicates.add(predicate);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -17,13 +16,14 @@ public abstract class FilterImpl<E> implements Filter<E> {
|
|||
|
||||
protected List<Predicate<Object>> predicates = new ArrayList<>();
|
||||
protected String message;
|
||||
protected boolean lockedFilter = false; // Helps to prevent to "accidently" modify the StaticFilters objects
|
||||
protected boolean lockedFilter; // Helps to prevent to "accidently" modify the StaticFilters objects
|
||||
|
||||
@Override
|
||||
public abstract FilterImpl<E> copy();
|
||||
|
||||
public FilterImpl(String name) {
|
||||
this.message = name;
|
||||
this.lockedFilter = false;
|
||||
}
|
||||
|
||||
public FilterImpl(final FilterImpl<E> filter) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -27,11 +26,6 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
|
|||
super("permanent");
|
||||
}
|
||||
|
||||
public FilterPermanent(final FilterPermanent filter) {
|
||||
super(filter);
|
||||
this.extraPredicates = new ArrayList<>(filter.extraPredicates);
|
||||
}
|
||||
|
||||
public FilterPermanent(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
|
@ -43,11 +37,16 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
|
|||
|
||||
public FilterPermanent(Set<SubType> subtypesList, String name) {
|
||||
super(name);
|
||||
for (SubType subtype: subtypesList) {
|
||||
for (SubType subtype : subtypesList) {
|
||||
this.add(new SubtypePredicate(subtype));
|
||||
}
|
||||
}
|
||||
|
||||
public FilterPermanent(final FilterPermanent filter) {
|
||||
super(filter);
|
||||
this.extraPredicates = new ArrayList<>(filter.extraPredicates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObjectClass(Object object) {
|
||||
return object instanceof Permanent;
|
||||
|
|
@ -63,6 +62,9 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
|
|||
}
|
||||
|
||||
public void add(ObjectPlayerPredicate predicate) {
|
||||
if (isLockedFilter()) {
|
||||
throw new UnsupportedOperationException("You may not modify a locked filter");
|
||||
}
|
||||
extraPredicates.add(predicate);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -34,6 +33,9 @@ public class FilterPlayer extends FilterImpl<Player> {
|
|||
}
|
||||
|
||||
public void add(ObjectPlayerPredicate predicate) {
|
||||
if (isLockedFilter()) {
|
||||
throw new UnsupportedOperationException("You may not modify a locked filter");
|
||||
}
|
||||
extraPredicates.add(predicate);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -42,6 +41,9 @@ public class FilterStackObject extends FilterObject<StackObject> {
|
|||
}
|
||||
|
||||
public void add(ObjectPlayerPredicate predicate) {
|
||||
if (isLockedFilter()) {
|
||||
throw new UnsupportedOperationException("You may not modify a locked filter");
|
||||
}
|
||||
extraPredicates.add(predicate);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue