forked from External/mage
changed enum comparison to ==.
isDependentTo returns empty set rather than null
This commit is contained in:
parent
297203dab5
commit
972ed6a3f2
61 changed files with 159 additions and 195 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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(' ');
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue