Refactor: removed unused custom set filters in SubType requests;

This commit is contained in:
Oleg Agafonov 2019-02-04 00:53:51 +04:00
parent e9c6c4fefa
commit b36465e5c9
27 changed files with 94 additions and 143 deletions

View file

@ -1,6 +1,5 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -9,15 +8,7 @@ import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.abilities.mana.AnyColorManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.Predicates;
@ -27,8 +18,9 @@ import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class AlpineMoon extends CardImpl {
@ -97,7 +89,7 @@ class AlpineMoonEffect extends ContinuousEffectImpl {
// 305.7 Note that this doesn't remove any abilities that were granted to the land by other effects
// So the ability removing has to be done before Layer 6
land.removeAllAbilities(source.getSourceId(), game);
land.getSubtype(game).removeAll(SubType.getLandTypes(false));
land.getSubtype(game).removeAll(SubType.getLandTypes());
break;
case AbilityAddingRemovingEffects_6:
land.addAbility(new AnyColorManaAbility(), source.getSourceId(), game);

View file

@ -139,7 +139,7 @@ class ConspiracyEffect extends ContinuousEffectImpl {
private void setChosenSubtype(SubTypeList subtype, SubType choice) {
if (subtype.size() != 1 || !subtype.contains(choice)) {
subtype.removeAll(SubType.getCreatureTypes(false));
subtype.clear();
subtype.add(choice);
}
}

View file

@ -1,9 +1,5 @@
package mage.cards.e;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
@ -16,8 +12,11 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPlayer;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class EgoErasure extends CardImpl {
@ -74,10 +73,10 @@ class EgoErasureLoseEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
} else {
it.remove();
}
@ -115,7 +114,7 @@ class EgoErasureBoostEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.addPower(-2);

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -16,8 +14,9 @@ import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class MagusOfTheMoon extends CardImpl {
@ -29,7 +28,7 @@ public final class MagusOfTheMoon extends CardImpl {
}
public MagusOfTheMoon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
@ -79,7 +78,7 @@ public final class MagusOfTheMoon extends CardImpl {
// 305.7 Note that this doesn't remove any abilities that were granted to the land by other effects
// So the ability removing has to be done before Layer 6
land.removeAllAbilities(source.getSourceId(), game);
land.getSubtype(game).removeAll(SubType.getLandTypes(false));
land.getSubtype(game).removeAll(SubType.getLandTypes());
land.getSubtype(game).add(SubType.MOUNTAIN);
break;
case AbilityAddingRemovingEffects_6:

View file

@ -1,6 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
@ -19,8 +18,9 @@ import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author noahg
*/
public final class MetamorphicAlteration extends CardImpl {
@ -126,7 +126,7 @@ class MetamorphicAlterationEffect extends ContinuousEffectImpl {
for (CardType t : copied.getCardType()) {
permanent.addCardType(t);
}
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
for (SubType t : copied.getSubtype(game)) {
permanent.getSubtype(game).add(t);
}

View file

@ -1,7 +1,6 @@
package mage.cards.m;
import java.util.ArrayList;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
@ -17,24 +16,23 @@ import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.target.common.TargetCardInLibrary;
import mage.util.SubTypeList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.constants.SuperType;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.game.Game;
import mage.target.common.TargetCardInLibrary;
import mage.util.SubTypeList;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class MyriadLandscape extends CardImpl {
@ -74,7 +72,7 @@ class TargetCardInLibrarySharingLandType extends TargetCardInLibrary {
static {
List<Predicate<MageObject>> subTypePreds = new ArrayList<>();
for (SubType landType : SubType.getLandTypes(false)) {
for (SubType landType : SubType.getLandTypes()) {
subTypePreds.add(new SubtypePredicate(landType));
}
filter.add(Predicates.or(subTypePreds));
@ -107,7 +105,7 @@ class TargetCardInLibrarySharingLandType extends TargetCardInLibrary {
}
Card card = game.getCard(id);
if (card != null && !landTypes.isEmpty()) {
for (Iterator<SubType> iterator = landTypes.iterator(); iterator.hasNext();) {
for (Iterator<SubType> iterator = landTypes.iterator(); iterator.hasNext(); ) {
SubType next = iterator.next();
if (card.hasSubtype(next, game)) {
return true;

View file

@ -1,4 +1,3 @@
package mage.cards.n;
import mage.Mana;
@ -23,13 +22,12 @@ import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class NyleasPresence extends CardImpl {
public NyleasPresence(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
this.subtype.add(SubType.AURA);
@ -62,7 +60,7 @@ class NyleasPresenceLandTypeEffect extends ContinuousEffectImpl {
public NyleasPresenceLandTypeEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
landTypes.addAll(SubType.getBasicLands(false));
landTypes.addAll(SubType.getBasicLands());
this.staticText = "Enchanted land is every basic land type in addition to its other types";
}
@ -90,11 +88,11 @@ class NyleasPresenceLandTypeEffect extends ContinuousEffectImpl {
switch (layer) {
case AbilityAddingRemovingEffects_6:
Mana mana = new Mana();
for (Ability ability : land.getAbilities()){
for (Ability ability : land.getAbilities()) {
if (ability instanceof BasicManaAbility) {
for (Mana netMana: ((BasicManaAbility)ability ).getNetMana(game)) {
for (Mana netMana : ((BasicManaAbility) ability).getNetMana(game)) {
mana.add(netMana);
}
}
}
}
if (mana.getGreen() == 0 && landTypes.contains(SubType.FOREST)) {

View file

@ -1,4 +1,3 @@
package mage.cards.p;
import mage.abilities.Ability;
@ -20,7 +19,6 @@ import java.util.Set;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class PlanarOverlay extends CardImpl {
@ -66,7 +64,7 @@ class PlanarOverlayEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (SubType landName : SubType.getBasicLands(false)) {
for (SubType landName : SubType.getBasicLands()) {
FilterLandPermanent filter = new FilterLandPermanent(landName + " to return to hand");
filter.add(new SubtypePredicate(landName));
filter.add(new ControllerPredicate(TargetController.YOU));

View file

@ -1,4 +1,3 @@
package mage.cards.p;
import mage.Mana;
@ -18,13 +17,12 @@ import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class PrismaticOmen extends CardImpl {
public PrismaticOmen(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
// Lands you control are every basic land type in addition to their other types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesBasicLandTypeAllEffect("Swamp", "Mountain", "Forest", "Island", "Plains")));
@ -46,7 +44,7 @@ class BecomesBasicLandTypeAllEffect extends ContinuousEffectImpl {
public BecomesBasicLandTypeAllEffect(String... landNames) {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
landTypes.addAll(SubType.getBasicLands(false));
landTypes.addAll(SubType.getBasicLands());
this.staticText = "Lands you control are every basic land type in addition to their other types";
}

View file

@ -1,8 +1,5 @@
package mage.cards.s;
import java.util.List;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -12,20 +9,16 @@ import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.util.SubTypeList;
import java.util.List;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class ShadesBreath extends CardImpl {
@ -102,7 +95,7 @@ class ShadesBreathSetSubtypeEffect extends ContinuousEffectImpl {
if (permanent != null) {
SubTypeList subtype = permanent.getSubtype(game);
if (subtype != null && (subtype.size() != 1 || !subtype.contains(SubType.SHADE))) {
subtype.removeAll(SubType.getCreatureTypes(false));
subtype.clear();
subtype.add(SubType.SHADE);
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import mage.MageInt;
@ -23,13 +22,12 @@ import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SunderingTitan extends CardImpl {
public SunderingTitan(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{8}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{8}");
this.subtype.add(SubType.GOLEM);
this.power = new MageInt(7);
@ -71,7 +69,7 @@ class SunderingTitanDestroyLandEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Set<UUID> lands = new HashSet<>();
if (controller != null && sourcePermanent != null) {
for (SubType landName : SubType.getBasicLands(false)) {
for (SubType landName : SubType.getBasicLands()) {
FilterLandPermanent filter = new FilterLandPermanent(landName + " to destroy");
filter.add(new SubtypePredicate(landName));
Target target = new TargetLandPermanent(1, 1, filter, true);