mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Minor formatting.
This commit is contained in:
parent
5932dc0323
commit
4a2a40ae2d
15 changed files with 64 additions and 29 deletions
|
|
@ -189,6 +189,7 @@ class CavernOfSoulsWatcher extends WatcherImpl<CavernOfSoulsWatcher> {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
// TODO: Replace identification by name by better method that also works if ability is copied from other land with other name
|
||||
if (object != null && object.getName().equals("Cavern of Souls") && event.getFlag()) {
|
||||
spells.add(event.getTargetId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ import java.util.UUID;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.combat.MustBeBlockedByAllSourceEffect;
|
||||
import mage.abilities.effects.common.combat.MustBeBlockedByAllTargetEffect;
|
||||
import mage.abilities.effects.common.continious.BoostTargetEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.RegenerateSourceEffect;
|
||||
import mage.abilities.effects.common.SacrificeControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
|
|
|||
|
|
@ -44,10 +44,11 @@ public class SpecialActions extends AbilitiesImpl<SpecialAction> {
|
|||
}
|
||||
|
||||
public LinkedHashMap<UUID, SpecialAction> getControlledBy(UUID controllerId) {
|
||||
LinkedHashMap<UUID, SpecialAction> controlledBy = new LinkedHashMap<UUID, SpecialAction>();
|
||||
LinkedHashMap<UUID, SpecialAction> controlledBy = new LinkedHashMap<>();
|
||||
for (SpecialAction action: this) {
|
||||
if (action.getControllerId().equals(controllerId))
|
||||
if (action.getControllerId().equals(controllerId)) {
|
||||
controlledBy.put(action.id, action);
|
||||
}
|
||||
}
|
||||
return controlledBy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.filter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import mage.MageObject;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
|
|
@ -36,6 +37,8 @@ import mage.game.Game;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author North
|
||||
*
|
||||
* @param <E>
|
||||
*/
|
||||
public interface Filter<E> extends Serializable {
|
||||
|
||||
|
|
@ -45,7 +48,7 @@ public interface Filter<E> extends Serializable {
|
|||
Equal("=="),
|
||||
LessThan("<");
|
||||
|
||||
private String text;
|
||||
private final String text;
|
||||
|
||||
ComparisonType(String text) {
|
||||
this.text = text;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import mage.game.Game;
|
|||
public class FilterCard extends FilterObject<Card> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected List<ObjectPlayerPredicate<ObjectPlayer<Card>>> extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Card>>>();
|
||||
protected List<ObjectPlayerPredicate<ObjectPlayer<Card>>> extraPredicates = new ArrayList<>();
|
||||
|
||||
public FilterCard() {
|
||||
super("card");
|
||||
|
|
@ -60,7 +60,7 @@ public class FilterCard extends FilterObject<Card> {
|
|||
|
||||
public FilterCard(FilterCard filter) {
|
||||
super(filter);
|
||||
this.extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Card>>>(filter.extraPredicates);
|
||||
this.extraPredicates = new ArrayList<>(filter.extraPredicates);
|
||||
}
|
||||
|
||||
//20130711 708.6c
|
||||
|
|
@ -88,7 +88,7 @@ public class FilterCard extends FilterObject<Card> {
|
|||
return false;
|
||||
}
|
||||
|
||||
return Predicates.and(extraPredicates).apply(new ObjectPlayer(card, playerId), game);
|
||||
return Predicates.and(extraPredicates).apply(new ObjectPlayer<>(card, playerId), game);
|
||||
}
|
||||
|
||||
public boolean match(Card card, UUID sourceId, UUID playerId, Game game) {
|
||||
|
|
@ -96,7 +96,7 @@ public class FilterCard extends FilterObject<Card> {
|
|||
return false;
|
||||
}
|
||||
|
||||
return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(card, sourceId, playerId), game);
|
||||
return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer<>(card, sourceId, playerId), game);
|
||||
}
|
||||
|
||||
public void add(ObjectPlayerPredicate predicate) {
|
||||
|
|
@ -104,7 +104,7 @@ public class FilterCard extends FilterObject<Card> {
|
|||
}
|
||||
|
||||
public Set<Card> filter(Set<Card> cards, Game game) {
|
||||
Set<Card> filtered = new HashSet<Card>();
|
||||
Set<Card> filtered = new HashSet<>();
|
||||
for (Card card : cards) {
|
||||
if (match(card, game)) {
|
||||
filtered.add(card);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.filter;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.MageObject;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.Game;
|
||||
|
|
@ -52,7 +53,7 @@ public abstract class FilterImpl<E> implements Filter<E> {
|
|||
this.message = name;
|
||||
}
|
||||
|
||||
public FilterImpl(FilterImpl filter) {
|
||||
public FilterImpl(FilterImpl<E> filter) {
|
||||
this.message = filter.message;
|
||||
this.predicates = new ArrayList<>(filter.predicates);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,19 +33,20 @@ import mage.MageObject;
|
|||
/**
|
||||
*
|
||||
* @author North
|
||||
* @param <E>
|
||||
*/
|
||||
public class FilterObject<E extends MageObject> extends FilterImpl<E> {
|
||||
|
||||
@Override
|
||||
public FilterObject<E> copy() {
|
||||
return new FilterObject<E>(this);
|
||||
return new FilterObject<>(this);
|
||||
}
|
||||
|
||||
public FilterObject(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public FilterObject(FilterObject filter) {
|
||||
public FilterObject(FilterObject<E> filter) {
|
||||
super(filter);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import mage.players.Player;
|
|||
*/
|
||||
public class FilterPlayer extends FilterImpl<Player> {
|
||||
|
||||
protected List<ObjectPlayerPredicate<ObjectPlayer<Player>>> extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Player>>>();
|
||||
protected List<ObjectPlayerPredicate<ObjectPlayer<Player>>> extraPredicates = new ArrayList<>();
|
||||
|
||||
public FilterPlayer() {
|
||||
this("player");
|
||||
|
|
@ -57,10 +57,10 @@ public class FilterPlayer extends FilterImpl<Player> {
|
|||
|
||||
public FilterPlayer(final FilterPlayer filter) {
|
||||
super(filter);
|
||||
this.extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Player>>>(filter.extraPredicates);
|
||||
this.extraPredicates = new ArrayList<>(filter.extraPredicates);
|
||||
}
|
||||
|
||||
public void add(ObjectPlayerPredicate predicate) {
|
||||
public void add(ObjectPlayerPredicate<ObjectPlayer<Player>> predicate) {
|
||||
extraPredicates.add(predicate);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@
|
|||
package mage.filter.predicate;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
* @param <T>
|
||||
*/
|
||||
public class ObjectPlayer<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.filter.predicate;
|
|||
/**
|
||||
*
|
||||
* @author North
|
||||
* @param <T>
|
||||
*/
|
||||
public interface ObjectPlayerPredicate<T extends ObjectPlayer> extends Predicate<T> {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.util.UUID;
|
|||
/**
|
||||
*
|
||||
* @author North
|
||||
* @param <T>
|
||||
*/
|
||||
public class ObjectSourcePlayer<T> extends ObjectPlayer<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import mage.game.Game;
|
|||
* Determines a true or false value for a given input.
|
||||
*
|
||||
* @author North
|
||||
* @param <T>
|
||||
*/
|
||||
public interface Predicate <T> extends Serializable {
|
||||
/**
|
||||
|
|
@ -47,6 +48,9 @@ public interface Predicate <T> extends Serializable {
|
|||
* predicate.apply(b)}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input
|
||||
* @param game
|
||||
* @return
|
||||
* @throws NullPointerException if {@code input} is null and this predicate does not accept null
|
||||
* arguments
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -47,9 +47,12 @@ public final class Predicates {
|
|||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the given predicate evaluates to {@code false}.
|
||||
* @param <T>
|
||||
* @param predicate
|
||||
* @return
|
||||
*/
|
||||
public static <T> Predicate<T> not(Predicate<T> predicate) {
|
||||
return new NotPredicate<T>(predicate);
|
||||
return new NotPredicate<>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,9 +60,12 @@ public final class Predicates {
|
|||
* components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is
|
||||
* found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this
|
||||
* predicate. If {@code components} is empty, the returned predicate will always evaluate to {@code true}.
|
||||
* @param <T>
|
||||
* @param components
|
||||
* @return
|
||||
*/
|
||||
public static <T> Predicate<T> and(Iterable<? extends Predicate<? super T>> components) {
|
||||
return new AndPredicate<T>(defensiveCopy(components));
|
||||
return new AndPredicate<>(defensiveCopy(components));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,18 +73,25 @@ public final class Predicates {
|
|||
* components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is
|
||||
* found. It defensively copies the array passed in, so future changes to it won't alter the behavior of this
|
||||
* predicate. If {@code components} is empty, the returned predicate will always evaluate to {@code true}.
|
||||
* @param <T>
|
||||
* @param components
|
||||
* @return
|
||||
*/
|
||||
public static <T> Predicate<T> and(Predicate<? super T>... components) {
|
||||
return new AndPredicate<T>(defensiveCopy(components));
|
||||
return new AndPredicate<>(defensiveCopy(components));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if both of its components evaluate to {@code true}. The
|
||||
* components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is
|
||||
* found.
|
||||
* @param <T>
|
||||
* @param first
|
||||
* @param second
|
||||
* @return
|
||||
*/
|
||||
public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) {
|
||||
return new AndPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
|
||||
return new AndPredicate<>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,9 +99,12 @@ public final class Predicates {
|
|||
* components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found.
|
||||
* It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this predicate.
|
||||
* If {@code components} is empty, the returned predicate will always evaluate to {@code true}.
|
||||
* @param <T>
|
||||
* @param components
|
||||
* @return
|
||||
*/
|
||||
public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) {
|
||||
return new OrPredicate<T>(defensiveCopy(components));
|
||||
return new OrPredicate<>(defensiveCopy(components));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,17 +112,24 @@ public final class Predicates {
|
|||
* components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found.
|
||||
* It defensively copies the array passed in, so future changes to it won't alter the behavior of this predicate. If
|
||||
* {@code components} is empty, the returned predicate will always evaluate to {@code true}.
|
||||
* @param <T>
|
||||
* @param components
|
||||
* @return
|
||||
*/
|
||||
public static <T> Predicate<T> or(Predicate<? super T>... components) {
|
||||
return new OrPredicate<T>(defensiveCopy(components));
|
||||
return new OrPredicate<>(defensiveCopy(components));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if either of its components evaluates to {@code true}. The
|
||||
* components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found.
|
||||
* @param <T>
|
||||
* @param first
|
||||
* @param second
|
||||
* @return
|
||||
*/
|
||||
public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) {
|
||||
return new OrPredicate<T>(Predicates.<T>asList(first, second));
|
||||
return new OrPredicate<>(Predicates.<T>asList(first, second));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,7 +221,7 @@ public final class Predicates {
|
|||
}
|
||||
|
||||
static <T> List<T> defensiveCopy(Iterable<T> iterable) {
|
||||
ArrayList<T> list = new ArrayList<T>();
|
||||
ArrayList<T> list = new ArrayList<>();
|
||||
for (T element : iterable) {
|
||||
list.add(checkNotNull(element));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@
|
|||
*/
|
||||
package mage.filter.predicate.other;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import mage.cards.Card;
|
||||
import mage.filter.predicate.ObjectPlayer;
|
||||
import mage.filter.predicate.ObjectPlayerPredicate;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue