change subtype.contains() to hasSubtype()

This commit is contained in:
igoudt 2017-09-25 21:20:24 +02:00
parent a316fe508f
commit b12b0e29b8
94 changed files with 250 additions and 277 deletions

View file

@ -1,9 +1,5 @@
package mage;
import java.io.Serializable;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
@ -19,6 +15,11 @@ import mage.game.Game;
import mage.game.events.ZoneChangeEvent;
import mage.util.SubTypeList;
import java.io.Serializable;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
public interface MageObject extends MageItem, Serializable {
String getName();
@ -177,7 +178,7 @@ public interface MageObject extends MageItem, Serializable {
}
}
for (SubType subtype : this.getSubtype(game)) {
if (otherCard.getSubtype(game).contains(subtype)) {
if (otherCard.hasSubtype(subtype, game)) {
return true;
}
}

View file

@ -58,7 +58,7 @@ public class AuraAttachedTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getSourceId())) {
Permanent attachment = game.getPermanent(event.getSourceId());
if (attachment != null && attachment.getSubtype(game).contains(SubType.AURA)) {
if (attachment != null && attachment.hasSubtype(SubType.AURA, game)) {
return true;
}
}

View file

@ -29,11 +29,11 @@ package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
import mage.constants.SubType;
/**
* Describes condition when creature is equipped with more than one Equipment.
@ -51,7 +51,7 @@ public enum EquippedMultipleSourceCondition implements Condition {
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached != null && attached.getSubtype(game).contains(SubType.EQUIPMENT)) {
if (attached != null && attached.hasSubtype(SubType.EQUIPMENT, game)) {
countEquipped++;
if (countEquipped >= 2) {
return true;

View file

@ -50,7 +50,7 @@ public enum EquippedSourceCondition implements Condition {
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached != null && attached.getSubtype(game).contains(SubType.EQUIPMENT)) {
if (attached != null && attached.hasSubtype(SubType.EQUIPMENT, game)) {
return true;
}
}

View file

@ -64,7 +64,7 @@ public class AuraAttachedCount implements DynamicValue {
List<UUID> attachments = p.getAttachments();
for (UUID attachmentId : attachments) {
Permanent attached = game.getPermanent(attachmentId);
if (attached != null && attached.getSubtype(game).contains(SubType.AURA)) {
if (attached != null && attached.hasSubtype(SubType.AURA, game)) {
count++;
}
}

View file

@ -1,14 +1,14 @@
package mage.abilities.dynamicvalue.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author Loki
*/
@ -63,19 +63,19 @@ public class DomainValue implements DynamicValue {
}
for (Permanent p : game.getBattlefield().getAllActivePermanents(targetPlayer)) {
if (p.isLand()) {
if (havePlains == 0 && p.getSubtype(game).contains(SubType.PLAINS)) {
if (havePlains == 0 && p.hasSubtype(SubType.PLAINS, game)) {
havePlains = 1;
}
if (haveIslands == 0 && p.getSubtype(game).contains(SubType.ISLAND)) {
if (haveIslands == 0 && p.hasSubtype(SubType.ISLAND, game)) {
haveIslands = 1;
}
if (haveMountains == 0 && p.getSubtype(game).contains(SubType.MOUNTAIN)) {
if (haveMountains == 0 && p.hasSubtype(SubType.MOUNTAIN, game)) {
haveMountains = 1;
}
if (haveSwamps == 0 && p.getSubtype(game).contains(SubType.SWAMP)) {
if (haveSwamps == 0 && p.hasSubtype(SubType.SWAMP, game)) {
haveSwamps = 1;
}
if (haveForests == 0 && p.getSubtype(game).contains(SubType.FOREST)) {
if (haveForests == 0 && p.hasSubtype(SubType.FOREST, game)) {
haveForests = 1;
}
}

View file

@ -27,8 +27,6 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
@ -36,6 +34,9 @@ import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.List;
import java.util.UUID;
/**
*
* @author North, noxx
@ -64,7 +65,7 @@ public class EquipmentAttachedCount implements DynamicValue {
List<UUID> attachments = permanent.getAttachments();
for (UUID attachmentId : attachments) {
Permanent attached = game.getPermanent(attachmentId);
if (attached != null && attached.getSubtype(game).contains(SubType.EQUIPMENT)) {
if (attached != null && attached.hasSubtype(SubType.EQUIPMENT, game)) {
count++;
}
}

View file

@ -27,9 +27,6 @@
*/
package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -51,6 +48,10 @@ import mage.util.CardUtil;
import mage.util.functions.ApplyToPermanent;
import mage.util.functions.EmptyApplyToPermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
@ -237,10 +238,10 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
if (tokenToughness != Integer.MIN_VALUE) {
token.getToughness().modifyBaseValue(tokenToughness);
}
if (additionalSubType != null && !token.getSubtype(game).contains(additionalSubType)) {
if (additionalSubType != null && !token.hasSubtype(additionalSubType, game)) {
token.getSubtype(game).add(additionalSubType);
}
if (onlySubType != null && !token.getSubtype(game).contains(onlySubType)) {
if (onlySubType != null && !token.hasSubtype(onlySubType, game)) {
token.getSubtype(game).clear();
token.getSubtype(game).add(onlySubType);
}

View file

@ -59,7 +59,7 @@ public class AddCardSubtypeAllEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (perm != null && !perm.getSubtype(game).contains(addedSubtype)) {
if (perm != null && !perm.hasSubtype(addedSubtype, game)) {
perm.getSubtype(game).add(addedSubtype);
}
}

View file

@ -59,7 +59,7 @@ public class AddCardSubtypeAttachedEffect extends ContinuousEffectImpl {
Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) {
Permanent target = game.getPermanent(equipment.getAttachedTo());
if (target != null && !target.getSubtype(game).contains(addedSubtype))
if (target != null && !target.hasSubtype(addedSubtype, game))
target.getSubtype(game).add(addedSubtype);
}
return true;

View file

@ -84,7 +84,7 @@ public class BecomesAuraSourceEffect extends ContinuousEffectImpl implements Sou
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!permanent.getSubtype(game).contains(SubType.AURA)) {
if (!permanent.hasSubtype(SubType.AURA, game)) {
permanent.getSubtype(game).add(SubType.AURA);
}
}

View file

@ -75,27 +75,27 @@ public class BecomesBasicLandEnchantedEffect extends ContinuousEffectImpl {
for (SubType landType : landTypes) {
switch (landType) {
case SWAMP:
if (permanent.getSubtype(game).contains(SubType.SWAMP)) { // type can be removed by other effect with newer timestamp, so no ability adding
if (permanent.hasSubtype(SubType.SWAMP, game)) { // type can be removed by other effect with newer timestamp, so no ability adding
permanent.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
break;
case MOUNTAIN:
if (permanent.getSubtype(game).contains(SubType.MOUNTAIN)) {
if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
permanent.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
break;
case FOREST:
if (permanent.getSubtype(game).contains(SubType.FOREST)) {
if (permanent.hasSubtype(SubType.FOREST, game)) {
permanent.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
break;
case ISLAND:
if (permanent.getSubtype(game).contains(SubType.ISLAND)) {
if (permanent.hasSubtype(SubType.ISLAND, game)) {
permanent.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
break;
case PLAINS:
if (permanent.getSubtype(game).contains(SubType.PLAINS)) {
if (permanent.hasSubtype(SubType.PLAINS, game)) {
permanent.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
break;

View file

@ -149,7 +149,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
} else {
landTypesToAdd.clear();
for (SubType subtype : landTypes) {
if (!land.getSubtype(game).contains(subtype)) {
if (!land.hasSubtype(subtype, game)) {
land.getSubtype(game).add(subtype);
landTypesToAdd.add(subtype);
}

View file

@ -104,7 +104,7 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
break;
}
for (SubType t : token.getSubtype(game)) {
if (!permanent.getSubtype(game).contains(t)) {
if (!permanent.hasSubtype(t, game)) {
permanent.getSubtype(game).add(t);
}
}

View file

@ -120,7 +120,7 @@ public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends Co
break;
}
for (SubType subType : token.getSubtype(game)) {
if (!permanentAttachedTo.getSubtype(game).contains(subType)) {
if (!permanentAttachedTo.hasSubtype(subType, game)) {
permanentAttachedTo.getSubtype(game).add(subType);
}
}

View file

@ -27,7 +27,7 @@ public class BecomesCreatureIfVehicleEffect extends ContinuousEffectImpl {
Permanent aura = game.getPermanent(source.getSourceId());
if (aura != null && aura.getAttachedTo() != null) {
Permanent enchanted = game.getPermanent(aura.getAttachedTo());
if (enchanted != null && enchanted.getSubtype(game).contains(SubType.VEHICLE)) {
if (enchanted != null && enchanted.hasSubtype(SubType.VEHICLE, game)) {
enchanted.addCardType(addedType);
}
}

View file

@ -89,7 +89,7 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl {
} else {
if (!token.getSubtype(game).isEmpty()) {
for (SubType subtype : token.getSubtype(game)) {
if (!permanent.getSubtype(game).contains(subtype)) {
if (!permanent.hasSubtype(subtype, game)) {
permanent.getSubtype(game).add(subtype);
}
}

View file

@ -77,7 +77,7 @@ public class BecomesCreatureTypeTargetEffect extends ContinuousEffectImpl {
permanent.getSubtype(game).addAll(subtypes);
} else {
for (SubType subtype : subtypes) {
if (!permanent.getSubtype(game).contains(subtype)) {
if (!permanent.hasSubtype(subtype, game)) {
permanent.getSubtype(game).add(subtype);
}
}

View file

@ -74,7 +74,7 @@ public class BecomesSubtypeAllEffect extends ContinuousEffectImpl {
permanent.getSubtype(game).addAll(subtypes);
} else {
for (SubType subtype : subtypes) {
if (!permanent.getSubtype(game).contains(subtype)) {
if (!permanent.hasSubtype(subtype, game)) {
permanent.getSubtype(game).add(subtype);
}
}

View file

@ -94,7 +94,7 @@ class AuraSwapEffect extends OneShotEffect {
if (controller != null) {
Permanent auraSourcePermanent = game.getPermanent(source.getSourceId());
if (auraSourcePermanent != null
&& auraSourcePermanent.getSubtype(game).contains(SubType.AURA)
&& auraSourcePermanent.hasSubtype(SubType.AURA, game)
&& auraSourcePermanent.getOwnerId().equals(source.getControllerId())) {
Permanent enchantedPermanent = game.getPermanent(auraSourcePermanent.getAttachedTo());
filterCardToCheck.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId()));

View file

@ -188,7 +188,7 @@ class BestowEntersBattlefieldEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent bestowPermanent = game.getPermanentEntering(source.getSourceId());
if (bestowPermanent != null) {
if (bestowPermanent.getSubtype(game).contains(SubType.AURA)) {
if (bestowPermanent.hasSubtype(SubType.AURA, game)) {
MageObject basicObject = bestowPermanent.getBasicMageObject(game);
basicObject.getSubtype(null).add(SubType.AURA);
basicObject.getCardType().remove(CardType.CREATURE);

View file

@ -110,7 +110,7 @@ class EmbalmEffect extends OneShotEffect {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
token.getColor(game).setColor(ObjectColor.WHITE);
if (!token.getSubtype(game).contains(SubType.ZOMBIE)) {
if (!token.hasSubtype(SubType.ZOMBIE, game)) {
token.getSubtype(game).add(0, SubType.ZOMBIE);
}
token.getManaCost().clear();

View file

@ -115,7 +115,7 @@ class EternalizeEffect extends OneShotEffect {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
token.getColor(game).setColor(ObjectColor.BLACK);
if (!token.getSubtype(game).contains(SubType.ZOMBIE)) {
if (!token.hasSubtype(SubType.ZOMBIE, game)) {
token.getSubtype(game).add(0, SubType.ZOMBIE);
}
token.getManaCost().clear();

View file

@ -27,7 +27,6 @@
*/
package mage.abilities.keyword;
import java.util.Iterator;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
@ -38,15 +37,13 @@ import mage.abilities.costs.CostsImpl;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.SpliceCardEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SpellAbilityType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import java.util.Iterator;
/**
* 702.45. Splice
@ -183,7 +180,7 @@ class SpliceOntoArcaneEffect extends SpliceCardEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
MageObject object = game.getObject(abilityToModify.getSourceId());
if (object != null && object.getSubtype(game).contains(SubType.ARCANE)) {
if (object != null && object.hasSubtype(SubType.ARCANE, game)) {
return spliceSpellCanBeActivated(source, game);
}
return false;

View file

@ -21,7 +21,7 @@ public class EquippedPredicate implements Predicate<Permanent> {
public boolean apply(Permanent input, Game game) {
for (UUID attachmentId : input.getAttachments()) {
Permanent attachment = game.getPermanent(attachmentId);
if (attachment != null && attachment.getSubtype(game).contains(SubType.EQUIPMENT)) {
if (attachment != null && attachment.hasSubtype(SubType.EQUIPMENT, game)) {
return true;
}
}

View file

@ -929,7 +929,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override
public boolean cantBeAttachedBy(MageObject source, Game game) {
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
if (!(source.getSubtype(game).contains(SubType.AURA)
if (!(source.hasSubtype(SubType.AURA, game)
&& !ability.removesAuras())
&& !source.getId().equals(ability.getAuraIdNotToBeRemoved())
&& !ability.canTarget(source, game)) {

View file

@ -27,10 +27,6 @@
*/
package mage.game.stack;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.Mana;
@ -64,6 +60,11 @@ import mage.players.Player;
import mage.util.GameLog;
import mage.util.SubTypeList;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -245,7 +246,7 @@ public class Spell extends StackObjImpl implements Card {
}
counter(null, game);
return false;
} else if (this.isEnchantment() && this.getSubtype(game).contains(SubType.AURA)) {
} else if (this.isEnchantment() && this.hasSubtype(SubType.AURA, game)) {
if (ability.getTargets().stillLegal(ability, game)) {
updateOptionalCosts(0);
boolean bestow = ability instanceof BestowAbility;

View file

@ -1,14 +1,17 @@
package mage.util;
import mage.constants.SubType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import mage.constants.SubType;
public class SubTypeList extends ArrayList<SubType> {
@Deprecated
public boolean addAll(List<String> subtypes) {
return addAll(subtypes.stream()

View file

@ -5,13 +5,14 @@
*/
package mage.util.functions;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author LevelX2
@ -26,7 +27,7 @@ public class AddSubtypeApplier extends ApplyToPermanent {
@Override
public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) {
if (!permanent.getSubtype(game).contains(subtype)) {
if (!permanent.hasSubtype(subtype, game)) {
permanent.getSubtype(game).add(subtype);
}
return true;
@ -34,7 +35,7 @@ public class AddSubtypeApplier extends ApplyToPermanent {
@Override
public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) {
if (!mageObject.getSubtype(game).contains(subtype)) {
if (!mageObject.hasSubtype(subtype, game)) {
mageObject.getSubtype(game).add(subtype);
}
return true;