Merge pull request #2879 from ingmargoudt/master

enum comparisons, return empty set rather than null
This commit is contained in:
ingmargoudt 2017-02-19 23:40:30 +01:00 committed by GitHub
commit 2d4c1f9b06
61 changed files with 159 additions and 195 deletions

View file

@ -31,12 +31,15 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -119,17 +122,11 @@ public class NecroticOoze extends CardImpl {
@Override
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
// the dependent classes needs to be an enclosed class for dependent check of continuous effects
Set<UUID> dependentTo = null;
for (ContinuousEffect effect : allEffectsInLayer) {
// http://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/285211-yixlid-jailer-vs-necrotic-ooze
if (YixlidJailer.class.equals(effect.getClass().getEnclosingClass())) {
if (dependentTo == null) {
dependentTo = new HashSet<>();
}
dependentTo.add(effect.getId());
}
}
return dependentTo;
return allEffectsInLayer.stream()
.filter(effect -> YixlidJailer.class.equals(effect.getClass().getEnclosingClass()))
.map(Effect::getId)
.collect(Collectors.toSet());
}
}

View file

@ -23,8 +23,7 @@ public class AfterUpkeepStepCondtion implements Condition {
@Override
public boolean apply(Game game, Ability source) {
return !(game.getStep().getType() == PhaseStep.UNTAP
|| game.getStep().getType() == PhaseStep.UPKEEP);
return game.getStep().getType().isAfter(PhaseStep.UPKEEP);
}
@Override

View file

@ -26,10 +26,7 @@ public class BeforeBlockersAreDeclaredCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
return !(game.getStep().getType().equals(PhaseStep.DECLARE_BLOCKERS)
|| game.getStep().getType().equals(PhaseStep.FIRST_COMBAT_DAMAGE)
|| game.getStep().getType().equals(PhaseStep.COMBAT_DAMAGE)
|| game.getStep().getType().equals(PhaseStep.END_COMBAT));
return game.getStep().getType().isBefore(PhaseStep.DECLARE_BLOCKERS);
}
@Override

View file

@ -28,6 +28,7 @@
package mage.abilities.decorator;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.effects.AsThoughEffect;
@ -36,10 +37,9 @@ import mage.constants.Duration;
import mage.game.Game;
/**
*
* @author LevelX2
*/
public class ConditionalAsThoughEffect extends AsThoughEffectImpl {
public class ConditionalAsThoughEffect extends AsThoughEffectImpl {
protected AsThoughEffect effect;
protected AsThoughEffect otherwiseEffect;
@ -59,9 +59,9 @@ public class ConditionalAsThoughEffect extends AsThoughEffectImpl {
public ConditionalAsThoughEffect(final ConditionalAsThoughEffect effect) {
super(effect);
this.effect = (AsThoughEffect) effect.effect.copy();
this.effect = effect.effect.copy();
if (effect.otherwiseEffect != null) {
this.otherwiseEffect = (AsThoughEffect) effect.otherwiseEffect.copy();
this.otherwiseEffect = effect.otherwiseEffect.copy();
}
this.condition = effect.condition;
this.conditionState = effect.conditionState;

View file

@ -28,6 +28,7 @@
package mage.abilities.effects;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
@ -55,10 +56,10 @@ import mage.target.common.TargetCardInGraveyard;
* was not cast (so from Zone != Hand), this effect gets the target to whitch to
* attach it and adds the Aura the the battlefield and attachs it to the target.
* The "attachTo:" value in game state has to be set therefore.
*
* <p>
* If no "attachTo:" value is defined, the controlling player has to chose the
* aura target.
*
* <p>
* This effect is automatically added to ContinuousEffects at the start of a
* game
*
@ -204,15 +205,15 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (((ZoneChangeEvent) event).getToZone().equals(Zone.BATTLEFIELD)
&& !(((ZoneChangeEvent) event).getFromZone().equals(Zone.STACK))) {
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
&& (((ZoneChangeEvent) event).getFromZone() != Zone.STACK)) {
Card card = game.getCard(event.getTargetId());
if (card != null && (card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura", game)
|| // in case of transformable enchantments
(game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null
&& card.getSecondCardFace() != null
&& card.getSecondCardFace().getCardType().contains(CardType.ENCHANTMENT)
&& card.getSecondCardFace().hasSubtype("Aura", game)))) {
&& card.getSecondCardFace() != null
&& card.getSecondCardFace().getCardType().contains(CardType.ENCHANTMENT)
&& card.getSecondCardFace().hasSubtype("Aura", game)))) {
return true;
}
}

View file

@ -33,6 +33,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.MageSingleton;
@ -51,7 +53,6 @@ import mage.game.Game;
import mage.players.Player;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public abstract class ContinuousEffectImpl extends EffectImpl implements ContinuousEffect {
@ -171,9 +172,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
public void init(Ability source, Game game) {
targetPointer.init(game, source);
//20100716 - 611.2c
if (AbilityType.ACTIVATED.equals(source.getAbilityType())
|| AbilityType.SPELL.equals(source.getAbilityType())
|| AbilityType.TRIGGERED.equals(source.getAbilityType())) {
if (AbilityType.ACTIVATED == source.getAbilityType()
|| AbilityType.SPELL == source.getAbilityType()
|| AbilityType.TRIGGERED == source.getAbilityType()) {
if (layer != null) {
switch (layer) {
case CopyEffects_1:
@ -197,7 +198,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
@Override
public boolean isInactive(Ability source, Game game) {
if (duration.equals(Duration.UntilYourNextTurn)) {
if (duration == Duration.UntilYourNextTurn) {
Player player = game.getPlayer(startingControllerId);
if (player != null) {
if (player.isInGame()) {
@ -271,19 +272,13 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
@Override
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
if (dependendToType != null) {
// the dependent classes needs to be an enclosed class for dependent check of continuous effects
Set<UUID> dependentTo = null;
for (ContinuousEffect effect : allEffectsInLayer) {
if (effect.getDependencyTypes().contains(dependendToType)) {
if (dependentTo == null) {
dependentTo = new HashSet<>();
}
dependentTo.add(effect.getId());
}
}
return dependentTo;
return allEffectsInLayer.stream()
.filter(effect -> effect.getDependencyTypes().contains(dependendToType))
.map(Effect::getId)
.collect(Collectors.toSet());
}
return null;
return new HashSet<>();
}
@Override

View file

@ -27,40 +27,12 @@
*/
package mage.abilities.effects;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.MageSingleton;
import mage.abilities.SpellAbility;
import mage.abilities.StaticAbility;
import mage.abilities.*;
import mage.abilities.keyword.SpliceOntoArcaneAbility;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.AbilityType;
import mage.constants.AsThoughEffectType;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.Layer;
import mage.constants.ManaType;
import mage.constants.Outcome;
import mage.constants.SpellAbilityType;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
@ -77,8 +49,11 @@ import mage.players.Player;
import mage.target.common.TargetCardInHand;
import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class ContinuousEffects implements Serializable {
@ -218,7 +193,7 @@ public class ContinuousEffects implements Serializable {
case WhileOnStack:
case WhileInGraveyard:
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
if (abilities != null) {
if (!abilities.isEmpty()) {
for (Ability ability : abilities) {
// If e.g. triggerd abilities (non static) created the effect, the ability must not be in usable zone (e.g. Unearth giving Haste effect)
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
@ -358,7 +333,6 @@ public class ContinuousEffects implements Serializable {
}
/**
*
* @param event
* @param game
* @return a list of all {@link ReplacementEffect} that apply to the current
@ -717,7 +691,8 @@ public class ContinuousEffects implements Serializable {
spliceAbilities.remove(selectedAbility);
}
}
} while (!spliceAbilities.isEmpty() && controller.chooseUse(Outcome.Benefit, "Splice another card?", abilityToModify, game));
}
while (!spliceAbilities.isEmpty() && controller.chooseUse(Outcome.Benefit, "Splice another card?", abilityToModify, game));
controller.revealCards("Spliced cards", cardsToReveal, game);
}
}
@ -727,10 +702,10 @@ public class ContinuousEffects implements Serializable {
* Checks if an event won't happen because of an rule modifying effect
*
* @param event
* @param targetAbility ability the event is attached to. can be null.
* @param targetAbility ability the event is attached to. can be null.
* @param game
* @param checkPlayableMode true if the event does not really happen but
* it's checked if the event would be replaced
* it's checked if the event would be replaced
* @return
*/
public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean checkPlayableMode) {
@ -777,7 +752,7 @@ public class ContinuousEffects implements Serializable {
do {
HashMap<ReplacementEffect, HashSet<Ability>> rEffects = getApplicableReplacementEffects(event, game);
// Remove all consumed effects (ability dependant)
for (Iterator<ReplacementEffect> it1 = rEffects.keySet().iterator(); it1.hasNext();) {
for (Iterator<ReplacementEffect> it1 = rEffects.keySet().iterator(); it1.hasNext(); ) {
ReplacementEffect entry = it1.next();
if (consumed.containsKey(entry.getId())) {
HashSet<UUID> consumedAbilitiesIds = consumed.get(entry.getId());
@ -865,9 +840,8 @@ public class ContinuousEffects implements Serializable {
if (consumed.containsKey(rEffect.getId())) {
HashSet<UUID> set = consumed.get(rEffect.getId());
if (rAbility != null) {
if (!set.contains(rAbility.getId())) {
set.add(rAbility.getId());
}
set.add(rAbility.getId());
}
} else {
HashSet<UUID> set = new HashSet<>();
@ -936,7 +910,7 @@ public class ContinuousEffects implements Serializable {
for (ContinuousEffect effect : layer) {
if (activeLayerEffects.contains(effect) && !appliedEffects.contains(effect.getId())) { // Effect does still exist and was not applied yet
Set<UUID> dependentTo = effect.isDependentTo(layer);
if (dependentTo != null && !appliedEffects.containsAll(dependentTo)) {
if (!appliedEffects.containsAll(dependentTo)) {
waitingEffects.put(effect, dependentTo);
continue;
}
@ -959,7 +933,7 @@ public class ContinuousEffects implements Serializable {
if (!waitingEffects.isEmpty()) {
// check if waiting effects can be applied now
for (Iterator<Map.Entry<ContinuousEffect, Set<UUID>>> iterator = waitingEffects.entrySet().iterator(); iterator.hasNext();) {
for (Iterator<Map.Entry<ContinuousEffect, Set<UUID>>> iterator = waitingEffects.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<ContinuousEffect, Set<UUID>> entry = iterator.next();
if (appliedEffects.containsAll(entry.getValue())) { // all dependent to effects are applied now so apply the effect itself
appliedAbilities = appliedEffectAbilities.get(entry.getKey());
@ -1039,7 +1013,7 @@ public class ContinuousEffects implements Serializable {
for (ContinuousEffect effect : layer) {
if (numberOfEffects > 1) { // If an effect is dependent to not applied effects yet of this layer, so wait to apply this effect
Set<UUID> dependentTo = effect.isDependentTo(layer);
if (dependentTo != null && !appliedEffects.containsAll(dependentTo)) {
if (!appliedEffects.containsAll(dependentTo)) {
waitingEffects.put(effect, dependentTo);
continue;
}
@ -1162,17 +1136,16 @@ public class ContinuousEffects implements Serializable {
private void setControllerForEffect(ContinuousEffectsList<?> effects, UUID sourceId, UUID controllerId) {
for (Effect effect : effects) {
HashSet<Ability> abilities = effects.getAbility(effect.getId());
if (abilities != null) {
for (Ability ability : abilities) {
if (ability.getSourceId() != null) {
if (ability.getSourceId().equals(sourceId)) {
ability.setControllerId(controllerId);
}
} else if (!ability.getZone().equals(Zone.COMMAND)) {
logger.fatal("Continuous effect for ability with no sourceId Ability: " + ability);
for (Ability ability : abilities) {
if (ability.getSourceId() != null) {
if (ability.getSourceId().equals(sourceId)) {
ability.setControllerId(controllerId);
}
} else if (ability.getZone() != Zone.COMMAND) {
logger.fatal("Continuous effect for ability with no sourceId Ability: " + ability);
}
}
}
}

View file

@ -34,6 +34,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.MageSingleton;
import mage.constants.Duration;
@ -41,9 +42,8 @@ import mage.game.Game;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
* @author BetaSteward_at_googlemail.com
*/
public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList<T> {
@ -74,7 +74,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
}
public void removeEndOfTurnEffects() {
for (Iterator<T> i = this.iterator(); i.hasNext();) {
for (Iterator<T> i = this.iterator(); i.hasNext(); ) {
T entry = i.next();
if (entry.getDuration() == Duration.EndOfTurn) {
i.remove();
@ -84,7 +84,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
}
public void removeEndOfCombatEffects() {
for (Iterator<T> i = this.iterator(); i.hasNext();) {
for (Iterator<T> i = this.iterator(); i.hasNext(); ) {
T entry = i.next();
if (entry.getDuration() == Duration.EndOfCombat) {
i.remove();
@ -94,7 +94,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
}
public void removeInactiveEffects(Game game) {
for (Iterator<T> i = this.iterator(); i.hasNext();) {
for (Iterator<T> i = this.iterator(); i.hasNext(); ) {
T entry = i.next();
if (isInactive(entry, game)) {
i.remove();
@ -169,7 +169,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
}
public HashSet<Ability> getAbility(UUID effectId) {
return effectAbilityMap.get(effectId);
return effectAbilityMap.getOrDefault(effectId, new HashSet<>());
}
public void removeEffects(UUID effectIdToRemove, Set<Ability> abilitiesToRemove) {
@ -178,7 +178,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
abilities.removeAll(abilitiesToRemove);
}
if (abilities == null || abilities.isEmpty()) {
for (Iterator<T> iterator = this.iterator(); iterator.hasNext();) {
for (Iterator<T> iterator = this.iterator(); iterator.hasNext(); ) {
ContinuousEffect effect = iterator.next();
if (effect.getId().equals(effectIdToRemove)) {
iterator.remove();

View file

@ -97,13 +97,13 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl {
public boolean checksEventType(GameEvent event, Game game) {
switch (enterEventType) {
case OTHER:
return EventType.ENTERS_THE_BATTLEFIELD.equals(event.getType());
return EventType.ENTERS_THE_BATTLEFIELD == event.getType();
case SELF:
return EventType.ENTERS_THE_BATTLEFIELD_SELF.equals(event.getType());
return EventType.ENTERS_THE_BATTLEFIELD_SELF == event.getType();
case CONTROL:
return EventType.ENTERS_THE_BATTLEFIELD_CONTROL.equals(event.getType());
return EventType.ENTERS_THE_BATTLEFIELD_CONTROL == event.getType();
case COPY:
return EventType.ENTERS_THE_BATTLEFIELD_COPY.equals(event.getType());
return EventType.ENTERS_THE_BATTLEFIELD_COPY == event.getType();
}
return false;
}

View file

@ -44,7 +44,7 @@ import mage.players.Player;
*/
public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectImpl implements PayCostToAttackBlockEffect {
public static enum RestrictType {
public enum RestrictType {
ATTACK("attack"),
ATTACK_AND_BLOCK("attack or block"),
@ -111,7 +111,7 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
case BLOCK:
return event.getType().equals(GameEvent.EventType.DECLARE_BLOCKER);
case ATTACK_AND_BLOCK:
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER || event.getType().equals(GameEvent.EventType.DECLARE_BLOCKER);
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER || event.getType() == EventType.DECLARE_BLOCKER;
}
return false;
}

View file

@ -61,8 +61,8 @@ public class AddCombatAndMainPhaseEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
// 15.07.2006 If it's somehow not a main phase when Fury of the Horde resolves, all it does is untap all creatures that attacked that turn. No new phases are created.
if (TurnPhase.PRECOMBAT_MAIN.equals(game.getTurn().getPhaseType())
|| TurnPhase.POSTCOMBAT_MAIN.equals(game.getTurn().getPhaseType())) {
if (game.getTurn().getPhaseType() == TurnPhase.PRECOMBAT_MAIN
|| game.getTurn().getPhaseType() == TurnPhase.POSTCOMBAT_MAIN) {
// we can't add two turn modes at once, will add additional post combat on delayed trigger resolution
TurnMod combat = new TurnMod(source.getControllerId(), TurnPhase.COMBAT, TurnPhase.POSTCOMBAT_MAIN, false);
game.getState().getTurnMods().add(combat);

View file

@ -114,7 +114,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
public boolean applies(GameEvent event, Ability source, Game game) {
// the check if a permanent untap pahse is already handled is needed if multiple effects are added to prevent untap in next untap step of controller
// if we don't check it for every untap step of a turn only one effect would be consumed instead of all be valid for the next untap step
if (GameEvent.EventType.UNTAP_STEP.equals(event.getType())) {
if (event.getType() == EventType.UNTAP_STEP) {
boolean allHandled = true;
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);

View file

@ -56,7 +56,7 @@ public class DontUntapInControllersUntapStepEnchantedEffect extends ContinuousRu
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (PhaseStep.UNTAP.equals(game.getTurn().getStepType())) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) {
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());

View file

@ -81,7 +81,7 @@ public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleM
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (PhaseStep.UNTAP.equals(game.getTurn().getStepType())) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
for (UUID targetId : targetPointer.getTargets(game, source)) {
if (event.getTargetId().equals(targetId)) {
Permanent permanent = game.getPermanent(targetId);

View file

@ -107,7 +107,7 @@ public class DontUntapInOpponentsNextUntapStepAllEffect extends ContinuousRuleMo
return false;
}
// remember the turn of the untap step the effect has to be applied
if (GameEvent.EventType.UNTAP_STEP.equals(event.getType())) {
if (event.getType() == EventType.UNTAP_STEP) {
if (game.getActivePlayerId().equals(getTargetPointer().getFirst(game, source))) {
if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step
discard();

View file

@ -190,7 +190,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Cards pickedCards = new CardsImpl(target.getTargets());
cards.removeAll(pickedCards);
if (targetPickedCards.equals(Zone.LIBRARY) && !putOnTopSelected) {
if (targetPickedCards == Zone.LIBRARY && !putOnTopSelected) {
player.putCardsOnBottomOfLibrary(pickedCards, game, source, true);
} else {
player.moveCards(pickedCards.getCards(game), targetPickedCards, source, game);

View file

@ -44,7 +44,7 @@ public class AttacksIfAbleAttachedEffect extends RequirementEffect {
public AttacksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) {
super(duration);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature attacks each turn if able";
} else {
this.staticText = "Equipped creature attacks each turn if able";

View file

@ -51,7 +51,7 @@ public class BlocksIfAbleAllEffect extends RequirementEffect {
super(duration);
staticText = new StringBuilder(filter.getMessage())
.append(" block ")
.append(duration.equals(Duration.EndOfTurn) ? "this":"each")
.append(duration == Duration.EndOfTurn ? "this":"each")
.append(" turn if able").toString();
this.filter = filter;
}

View file

@ -44,7 +44,7 @@ public class BlocksIfAbleAttachedEffect extends RequirementEffect {
public BlocksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) {
super(duration);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature blocks each turn if able";
} else {
this.staticText = "Equipped creature blocks each turn if able";

View file

@ -27,7 +27,6 @@
*/
package mage.abilities.effects.common.combat;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.constants.AsThoughEffectType;
@ -38,18 +37,19 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author Quercitron
*/
public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffectImpl {
private final FilterPermanent filter;
public CanAttackAsThoughItDidntHaveDefenderAllEffect(Duration duration) {
this(duration, new FilterCreaturePermanent());
}
public CanAttackAsThoughItDidntHaveDefenderAllEffect(Duration duration, FilterPermanent filter) {
super(AsThoughEffectType.ATTACK, duration, Outcome.Benefit);
this.filter = filter;
@ -76,12 +76,12 @@ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffec
Permanent permanent = game.getPermanent(objectId);
return permanent != null && filter.match(permanent, game);
}
private String getText() {
StringBuilder sb = new StringBuilder(filter.getMessage());
sb.append(" can attack ");
if (!duration.toString().isEmpty()) {
if(Duration.EndOfTurn.equals(duration)) {
if (!duration.toString().isEmpty()) {
if (Duration.EndOfTurn == duration) {
sb.append("this turn");
} else {
sb.append(duration.toString());
@ -89,6 +89,6 @@ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffec
sb.append(' ');
}
sb.append("as though they didn't have defender");
return sb.toString();
return sb.toString();
}
}

View file

@ -44,7 +44,7 @@ public class CanAttackAsThoughItDidntHaveDefenderSourceEffect extends AsThoughEf
public CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration duration) {
super(AsThoughEffectType.ATTACK, duration, Outcome.Benefit);
staticText = "{this} can attack "
+ (duration.equals(Duration.EndOfTurn) ? "this turn " : "")
+ (duration == Duration.EndOfTurn ? "this turn " : "")
+ "as though it didn't have defender";
}

View file

@ -45,7 +45,7 @@ public class CanBlockOnlyFlyingAttachedEffect extends RestrictionEffect {
public CanBlockOnlyFlyingAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature can block only creatures with flying";
} else {
this.staticText = "Equipped creature can block only creatures with flying";

View file

@ -20,7 +20,7 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect {
public CantAttackAloneAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature can't attack alone";
} else {
this.staticText = "Equipped creature can't attack alone";

View file

@ -44,7 +44,7 @@ public class CantAttackAttachedEffect extends RestrictionEffect {
public CantAttackAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature can't attack";
} else {
this.staticText = "Equipped creature can't attack";

View file

@ -48,7 +48,7 @@ public class CantAttackBlockAllEffect extends RestrictionEffect {
StringBuilder sb = new StringBuilder(filter.getMessage()).append(" can't attack or block");
if (!duration.toString().isEmpty()) {
sb.append(' ');
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
sb.append(" this turn");
} else {
sb.append(' ').append(duration.toString());

View file

@ -42,7 +42,7 @@ public class CantAttackBlockAttachedEffect extends RestrictionEffect {
public CantAttackBlockAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature can't attack or block";
} else {
this.staticText = "Equipped creature can't attack or block";

View file

@ -46,7 +46,7 @@ public class CantAttackBlockUnlessPaysAttachedEffect extends PayCostToAttackBloc
public CantAttackBlockUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK_AND_BLOCK, manaCosts);
staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted " : "Equipped ")
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ")
+ "creature can't attack or block unless its controller pays "
+ (manaCosts == null ? "" : manaCosts.getText());
}
@ -59,10 +59,10 @@ public class CantAttackBlockUnlessPaysAttachedEffect extends PayCostToAttackBloc
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (event.getType().equals(EventType.DECLARE_ATTACKER)) {
if (event.getType() == EventType.DECLARE_ATTACKER) {
return event.getSourceId().equals(enchantment.getAttachedTo());
}
if (event.getType().equals(EventType.DECLARE_BLOCKER)) {
if (event.getType() == EventType.DECLARE_BLOCKER) {
return event.getSourceId().equals(enchantment.getAttachedTo());
}
}

View file

@ -47,7 +47,7 @@ public class CantAttackBlockUnlessPaysSourceEffect extends PayCostToAttackBlockE
super(Duration.WhileOnBattlefield, Outcome.Detriment, restrictType, cost);
staticText = "{this} can't " + restrictType.toString() + " unless you "
+ cost == null ? "" : cost.getText()
+ (restrictType.equals(RestrictType.ATTACK) ? " <i>(This cost is paid as attackers are declared.)</i>" : "");
+ (restrictType == RestrictType.ATTACK ? " <i>(This cost is paid as attackers are declared.)</i>" : "");
}
public CantAttackBlockUnlessPaysSourceEffect(ManaCosts manaCosts, RestrictType restrictType) {
@ -62,10 +62,10 @@ public class CantAttackBlockUnlessPaysSourceEffect extends PayCostToAttackBlockE
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!restrictType.equals(RestrictType.BLOCK) && event.getType().equals(EventType.DECLARE_ATTACKER)) {
if (!(restrictType == RestrictType.BLOCK) && event.getType() == EventType.DECLARE_ATTACKER) {
return event.getSourceId().equals(source.getSourceId());
}
if (!restrictType.equals(RestrictType.ATTACK) && event.getType().equals(EventType.DECLARE_BLOCKER)) {
if (!(restrictType == RestrictType.ATTACK) && event.getType() == EventType.DECLARE_BLOCKER) {
return event.getSourceId().equals(source.getSourceId());
}
return false;

View file

@ -46,7 +46,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect {
public CantAttackControllerAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature can't attack you or a planeswalker you control";
} else {
this.staticText = "Equipped creature can't attack you or a planeswalker you control";

View file

@ -46,7 +46,7 @@ public class CantAttackUnlessPaysAttachedEffect extends PayCostToAttackBlockEffe
public CantAttackUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK, manaCosts);
staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted " : "Equipped ")
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ")
+ "creature can't attack unless its controller pays "
+ (manaCosts == null ? "" : manaCosts.getText());
}
@ -59,7 +59,7 @@ public class CantAttackUnlessPaysAttachedEffect extends PayCostToAttackBlockEffe
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (event.getType().equals(EventType.DECLARE_ATTACKER)) {
if (event.getType() == EventType.DECLARE_ATTACKER) {
return event.getSourceId().equals(enchantment.getAttachedTo());
}
}

View file

@ -59,7 +59,7 @@ public class CantAttackYouAllEffect extends RestrictionEffect {
this.alsoPlaneswalker = alsoPlaneswalker;
staticText = filterAttacker.getMessage() + " can't attack you"
+ (alsoPlaneswalker ? " or a planeswalker you control" : "")
+ (duration.equals(Duration.UntilYourNextTurn) ? " until your next turn" : "");
+ (duration == Duration.UntilYourNextTurn ? " until your next turn" : "");
}
CantAttackYouAllEffect(final CantAttackYouAllEffect effect) {

View file

@ -47,7 +47,7 @@ public class CantBeBlockedAllEffect extends RestrictionEffect {
this.filter = filter;
this.staticText = filter.getMessage() + " can't be blocked";
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
this.staticText += " this turn";
}
}

View file

@ -42,7 +42,7 @@ public class CantBeBlockedAttachedEffect extends RestrictionEffect {
public CantBeBlockedAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield);
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
this.staticText = "Enchanted creature can't be blocked";
} else {
this.staticText = "Equipped creature can't be blocked";

View file

@ -47,7 +47,7 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect {
super(duration);
this.filter = filter;
StringBuilder sb = new StringBuilder();
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
sb.append("Enchanted ");
} else {
sb.append("Equipped ");

View file

@ -56,7 +56,7 @@ public class CantBeBlockedByOneAllEffect extends ContinuousEffectImpl {
this.amount = amount;
this.filter = filter;
StringBuilder sb = new StringBuilder("each ").append(filter.getMessage()).append(" can't be blocked ");
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
sb.append("this turn ");
}
sb.append("except by ").append(CardUtil.numberToText(amount)).append(" or more creatures");

View file

@ -54,7 +54,7 @@ public class CantBeBlockedByOneAttachedEffect extends ContinuousEffectImpl {
super(duration, Outcome.Benefit);
this.amount = amount;
this.attachmentType = attachmentType;
staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted" : "Equipped") + " creature can't be blocked except by " + amount + " or more creatures";
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted" : "Equipped") + " creature can't be blocked except by " + amount + " or more creatures";
}
public CantBeBlockedByOneAttachedEffect(final CantBeBlockedByOneAttachedEffect effect) {

View file

@ -93,7 +93,7 @@ public class CantBeBlockedByTargetSourceEffect extends RestrictionEffect {
sb.append("Target ");
}
sb.append(target.getTargetName()).append(" can't block {this}");
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
sb.append(" this turn");
}

View file

@ -45,7 +45,7 @@ public class CantBeBlockedSourceEffect extends RestrictionEffect {
public CantBeBlockedSourceEffect(Duration duration) {
super(duration);
this.staticText = "{this} can't be blocked";
if (Duration.EndOfTurn.equals(this.duration)) {
if (this.duration == Duration.EndOfTurn) {
this.staticText += " this turn";
}
}

View file

@ -72,7 +72,7 @@ public class CantBlockAllEffect extends RestrictionEffect {
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append(filter.getMessage()).append(" can't block");
if (Duration.EndOfTurn.equals(this.duration)) {
if (this.duration == Duration.EndOfTurn) {
sb.append(" this turn");
}
return sb.toString();

View file

@ -56,7 +56,7 @@ public class CantBlockAttachedEffect extends RestrictionEffect {
super(duration);
this.filter = filter;
StringBuilder sb = new StringBuilder();
if (attachmentType.equals(AttachmentType.AURA)) {
if (attachmentType == AttachmentType.AURA) {
sb.append("Enchanted creature can't block");
} else {
sb.append("Equipped creature can't block");

View file

@ -43,7 +43,7 @@ public class CantBlockSourceEffect extends RestrictionEffect {
public CantBlockSourceEffect(Duration duration) {
super(duration);
this.staticText = "{this} can't block";
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
this.staticText += " this turn";
}
}

View file

@ -89,7 +89,7 @@ public class CantBlockTargetEffect extends RestrictionEffect {
}
sb.append(" can't block");
if (Duration.EndOfTurn.equals(this.duration)) {
if (this.duration == Duration.EndOfTurn) {
sb.append(" this turn");
}

View file

@ -46,7 +46,7 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect {
public MustBeBlockedByAllTargetEffect(Duration duration) {
super(duration);
staticText = new StringBuilder("All creatures able to block target creature ")
.append(this.getDuration().equals(Duration.EndOfTurn) ? "this turn ":"")
.append(this.getDuration() == Duration.EndOfTurn ? "this turn ":"")
.append("do so").toString();
}
@ -58,7 +58,7 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect {
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent attackingCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (attackingCreature != null && attackingCreature.isAttacking()) {
if (!source.getAbilityType().equals(AbilityType.STATIC)) {
if (source.getAbilityType() != AbilityType.STATIC) {
BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher");
if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attackingCreature, permanent, game)) {
// has already blocked this turn, so no need to do again

View file

@ -62,7 +62,7 @@ public class AddCardSubTypeTargetEffect extends ContinuousEffectImpl {
target.getSubtype(game).add(addedSubType);
}
} else {
if (Duration.Custom.equals(duration)) {
if (duration == Duration.Custom) {
discard();
}
}

View file

@ -49,7 +49,7 @@ public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
public AddCardTypeSourceEffect(CardType addedCardType, Duration duration) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.addedCardType = addedCardType;
if (addedCardType.equals(CardType.ENCHANTMENT)) {
if (addedCardType == CardType.ENCHANTMENT) {
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
}
}

View file

@ -50,9 +50,9 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
public AddCardTypeTargetEffect(CardType addedCardType, Duration duration) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.addedCardType = addedCardType;
if (addedCardType.equals(CardType.ENCHANTMENT)) {
if (addedCardType == CardType.ENCHANTMENT) {
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
} else if (addedCardType.equals(CardType.ARTIFACT)) {
} else if (addedCardType == CardType.ARTIFACT) {
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
}
}
@ -75,7 +75,7 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
}
}
if (!result) {
if (this.getDuration().equals(Duration.Custom)) {
if (this.getDuration() == Duration.Custom) {
this.discard();
}
}

View file

@ -130,7 +130,7 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
sb.append(" can't gain life");
if (!this.duration.toString().isEmpty()) {
sb.append(' ');
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
sb.append("this turn");
} else {
sb.append(duration.toString());

View file

@ -48,7 +48,7 @@ public class CantGainLifeTargetEffect extends ContinuousEffectImpl {
super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit);
StringBuilder sb = new StringBuilder("If that player would gain life");
if (!this.duration.toString().isEmpty()) {
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
sb.append("this turn, ");
} else {
sb.append(' ').append(duration.toString());

View file

@ -94,7 +94,7 @@ public class CastAsThoughItHadFlashAllEffect extends AsThoughEffectImpl {
sb.append(" may cast ");
sb.append(filter.getMessage());
if (!duration.toString().isEmpty()) {
if (duration.equals(Duration.EndOfTurn)) {
if (duration == Duration.EndOfTurn) {
sb.append(" this turn");
} else {
sb.append(' ');

View file

@ -29,7 +29,7 @@ public class DamageCantBePreventedEffect extends ContinuousRuleModifyingEffectIm
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType().equals(GameEvent.EventType.PREVENT_DAMAGE);
return event.getType() == GameEvent.EventType.PREVENT_DAMAGE;
}
@Override

View file

@ -46,7 +46,7 @@ import mage.util.CardUtil;
*/
public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
public static enum HandSizeModification {
public enum HandSizeModification {
SET, INCREASE, REDUCE
}
@ -90,8 +90,8 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
protected static Outcome defineOutcome(HandSizeModification handSizeModification, TargetController targetController) {
Outcome newOutcome = Outcome.Benefit;
if ((targetController.equals(TargetController.YOU) || targetController.equals(TargetController.ANY))
&& handSizeModification.equals(HandSizeModification.REDUCE)) {
if ((targetController == TargetController.YOU || targetController == TargetController.ANY)
&& handSizeModification == HandSizeModification.REDUCE) {
newOutcome = Outcome.Detriment;
}
return newOutcome;

View file

@ -38,7 +38,6 @@ import mage.game.Game;
import mage.players.Player;
/**
*
* @author Viserion
*/
public class PlayAdditionalLandsControllerEffect extends ContinuousEffectImpl {
@ -65,10 +64,9 @@ public class PlayAdditionalLandsControllerEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if(player.getLandsPerTurn() == Integer.MAX_VALUE || this.additionalCards == Integer.MAX_VALUE){
if (player.getLandsPerTurn() == Integer.MAX_VALUE || this.additionalCards == Integer.MAX_VALUE) {
player.setLandsPerTurn(Integer.MAX_VALUE);
}
else{
} else {
player.setLandsPerTurn(player.getLandsPerTurn() + this.additionalCards);
}
return true;
@ -79,15 +77,13 @@ public class PlayAdditionalLandsControllerEffect extends ContinuousEffectImpl {
private void setText() {
StringBuilder sb = new StringBuilder();
sb.append("You may play ");
if(additionalCards == Integer.MAX_VALUE){
if (additionalCards == Integer.MAX_VALUE) {
sb.append("any number of");
} else {
sb.append(Integer.toString(additionalCards));
}
else
{
sb.append(Integer.toString(additionalCards));
}
sb.append(" additional land").append((additionalCards == 1 ? "" : "s"))
.append(duration == Duration.EndOfTurn ? " this turn" : " on each of your turns");
sb.append(" additional land").append((additionalCards == 1 ? "" : "s"))
.append(duration == Duration.EndOfTurn ? " this turn" : " on each of your turns");
staticText = sb.toString();
}

View file

@ -71,7 +71,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl {
affectedPlayers = game.getOpponents(source.getControllerId());
break;
case YOU:
ArrayList tmp = new ArrayList<>();
ArrayList<UUID> tmp = new ArrayList<>();
tmp.add(source.getControllerId());
affectedPlayers = tmp;
break;

View file

@ -85,7 +85,7 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (mageObject == null) {
if (duration.equals(Duration.Custom) || isTemporary()) {
if (duration == Duration.Custom || isTemporary()) {
mageObject = game.getPermanent(source.getSourceId());
} else {
mageObject = game.getObject(source.getSourceId());

View file

@ -37,7 +37,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class SwitchPowerToughnessSourceEffect extends ContinuousEffectImpl {
@ -58,7 +57,7 @@ public class SwitchPowerToughnessSourceEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent target = (Permanent) game.getPermanent(source.getSourceId());
Permanent target = game.getPermanent(source.getSourceId());
if (target != null) {
int power = target.getPower().getValue();
target.getPower().setValue(target.getToughness().getValue());
@ -68,4 +67,4 @@ public class SwitchPowerToughnessSourceEffect extends ContinuousEffectImpl {
return false;
}
}
}

View file

@ -39,7 +39,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author ayratn
*/
public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl {
@ -59,7 +58,7 @@ public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent target = (Permanent) game.getPermanent(source.getFirstTarget());
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
int power = target.getPower().getValue();
target.getPower().setValue(target.getToughness().getValue());
@ -73,7 +72,7 @@ public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl {
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append("Switch target ").append(mode.getTargets().get(0).getTargetName()).append("'s power and toughness")
.append(' ').append(duration.toString());
.append(' ').append(duration.toString());
return sb.toString();
}

View file

@ -69,7 +69,7 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff
if (applied == null) {
applied = Boolean.FALSE;
}
if (!applied && layer.equals(Layer.RulesEffects)) {
if (!applied && layer == Layer.RulesEffects) {
if (!source.getControllerId().equals(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) {
game.getState().setValue(source.getSourceId() + "applied", true);
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {

View file

@ -64,7 +64,7 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous
if (applied == null) {
applied = Boolean.FALSE;
}
if (!applied && layer.equals(Layer.RulesEffects)) {
if (!applied && layer == Layer.RulesEffects) {
if (!source.getControllerId().equals(game.getActivePlayerId())
&& game.getStep() != null
&& game.getStep().getType() == PhaseStep.UNTAP) {
@ -80,7 +80,7 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous
}
}
}
} else if (applied && layer.equals(Layer.RulesEffects)) {
} else if (applied && layer == Layer.RulesEffects) {
if (game.getStep() != null && game.getStep().getType() == PhaseStep.END_TURN) {
game.getState().setValue(source.getSourceId() + "applied", false);
}

View file

@ -71,8 +71,7 @@ public class ProliferateEffect extends OneShotEffect {
options.put("UI.right.btn.text", "Done");
controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options);
for (int idx = 0; idx < target.getTargets().size(); idx++) {
UUID chosen = (UUID) target.getTargets().get(idx);
for (UUID chosen : target.getTargets()) {
Permanent permanent = game.getPermanent(chosen);
if (permanent != null) {
if (!permanent.getCounters(game).isEmpty()) {

View file

@ -16,7 +16,6 @@ import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author LevelX2
*/
public class CastOnlyDuringPhaseStepSourceEffect extends ContinuousRuleModifyingEffectImpl {
@ -49,8 +48,8 @@ public class CastOnlyDuringPhaseStepSourceEffect extends ContinuousRuleModifying
public boolean applies(GameEvent event, Ability source, Game game) {
// has to return true, if the spell cannot be cast in the current phase / step
if (event.getSourceId().equals(source.getSourceId())) {
if ((turnPhase != null && !game.getPhase().getType().equals(turnPhase))
|| (phaseStep != null && !game.getTurn().getStepType().equals(phaseStep))
if ((turnPhase != null && game.getPhase().getType() != turnPhase)
|| (phaseStep != null && (game.getTurn().getStepType() != phaseStep))
|| (condition != null && !condition.apply(game, source))) {
return true;
}

View file

@ -1,5 +1,7 @@
package mage.constants;
import mage.game.turn.Phase;
/**
*
* @author North
@ -33,6 +35,14 @@ public enum PhaseStep {
this.stepText = stepText;
}
public boolean isBefore(PhaseStep other){
return this.getIndex()<other.getIndex();
}
public boolean isAfter(PhaseStep other){
return this.getIndex()>other.getIndex();
}
public int getIndex() {
return index;
}