mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
Refactor: removed unused custom set filters in SubType requests;
This commit is contained in:
parent
e9c6c4fefa
commit
b36465e5c9
27 changed files with 94 additions and 143 deletions
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -18,8 +17,9 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public class ChooseLandTypeEffect extends OneShotEffect {
|
||||
|
|
@ -43,7 +43,7 @@ public class ChooseLandTypeEffect extends OneShotEffect {
|
|||
if (controller != null && mageObject != null) {
|
||||
Choice typeChoice = new ChoiceImpl(true);
|
||||
typeChoice.setMessage("Choose land type");
|
||||
typeChoice.setChoices(SubType.getLandTypes(false).stream().map(SubType::toString).collect(Collectors.toSet()));
|
||||
typeChoice.setChoices(SubType.getLandTypes().stream().map(SubType::toString).collect(Collectors.toSet()));
|
||||
if (controller.choose(outcome, typeChoice, game)) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -78,7 +77,7 @@ public class BecomesBasicLandEnchantedEffect extends ContinuousEffectImpl {
|
|||
break;
|
||||
case TypeChangingEffects_4:
|
||||
// subtypes are all removed by changing the subtype to a land type.
|
||||
permanent.getSubtype(game).removeAll(SubType.getLandTypes(false));
|
||||
permanent.getSubtype(game).removeAll(SubType.getLandTypes());
|
||||
permanent.getSubtype(game).addAll(landTypes);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.mana.*;
|
||||
|
|
@ -15,6 +10,11 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* http://mtgsalvation.gamepedia.com/Land_changers
|
||||
*
|
||||
|
|
@ -116,7 +116,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
|
|||
// So the ability removing has to be done before Layer 6
|
||||
land.removeAllAbilities(source.getSourceId(), game);
|
||||
// 305.7
|
||||
land.getSubtype(game).removeAll(SubType.getLandTypes(false));
|
||||
land.getSubtype(game).removeAll(SubType.getLandTypes());
|
||||
land.getSubtype(game).addAll(landTypes);
|
||||
} else {
|
||||
landTypesToAdd.clear();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -73,7 +72,7 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
|
|||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
case ABILITIES_SUBTYPE:
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
break;
|
||||
}
|
||||
for (SubType t : token.getSubtype(game)) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
|
|
@ -7,7 +6,6 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
|||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +69,7 @@ public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends Co
|
|||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
for (SuperType superType : token.getSuperType()) {
|
||||
permanentAttachedTo.addSuperType(superType);
|
||||
permanentAttachedTo.addSuperType(superType);
|
||||
|
||||
}
|
||||
// card type
|
||||
|
|
@ -90,7 +88,7 @@ public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends Co
|
|||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
case ABILITIES_SUBTYPE_AND_PT:
|
||||
permanentAttachedTo.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
permanentAttachedTo.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
break;
|
||||
}
|
||||
for (SubType subType : token.getSubtype(game)) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
|
|
@ -31,8 +30,9 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
}
|
||||
|
||||
public BecomesCreatureSourceEffect(Token token, String theyAreStillType, Duration duration, boolean losePreviousTypes, boolean characterDefining, DynamicValue power, DynamicValue toughness) {
|
||||
this(token, theyAreStillType,duration,losePreviousTypes,characterDefining,power,toughness,false);
|
||||
this(token, theyAreStillType, duration, losePreviousTypes, characterDefining, power, toughness, false);
|
||||
}
|
||||
|
||||
public BecomesCreatureSourceEffect(Token token, String theyAreStillType, Duration duration, boolean losePreviousTypes, boolean characterDefining, DynamicValue power, DynamicValue toughness, boolean loseAbilities) {
|
||||
super(duration, Outcome.BecomeCreature);
|
||||
this.characterDefining = characterDefining;
|
||||
|
|
@ -40,7 +40,8 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
this.theyAreStillType = theyAreStillType;
|
||||
this.losePreviousTypes = losePreviousTypes;
|
||||
this.power = power;
|
||||
this.toughness = toughness;this.loseAbilities=loseAbilities;
|
||||
this.toughness = toughness;
|
||||
this.loseAbilities = loseAbilities;
|
||||
setText();
|
||||
|
||||
this.addDependencyType(DependencyType.BecomeCreature);
|
||||
|
|
@ -50,7 +51,8 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
super(effect);
|
||||
this.token = effect.token.copy();
|
||||
this.theyAreStillType = effect.theyAreStillType;
|
||||
this.losePreviousTypes = effect.losePreviousTypes;this.loseAbilities=effect.loseAbilities;
|
||||
this.losePreviousTypes = effect.losePreviousTypes;
|
||||
this.loseAbilities = effect.loseAbilities;
|
||||
if (effect.power != null) {
|
||||
this.power = effect.power.copy();
|
||||
}
|
||||
|
|
@ -92,7 +94,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
}
|
||||
|
||||
if (theyAreStillType != null && theyAreStillType.isEmpty() || theyAreStillType == null && permanent.isLand()) {
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
}
|
||||
if (!token.getSubtype(game).isEmpty()) {
|
||||
permanent.getSubtype(game).addAll(token.getSubtype(game));
|
||||
|
|
@ -111,8 +113,9 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
if(loseAbilities){
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);}
|
||||
if (loseAbilities) {
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
}
|
||||
for (Ability ability : token.getAbilities()) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -7,7 +6,6 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
|||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.target.Target;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -24,10 +22,9 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl {
|
|||
protected boolean addStillALandText;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param token
|
||||
* @param loseAllAbilities loses all subtypes and colors
|
||||
* @param stillALand add rule text, "it's still a land"
|
||||
* @param stillALand add rule text, "it's still a land"
|
||||
* @param duration
|
||||
*/
|
||||
public BecomesCreatureTargetEffect(Token token, boolean loseAllAbilities, boolean stillALand, Duration duration) {
|
||||
|
|
@ -59,7 +56,7 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl {
|
|||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
if (loseAllAbilities) {
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
permanent.getSubtype(game).addAll(token.getSubtype(game));
|
||||
} else {
|
||||
if (!token.getSubtype(game).isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import mage.util.SubTypeList;
|
|||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class BecomesCreatureTypeTargetEffect extends ContinuousEffectImpl {
|
||||
|
|
@ -73,7 +72,7 @@ public class BecomesCreatureTypeTargetEffect extends ContinuousEffectImpl {
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (loseOther) {
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
permanent.getSubtype(game).addAll(subtypes);
|
||||
} else {
|
||||
for (SubType subtype : subtypes) {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class BecomesSubtypeAllEffect extends ContinuousEffectImpl {
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (loseOther) {
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
permanent.getSubtype(game).addAll(subtypes);
|
||||
} else {
|
||||
for (SubType subtype : subtypes) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -9,7 +8,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public class LoseAllCreatureTypesTargetEffect extends ContinuousEffectImpl {
|
||||
|
|
@ -32,7 +30,7 @@ public class LoseAllCreatureTypesTargetEffect extends ContinuousEffectImpl {
|
|||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
permanent.setIsAllCreatureTypes(false);
|
||||
return permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
return permanent.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public class LoseArtifactTypeTargetEffect extends ContinuousEffectImpl{
|
||||
public class LoseArtifactTypeTargetEffect extends ContinuousEffectImpl {
|
||||
|
||||
public LoseArtifactTypeTargetEffect(Duration duration) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Neutral);
|
||||
|
|
@ -53,7 +49,7 @@ public class LoseArtifactTypeTargetEffect extends ContinuousEffectImpl{
|
|||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.getCardType().remove(CardType.ARTIFACT);
|
||||
permanent.getSubtype(game).removeAll(SubType.getArtifactTypes(false));
|
||||
permanent.getSubtype(game).removeAll(SubType.getArtifactTypes());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -10,7 +9,6 @@ import mage.game.permanent.Permanent;
|
|||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class LoseCreatureTypeSourceEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
|
@ -65,7 +63,7 @@ public class LoseCreatureTypeSourceEffect extends ContinuousEffectImpl implement
|
|||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.getCardType().remove(CardType.CREATURE);
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
permanent.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
if (permanent.isAttacking() || permanent.getBlocking() > 0) {
|
||||
permanent.removeFromCombat(game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.SubTypeList;
|
||||
|
|
@ -54,7 +48,7 @@ public class SetCardSubtypeAttachedEffect extends ContinuousEffectImpl {
|
|||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent target = game.getPermanent(equipment.getAttachedTo());
|
||||
if (target != null) {
|
||||
target.getSubtype(game).retainAll(SubType.getLandTypes(false));
|
||||
target.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
target.getSubtype(game).addAll(setSubtypes);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.choices;
|
||||
|
||||
import mage.constants.SubType;
|
||||
|
|
@ -13,7 +11,7 @@ public class ChoiceLandType extends ChoiceImpl {
|
|||
|
||||
public ChoiceLandType() {
|
||||
super(true);
|
||||
this.setChoices(SubType.getLandTypes(false).stream().map(SubType::toString).collect(Collectors.toSet()));
|
||||
this.setChoices(SubType.getLandTypes().stream().map(SubType::toString).collect(Collectors.toSet()));
|
||||
this.message = "Choose a land type";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -471,48 +471,47 @@ public enum SubType {
|
|||
return subTypeSet;
|
||||
}
|
||||
|
||||
public static Set<SubType> getArtifactTypes(boolean withCustomSets) {
|
||||
public static Set<SubType> getArtifactTypes() {
|
||||
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||
for (SubType subType : values()) {
|
||||
if (subType.getSubTypeSet() == SubTypeSet.ArtifactType && (withCustomSets || !subType.customSet)) {
|
||||
if (subType.getSubTypeSet() == SubTypeSet.ArtifactType) {
|
||||
subTypes.add(subType);
|
||||
}
|
||||
}
|
||||
return subTypes;
|
||||
}
|
||||
|
||||
public static Set<SubType> getPlaneswalkerTypes(boolean withCustomSets) {
|
||||
public static Set<SubType> getPlaneswalkerTypes() {
|
||||
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||
for (SubType subType : values()) {
|
||||
if (subType.getSubTypeSet() == SubTypeSet.PlaneswalkerType && (withCustomSets || !subType.customSet)) {
|
||||
if (subType.getSubTypeSet() == SubTypeSet.PlaneswalkerType) {
|
||||
subTypes.add(subType);
|
||||
}
|
||||
}
|
||||
return subTypes;
|
||||
}
|
||||
|
||||
public static Set<SubType> getCreatureTypes(boolean customSet) {
|
||||
public static Set<SubType> getCreatureTypes() {
|
||||
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||
for (SubType s : values()) {
|
||||
if (s.customSet == customSet && s.getSubTypeSet() == SubTypeSet.CreatureType) {
|
||||
subTypes.add(s);
|
||||
for (SubType subType : values()) {
|
||||
if (subType.getSubTypeSet() == SubTypeSet.CreatureType) {
|
||||
subTypes.add(subType);
|
||||
}
|
||||
}
|
||||
return subTypes;
|
||||
}
|
||||
|
||||
public static Set<SubType> getBasicLands(boolean customSet) {
|
||||
public static Set<SubType> getBasicLands() {
|
||||
return Arrays.stream(values())
|
||||
.filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType)
|
||||
.filter(s -> s.customSet == customSet)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public static SubTypeList getLandTypes(boolean customSet) {
|
||||
public static SubTypeList getLandTypes() {
|
||||
SubTypeList landTypes = new SubTypeList();
|
||||
for (SubType s : values()) {
|
||||
if (s.getSubTypeSet() == SubTypeSet.BasicLandType || s.getSubTypeSet() == SubTypeSet.NonBasicLandType) {
|
||||
landTypes.add(s);
|
||||
for (SubType subType : values()) {
|
||||
if (subType.getSubTypeSet() == SubTypeSet.BasicLandType || subType.getSubTypeSet() == SubTypeSet.NonBasicLandType) {
|
||||
landTypes.add(subType);
|
||||
}
|
||||
}
|
||||
return landTypes;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue