cleanup to use ObjectColor.COLORLESS (#10447)

* Replace for BecomesColorSourceEffect

* Replace for BecomesColorTargetEffect

* Remove unused class

* Use common static instance
This commit is contained in:
xenohedron 2023-06-11 23:36:01 -04:00 committed by GitHub
parent 7b2f6b3d46
commit 2cdfb255cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 23 additions and 183 deletions

View file

@ -27,7 +27,7 @@ public final class AncientKavu extends CardImpl {
this.toughness = new MageInt(3);
// {2}: Ancient Kavu becomes colorless until end of turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorSourceEffect(new ObjectColor(), Duration.EndOfTurn), new ManaCostsImpl<>("{2}")));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorSourceEffect(ObjectColor.COLORLESS, Duration.EndOfTurn), new ManaCostsImpl<>("{2}")));
}
private AncientKavu(final AncientKavu card) {

View file

@ -31,7 +31,7 @@ public final class BlazingBladeAskari extends CardImpl {
// Flanking
this.addAbility(new FlankingAbility());
// {2}: Blazing Blade Askari becomes colorless until end of turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorSourceEffect(new ObjectColor(), Duration.EndOfTurn), new ManaCostsImpl<>("{2}")));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorSourceEffect(ObjectColor.COLORLESS, Duration.EndOfTurn), new ManaCostsImpl<>("{2}")));
}
private BlazingBladeAskari(final BlazingBladeAskari card) {

View file

@ -30,12 +30,12 @@ public final class ErsatzGnomes extends CardImpl {
this.toughness = new MageInt(1);
// {T}: Target spell becomes colorless.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorTargetEffect(new ObjectColor(), Duration.Custom), new TapSourceCost());
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorTargetEffect(ObjectColor.COLORLESS, Duration.Custom), new TapSourceCost());
ability.addTarget(new TargetSpell());
this.addAbility(ability);
// {T}: Target permanent becomes colorless until end of turn.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorTargetEffect(new ObjectColor(), Duration.EndOfTurn), new TapSourceCost());
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorTargetEffect(ObjectColor.COLORLESS, Duration.EndOfTurn), new TapSourceCost());
ability.addTarget(new TargetPermanent());
this.addAbility(ability);
}

View file

@ -44,8 +44,6 @@ class GhostflameSliverEffect extends ContinuousEffectImpl {
private static final FilterPermanent filter = new FilterPermanent(SubType.SLIVER, "All Slivers");
private static ObjectColor colorless = new ObjectColor();
public GhostflameSliverEffect() {
super(Duration.WhileOnBattlefield, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit);
staticText = "All Slivers are colorless";
@ -55,7 +53,7 @@ class GhostflameSliverEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (filter.match(perm, game)) {
perm.getColor(game).setColor(colorless);
perm.getColor(game).setColor(ObjectColor.COLORLESS);
}
}
return true;

View file

@ -21,7 +21,7 @@ public final class Moonlace extends CardImpl {
// Target spell or permanent becomes colorless.
this.getSpellAbility().addTarget(new TargetSpellOrPermanent());
this.getSpellAbility().addEffect(new BecomesColorTargetEffect(new ObjectColor(), Duration.Custom));
this.getSpellAbility().addEffect(new BecomesColorTargetEffect(ObjectColor.COLORLESS, Duration.Custom));
}
private Moonlace(final Moonlace card) {

View file

@ -27,7 +27,7 @@ public final class RagingSpirit extends CardImpl {
this.toughness = new MageInt(3);
// {2}: Raging Spirit becomes colorless until end of turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorSourceEffect(new ObjectColor(), Duration.EndOfTurn), new ManaCostsImpl<>("{2}")));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorSourceEffect(ObjectColor.COLORLESS, Duration.EndOfTurn), new ManaCostsImpl<>("{2}")));
}
private RagingSpirit(final RagingSpirit card) {

View file

@ -37,8 +37,6 @@ public final class ThranLens extends CardImpl {
}
class ThranLensEffect extends ContinuousEffectImpl {
private static ObjectColor colorless = new ObjectColor();
public ThranLensEffect()
{
super(Duration.WhileOnBattlefield, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit);
@ -47,7 +45,7 @@ public final class ThranLens extends CardImpl {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent perm: game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
perm.getColor(game).setColor(colorless);
perm.getColor(game).setColor(ObjectColor.COLORLESS);
}
return true;
}

View file

@ -52,7 +52,7 @@ public final class XathridGorgon extends CardImpl {
effect = new AddCardTypeTargetEffect(Duration.Custom, CardType.ARTIFACT);
effect.setText("and becomes a colorless");
ability.addEffect(effect);
ability.addEffect(new BecomesColorTargetEffect(new ObjectColor(), Duration.Custom, "artifact in addition to its other types"));
ability.addEffect(new BecomesColorTargetEffect(ObjectColor.COLORLESS, Duration.Custom, "artifact in addition to its other types"));
ability.addEffect(new XathridGorgonCantActivateEffect());
this.addAbility(ability);

View file

@ -1,151 +0,0 @@
/*
*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*
*/
package mage.abilities.effects.common.continuous;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.choices.ChoiceColor;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
* @author LevelX
*/
public class BecomesColorAllEffect extends ContinuousEffectImpl {
private ObjectColor setColor;
protected boolean loseOther;
protected FilterPermanent filter;
/**
* Set the color of a spell or permanent
*
* @param duration
*/
public BecomesColorAllEffect(Duration duration) {
this(null, duration);
}
public BecomesColorAllEffect(ObjectColor setColor, Duration duration) {
this(setColor, duration, new FilterPermanent("All permanents"), true, null);
}
public BecomesColorAllEffect(ObjectColor setColor, Duration duration, FilterPermanent filter, boolean loseOther, String text) {
super(duration, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Neutral);
this.setColor = setColor;
this.filter = filter;
this.loseOther = loseOther;
staticText = text;
}
public BecomesColorAllEffect(final BecomesColorAllEffect effect) {
super(effect);
this.setColor = effect.setColor;
this.filter = effect.filter;
this.loseOther = effect.loseOther;
}
@Override
public void init(Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return;
}
if (setColor == null) {
ChoiceColor choice = new ChoiceColor();
if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
discard();
return;
}
setColor = choice.getColor();
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " has chosen the color: " + setColor.toString());
}
}
super.init(source, game); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
if (setColor != null) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
if (permanent != null) {
switch (layer) {
case ColorChangingEffects_5:
if (loseOther) {
permanent.getColor(game).setColor(new ObjectColor());
}
permanent.getColor(game).addColor(setColor);
break;
}
} else if (duration == Duration.Custom) {
discard();
}
}
return true;
}
return false;
}
@Override
public BecomesColorAllEffect copy() {
return new BecomesColorAllEffect(this);
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append(filter.getMessage());
sb.append(" become ");
if (setColor == null) {
sb.append("the color of your choice");
} else {
sb.append(setColor.getDescription());
}
if (!duration.toString().equals("")) {
sb.append(' ').append(duration.toString());
}
return sb.toString();
}
}

View file

@ -25,7 +25,6 @@ import java.util.UUID;
*/
public abstract class Designation extends MageObjectImpl {
private static final ObjectColor emptyColor = new ObjectColor();
private static final ManaCostsImpl emptyCost = new ManaCostsImpl<>();
private final DesignationType designationType;
@ -82,7 +81,7 @@ public abstract class Designation extends MageObjectImpl {
@Override
public ObjectColor getFrameColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
public DesignationType getDesignationType() {
@ -121,12 +120,12 @@ public abstract class Designation extends MageObjectImpl {
@Override
public ObjectColor getColor() {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override

View file

@ -45,7 +45,6 @@ public class Dungeon extends CommandObjectImpl {
}
private static final List<CardType> cardTypes = Collections.unmodifiableList(Arrays.asList(CardType.DUNGEON));
private static final ObjectColor emptyColor = new ObjectColor();
private static final ManaCosts<ManaCost> emptyCost = new ManaCostsImpl<>();
private UUID controllerId;
@ -238,17 +237,17 @@ public class Dungeon extends CommandObjectImpl {
@Override
public ObjectColor getColor() {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getFrameColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override

View file

@ -30,7 +30,6 @@ import java.util.UUID;
*/
public abstract class Emblem extends CommandObjectImpl {
private static final ObjectColor emptyColor = new ObjectColor();
private static final ManaCosts emptyCost = new ManaCostsImpl<>();
private UUID controllerId;
@ -153,17 +152,17 @@ public abstract class Emblem extends CommandObjectImpl {
@Override
public ObjectColor getColor() {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getFrameColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override

View file

@ -33,7 +33,6 @@ import java.util.UUID;
*/
public abstract class Plane extends CommandObjectImpl {
private static final ObjectColor emptyColor = new ObjectColor();
private static final ManaCosts emptyCost = new ManaCostsImpl<>();
private Planes planeType = null;
@ -178,17 +177,17 @@ public abstract class Plane extends CommandObjectImpl {
@Override
public ObjectColor getColor() {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getFrameColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override

View file

@ -45,7 +45,6 @@ public class StackAbility extends StackObjectImpl implements Ability {
private static final List<CardType> emptyCardType = Collections.unmodifiableList(new ArrayList<>());
private static final List<String> emptyString = Collections.unmodifiableList(new ArrayList<>());
private static final ObjectColor emptyColor = new ObjectColor();
private static final ManaCosts<ManaCost> emptyCost = new ManaCostsImpl<>();
private static final Costs<Cost> emptyCosts = new CostsImpl<>();
private static final Abilities<Ability> emptyAbilites = new AbilitiesImpl<>();
@ -223,12 +222,12 @@ public class StackAbility extends StackObjectImpl implements Ability {
@Override
public ObjectColor getColor() {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override
public ObjectColor getColor(Game game) {
return emptyColor;
return ObjectColor.COLORLESS;
}
@Override