diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java index 6f6d8cce200..8368c76c45d 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java @@ -62,7 +62,6 @@ public enum MythicspoilerComSource implements CardImageSource { private Map> cardNameAliasesStart; private final Map> sets; - @Override public String getSourceName() { return "mythicspoiler.com"; @@ -72,6 +71,7 @@ public enum MythicspoilerComSource implements CardImageSource { sets = new LinkedHashMap<>(); setsAliases = new HashMap<>(); setsAliases.put("exp", "bfz"); + setsAliases.put("xln", "ixa"); cardNameAliases = new HashMap<>(); // set+wrong name from web side => correct card name cardNameAliases.put("MM2-otherwordlyjourney", "otherworldlyjourney"); diff --git a/Mage.Client/src/main/resources/image.url.properties b/Mage.Client/src/main/resources/image.url.properties index 3415b291f22..8b2b31bb074 100644 --- a/Mage.Client/src/main/resources/image.url.properties +++ b/Mage.Client/src/main/resources/image.url.properties @@ -74,6 +74,6 @@ dd3evg=ddaevg dd3gvl=ddagvl dd3jvc=ddajvc # Remove setname as soon as the images can be downloaded -ignore.urls=TOK,DDT,V17,IMA,XLN,RIX,,E02,M19,M25,DOM,UST,H17 +ignore.urls=TOK,DDT,V17,IMA,RIX,E02,M19,M25,DOM,UST,H17 # sets ordered by release time (newest goes first) token.lookup.order=M19,M25,DOM,E02,RIX,UST,XLN,IMA,H17,C17,V17,E01,DDT,CMA,HOU,MM3,DDS,AKH,DD3DVD,DD3EVG,DD3GVL,DD3JVC,H09,AER,PCA,C16,V16,MPS,KLD,DDR,CN2,EMN,EMA,SOI,DDQ,CP,CMA,ARENA,SUS,APAC,EURO,UGIN,C15,OGW,EXP,DDP,BFZ,DRB,V09,V10,V11,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC \ No newline at end of file diff --git a/Mage.Common/src/main/java/mage/utils/MageVersion.java b/Mage.Common/src/main/java/mage/utils/MageVersion.java index 5d121360816..0b45f8ca40a 100644 --- a/Mage.Common/src/main/java/mage/utils/MageVersion.java +++ b/Mage.Common/src/main/java/mage/utils/MageVersion.java @@ -41,7 +41,7 @@ public class MageVersion implements Serializable, Comparable { public final static int MAGE_VERSION_MAJOR = 1; public final static int MAGE_VERSION_MINOR = 4; public final static int MAGE_VERSION_PATCH = 26; - public final static String MAGE_VERSION_MINOR_PATCH = "V2"; + public final static String MAGE_VERSION_MINOR_PATCH = "V3"; public final static String MAGE_VERSION_INFO = ""; private final int major; diff --git a/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java b/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java index bdeced5686b..19b501fc9f5 100644 --- a/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java +++ b/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java @@ -30,19 +30,25 @@ package mage.cards.a; import java.util.UUID; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.common.TapTargetCost; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.KickerAbility; import mage.abilities.keyword.TrampleAbility; +import mage.abilities.text.TextPartSubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.common.FilterControlledCreaturePermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.TextPartSubtypePredicate; +import mage.filter.predicate.permanent.TappedPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; +import mage.target.common.TargetControlledCreaturePermanent; import mage.target.targetpointer.FixedTarget; /** @@ -52,7 +58,7 @@ import mage.target.targetpointer.FixedTarget; public class AtarkaWorldRender extends CardImpl { public AtarkaWorldRender(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{G}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.DRAGON); this.power = new MageInt(6); @@ -65,7 +71,12 @@ public class AtarkaWorldRender extends CardImpl { this.addAbility(TrampleAbility.getInstance()); // Whenever a Dragon you control attacks, it gains double strike until end of turn. - this.addAbility(new AtarkaWorldRenderEffect()); + TextPartSubType textPart1 = (TextPartSubType) addTextPart(new TextPartSubType(SubType.DRAGON)); + FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Dragon you control"); + filter.add(new TextPartSubtypePredicate(textPart1)); + filter.add(Predicates.not(new TappedPredicate())); + this.addAbility(new KickerAbility(new TapTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, true)))); + this.addAbility(new AtarkaWorldRenderEffect(filter)); } @@ -81,18 +92,16 @@ public class AtarkaWorldRender extends CardImpl { class AtarkaWorldRenderEffect extends TriggeredAbilityImpl { - private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("dragon you control"); + FilterControlledCreaturePermanent filter; - static { - filter.add(new SubtypePredicate(SubType.DRAGON)); - } - - public AtarkaWorldRenderEffect() { + public AtarkaWorldRenderEffect(FilterControlledCreaturePermanent filter) { super(Zone.BATTLEFIELD, new GainAbilityTargetEffect(DoubleStrikeAbility.getInstance(), Duration.EndOfTurn)); + this.filter = filter; } public AtarkaWorldRenderEffect(final AtarkaWorldRenderEffect ability) { super(ability); + this.filter = ability.filter.copy(); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BloodTribute.java b/Mage.Sets/src/mage/cards/b/BloodTribute.java index cd1951fda3e..19cd00f57e4 100644 --- a/Mage.Sets/src/mage/cards/b/BloodTribute.java +++ b/Mage.Sets/src/mage/cards/b/BloodTribute.java @@ -35,6 +35,7 @@ import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.KickerAbility; +import mage.abilities.text.TextPartSubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -42,7 +43,7 @@ import mage.constants.Outcome; import mage.constants.SubType; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.Predicates; -import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.mageobject.TextPartSubtypePredicate; import mage.filter.predicate.permanent.TappedPredicate; import mage.game.Game; import mage.players.Player; @@ -55,17 +56,14 @@ import mage.target.common.TargetOpponent; */ public class BloodTribute extends CardImpl { - private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("an untapped Vampire you control"); - - static { - filter.add(Predicates.not(new TappedPredicate())); - filter.add(new SubtypePredicate(SubType.VAMPIRE)); - } - public BloodTribute(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}{B}"); // Kicker - Tap an untapped Vampire you control. + TextPartSubType textPartVampire = (TextPartSubType) addTextPart(new TextPartSubType(SubType.VAMPIRE)); + FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("an untapped Vampire you control"); + filter.add(new TextPartSubtypePredicate(textPartVampire)); + filter.add(Predicates.not(new TappedPredicate())); this.addAbility(new KickerAbility(new TapTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, true)))); // Target opponent loses half his or her life, rounded up. diff --git a/Mage.Sets/src/mage/cards/n/NewBlood.java b/Mage.Sets/src/mage/cards/n/NewBlood.java new file mode 100644 index 00000000000..abef9e8c1d6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NewBlood.java @@ -0,0 +1,230 @@ +/* + * 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.cards.n; + +import java.util.LinkedHashSet; +import java.util.UUID; +import java.util.stream.Collectors; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.text.TextPartSubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +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.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.TextPartSubtypePredicate; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ +public class NewBlood extends CardImpl { + + public NewBlood(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}{B}"); + + TextPartSubType textPartVampire = (TextPartSubType) addTextPart(new TextPartSubType(SubType.VAMPIRE)); + FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("an untapped Vampire you control"); + filter.add(new TextPartSubtypePredicate(textPartVampire)); + filter.add(Predicates.not(new TappedPredicate())); + // As an additional cost to cast New Blood, tap an untapped Vampire you control. + this.getSpellAbility().addCost(new TapTargetCost( + new TargetControlledCreaturePermanent(1, 1, filter, true))); + + // Gain control of target creature. Change the text of that creature by replacing all instances of one creature type with Vampire. + getSpellAbility().addEffect(new NewBloodEffect()); + getSpellAbility().addTarget(new TargetCreaturePermanent()); + } + + public NewBlood(final NewBlood card) { + super(card); + } + + @Override + public NewBlood copy() { + return new NewBlood(this); + } +} + +class NewBloodEffect extends OneShotEffect { + + public NewBloodEffect() { + super(Outcome.Benefit); + this.staticText = "Gain control of target creature. Change the text of that creature by replacing all instances of one creature type with Vampire"; + } + + public NewBloodEffect(final NewBloodEffect effect) { + super(effect); + } + + @Override + public NewBloodEffect copy() { + return new NewBloodEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true); + effect.setTargetPointer(new FixedTarget(targetPermanent, game)); + game.addEffect(effect, source); + effect = new ChangeCreatureTypeTargetEffect(null, SubType.VAMPIRE, Duration.Custom); + effect.setTargetPointer(new FixedTarget(targetPermanent, game)); + game.addEffect(effect, source); + return true; + } + return false; + } +} + +class ChangeCreatureTypeTargetEffect extends ContinuousEffectImpl { + + private SubType fromSubType; + private SubType toSubType; + + public ChangeCreatureTypeTargetEffect(SubType fromSubType, SubType toSubType, Duration duration) { + super(duration, Layer.TextChangingEffects_3, SubLayer.NA, Outcome.Benefit); + this.fromSubType = fromSubType; + this.toSubType = toSubType; + } + + public ChangeCreatureTypeTargetEffect(final ChangeCreatureTypeTargetEffect effect) { + super(effect); + this.fromSubType = effect.fromSubType; + this.toSubType = effect.toSubType; + } + + @Override + public void init(Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return; + } + if (fromSubType == null) { + Choice typeChoice = new ChoiceImpl(true); + typeChoice.setMessage("Choose creature type to change to Vampire"); + typeChoice.setChoices(SubType.getCreatureTypes(false).stream().map(SubType::toString).collect(Collectors.toCollection(LinkedHashSet::new))); + while (!controller.choose(outcome, typeChoice, game)) { + if (!controller.canRespond()) { + return; + } + } + if (typeChoice.getChoice() == null) { + return; + } + fromSubType = SubType.byDescription(typeChoice.getChoice()); + if (!game.isSimulation()) { + game.informPlayers(controller.getLogName() + " has chosen the creature type: " + fromSubType.toString()); + } + } + + super.init(source, game); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + if (fromSubType != null) { + boolean objectFound = false; + for (UUID targetId : targetPointer.getTargets(game, source)) { + MageObject targetObject = game.getObject(targetId); + if (targetObject != null) { + objectFound = true; + switch (layer) { + case TextChangingEffects_3: + targetObject.changeSubType(fromSubType, toSubType); + break; + case TypeChangingEffects_4: + if (sublayer == SubLayer.NA) { + if (targetObject.getSubtype(game).contains(fromSubType)) { + targetObject.getSubtype(game).remove(fromSubType); + if (!targetObject.getSubtype(game).contains(toSubType)) { + targetObject.getSubtype(game).add(toSubType); + } + } + break; + } + } + } + if (!objectFound && this.getDuration() == Duration.Custom) { + this.discard(); + } + } + return true; + } else { + throw new UnsupportedOperationException("No subtype to change set"); + } + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.TextChangingEffects_3 + || layer == Layer.TypeChangingEffects_4; + } + + @Override + public ChangeCreatureTypeTargetEffect copy() { + return new ChangeCreatureTypeTargetEffect(this); + } + + @Override + public String getText(Mode mode) { + return "Change the text of that creature by replacing all instances of one creature type with Vampire"; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2017.java b/Mage.Sets/src/mage/sets/Commander2017.java index b8c087fde0f..44bdb8329c9 100644 --- a/Mage.Sets/src/mage/sets/Commander2017.java +++ b/Mage.Sets/src/mage/sets/Commander2017.java @@ -222,6 +222,7 @@ public class Commander2017 extends ExpansionSet { cards.add(new SetCardInfo("Nazahn, Revered Bladesmith", 44, Rarity.MYTHIC, mage.cards.n.NazahnReveredBladesmith.class)); cards.add(new SetCardInfo("Necromantic Selection", 117, Rarity.RARE, mage.cards.n.NecromanticSelection.class)); cards.add(new SetCardInfo("Nevinyrral's Disk", 217, Rarity.RARE, mage.cards.n.NevinyrralsDisk.class)); + cards.add(new SetCardInfo("New Blood", 19, Rarity.RARE, mage.cards.n.NewBlood.class)); cards.add(new SetCardInfo("Nihil Spellbomb", 218, Rarity.COMMON, mage.cards.n.NihilSpellbomb.class)); cards.add(new SetCardInfo("Nin, the Pain Artist", 183, Rarity.RARE, mage.cards.n.NinThePainArtist.class)); cards.add(new SetCardInfo("Nissa's Pilgrimage", 155, Rarity.COMMON, mage.cards.n.NissasPilgrimage.class)); diff --git a/Mage/src/main/java/mage/MageObject.java b/Mage/src/main/java/mage/MageObject.java index 7be5a06d3e1..2569ca1acfd 100644 --- a/Mage/src/main/java/mage/MageObject.java +++ b/Mage/src/main/java/mage/MageObject.java @@ -1,10 +1,15 @@ 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; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.keyword.ChangelingAbility; +import mage.abilities.text.TextPart; import mage.cards.Card; import mage.cards.FrameStyle; import mage.constants.CardType; @@ -14,10 +19,6 @@ import mage.game.Game; import mage.game.events.ZoneChangeEvent; import mage.util.SubTypeList; -import java.io.Serializable; -import java.util.EnumSet; -import java.util.UUID; - public interface MageObject extends MageItem, Serializable { String getName(); @@ -58,7 +59,6 @@ public interface MageObject extends MageItem, Serializable { int getStartingLoyalty(); - void adjustCosts(Ability ability, Game game); void adjustTargets(Ability ability, Game game); @@ -85,7 +85,6 @@ public interface MageObject extends MageItem, Serializable { void setZoneChangeCounter(int value, Game game); - default boolean isCreature() { return getCardType().contains(CardType.CREATURE); } @@ -163,7 +162,6 @@ public interface MageObject extends MageItem, Serializable { return false; } - default boolean shareSubtypes(Card otherCard, Game game) { if (otherCard == null) { @@ -191,7 +189,15 @@ public interface MageObject extends MageItem, Serializable { void setIsAllCreatureTypes(boolean value); - default void addCardTypes(EnumSet cardType){ + default void addCardTypes(EnumSet cardType) { getCardType().addAll(cardType); } + + List getTextParts(); + + TextPart addTextPart(TextPart textPart); + + default void changeSubType(SubType fromSubType, SubType toSubType) { + + } } diff --git a/Mage/src/main/java/mage/MageObjectImpl.java b/Mage/src/main/java/mage/MageObjectImpl.java index 461a3fccd6b..30c93e6fb07 100644 --- a/Mage/src/main/java/mage/MageObjectImpl.java +++ b/Mage/src/main/java/mage/MageObjectImpl.java @@ -27,6 +27,10 @@ */ package mage; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.UUID; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; import mage.abilities.Ability; @@ -36,6 +40,8 @@ import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.keyword.ChangelingAbility; import mage.abilities.mana.ActivatedManaAbilityImpl; +import mage.abilities.text.TextPart; +import mage.abilities.text.TextPartSubType; import mage.cards.FrameStyle; import mage.constants.CardType; import mage.constants.SubType; @@ -46,10 +52,6 @@ import mage.game.events.ZoneChangeEvent; import mage.util.GameLog; import mage.util.SubTypeList; -import java.util.EnumSet; -import java.util.List; -import java.util.UUID; - public abstract class MageObjectImpl implements MageObject { protected UUID objectId; @@ -68,6 +70,7 @@ public abstract class MageObjectImpl implements MageObject { protected MageInt power; protected MageInt toughness; protected boolean copy; + protected List textParts; public MageObjectImpl() { this(UUID.randomUUID()); @@ -82,6 +85,7 @@ public abstract class MageObjectImpl implements MageObject { frameStyle = FrameStyle.M15_NORMAL; manaCost = new ManaCostsImpl<>(""); abilities = new AbilitiesImpl<>(); + textParts = new ArrayList<>(); } public MageObjectImpl(final MageObjectImpl object) { @@ -99,6 +103,8 @@ public abstract class MageObjectImpl implements MageObject { this.subtype.addAll(object.subtype); supertype.addAll(object.supertype); this.copy = object.copy; + textParts = new ArrayList<>(); + textParts.addAll(object.textParts); } @Override @@ -303,13 +309,33 @@ public abstract class MageObjectImpl implements MageObject { } @Override - public boolean isAllCreatureTypes(){ + public boolean isAllCreatureTypes() { return isAllCreatureTypes; } @Override - public void setIsAllCreatureTypes(boolean value){ + public void setIsAllCreatureTypes(boolean value) { isAllCreatureTypes = value; } + @Override + public List getTextParts() { + return textParts; + } + + @Override + public TextPart addTextPart(TextPart textPart) { + textParts.add(textPart); + return textPart; + } + + @Override + public void changeSubType(SubType fromSubType, SubType toSubType) { + for (TextPart textPart : textParts) { + if (textPart instanceof TextPartSubType && textPart.getCurrentValue().equals(fromSubType)) { + textPart.replaceWith(toSubType); + } + } + } + } diff --git a/Mage/src/main/java/mage/abilities/text/TextPart.java b/Mage/src/main/java/mage/abilities/text/TextPart.java new file mode 100644 index 00000000000..03778cb53ed --- /dev/null +++ b/Mage/src/main/java/mage/abilities/text/TextPart.java @@ -0,0 +1,52 @@ +/* + * 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.text; + +import java.io.Serializable; +import java.util.UUID; +import mage.util.Copyable; + +/** + * + * @author LevelX2 + * @param + */ +public interface TextPart extends Serializable, Copyable { + + UUID getId(); + + String getText(); + + E getBaseValue(); + + E getCurrentValue(); + + void replaceWith(E o); + + void reset(); +} diff --git a/Mage/src/main/java/mage/abilities/text/TextPartColor.java b/Mage/src/main/java/mage/abilities/text/TextPartColor.java new file mode 100644 index 00000000000..280ad78e029 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/text/TextPartColor.java @@ -0,0 +1,90 @@ +/* + * 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.text; + +import mage.ObjectColor; + +/** + * + * This implementation is not finished yet. There is no support to also change + * the rules text of an object. + * + * @author LevelX2 + */ +public class TextPartColor extends TextPartImpl { + + private final ObjectColor objectColorBase; + private ObjectColor objectColorCurrent; + + public TextPartColor(ObjectColor objectColor) { + this.objectColorBase = objectColor; + this.objectColorCurrent = objectColor; + } + + public TextPartColor(final TextPartColor textPartColor) { + super(); + this.objectColorBase = textPartColor.objectColorBase; + this.objectColorCurrent = textPartColor.objectColorCurrent; + } + + @Override + public String getText() { + return objectColorCurrent.getDescription(); + } + + @Override + public ObjectColor getCurrentValue() { + return objectColorCurrent; + } + + @Override + public ObjectColor getBaseValue() { + return objectColorBase; + } + + @Override + public void replaceWith(ObjectColor objectColor) { + this.objectColorCurrent = objectColor; + } + + @Override + public void reset() { + this.objectColorCurrent = this.objectColorBase; + } + + @Override + public TextPartColor copy() { + return new TextPartColor(this); + } + + @Override + public String toString() { + return objectColorCurrent.toString(); + } + +} diff --git a/Mage/src/main/java/mage/abilities/text/TextPartImpl.java b/Mage/src/main/java/mage/abilities/text/TextPartImpl.java new file mode 100644 index 00000000000..abc79ebfb99 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/text/TextPartImpl.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.abilities.text; + +import java.util.UUID; + +/** + * + * @author LevelX2 + * @param + */ +public abstract class TextPartImpl implements TextPart { + + private final UUID id; + + public TextPartImpl() { + this.id = UUID.randomUUID(); + } + + public TextPartImpl(final TextPartImpl textPartimpl) { + this.id = textPartimpl.id; + } + + @Override + public UUID getId() { + return id; + } + +} diff --git a/Mage/src/main/java/mage/abilities/text/TextPartSubType.java b/Mage/src/main/java/mage/abilities/text/TextPartSubType.java new file mode 100644 index 00000000000..ae067fbe062 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/text/TextPartSubType.java @@ -0,0 +1,90 @@ +/* + * 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.text; + +import mage.constants.SubType; + +/** + * This implementation is not finished yet. There is no support to also change + * the rules text of an object. Also all the cards that user subtypes in the + * text have to be updated with the new elements. + * + * @author LevelX2 + */ +public class TextPartSubType extends TextPartImpl { + + private final SubType subTypeBase; + private SubType subTypeCurrent; + + public TextPartSubType(SubType subType) { + this.subTypeBase = subType; + this.subTypeCurrent = subType; + } + + public TextPartSubType(final TextPartSubType textPartSubType) { + super(); + this.subTypeBase = textPartSubType.subTypeBase; + this.subTypeCurrent = textPartSubType.subTypeCurrent; + } + + @Override + public String getText() { + return subTypeCurrent.getDescription(); + } + + @Override + public SubType getCurrentValue() { + return subTypeCurrent; + } + + @Override + public SubType getBaseValue() { + return subTypeBase; + } + + @Override + public void replaceWith(SubType subType) { + this.subTypeCurrent = subType; + } + + @Override + public void reset() { + this.subTypeCurrent = this.subTypeBase; + } + + @Override + public TextPartSubType copy() { + return new TextPartSubType(this); + } + + @Override + public String toString() { + return subTypeCurrent.toString(); + } + +} diff --git a/Mage/src/main/java/mage/cards/repository/CardRepository.java b/Mage/src/main/java/mage/cards/repository/CardRepository.java index 7889341d5af..82248406626 100644 --- a/Mage/src/main/java/mage/cards/repository/CardRepository.java +++ b/Mage/src/main/java/mage/cards/repository/CardRepository.java @@ -58,7 +58,7 @@ public enum CardRepository { // raise this if db structure was changed private static final long CARD_DB_VERSION = 51; // raise this if new cards were added to the server - private static final long CARD_CONTENT_VERSION = 89; + private static final long CARD_CONTENT_VERSION = 90; private Dao cardDao; private Set classNames; diff --git a/Mage/src/main/java/mage/designations/Monarch.java b/Mage/src/main/java/mage/designations/Monarch.java index 7563f8956b2..6f6cd57404e 100644 --- a/Mage/src/main/java/mage/designations/Monarch.java +++ b/Mage/src/main/java/mage/designations/Monarch.java @@ -27,11 +27,14 @@ */ package mage.designations; +import java.util.List; +import java.util.UUID; import mage.MageObject; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; import mage.abilities.effects.common.BecomesMonarchTargetEffect; import mage.abilities.effects.common.DrawCardTargetEffect; +import mage.abilities.text.TextPart; import mage.constants.TargetController; import mage.constants.Zone; import mage.game.Game; @@ -40,8 +43,6 @@ import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; -import java.util.UUID; - /** * * @author LevelX2 @@ -73,6 +74,16 @@ public class Monarch extends Designation { public void setIsAllCreatureTypes(boolean value) { } + + @Override + public List getTextParts() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TextPart addTextPart(TextPart textPart) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } } // At the beginning of the monarch’s end step, that player draws a card @@ -159,5 +170,4 @@ class MonarchDealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility return "Whenever a creature deals combat damage to the monarch, its controller becomes the monarch."; } - } diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/TextPartSubtypePredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/TextPartSubtypePredicate.java new file mode 100644 index 00000000000..a00c4166347 --- /dev/null +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/TextPartSubtypePredicate.java @@ -0,0 +1,34 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.filter.predicate.mageobject; + +import mage.MageObject; +import mage.abilities.text.TextPartSubType; +import mage.filter.predicate.Predicate; +import mage.game.Game; + +/** + * + * @author LevelX2 + */ +public class TextPartSubtypePredicate implements Predicate { + + private final TextPartSubType textPartSubtype; + + public TextPartSubtypePredicate(TextPartSubType textPartSubtype) { + this.textPartSubtype = textPartSubtype; + } + + @Override + public boolean apply(MageObject input, Game game) { + return input.hasSubtype(textPartSubtype.getCurrentValue(), game); + } + + @Override + public String toString() { + return "Subtype(" + textPartSubtype.getCurrentValue() + ')'; + } +} diff --git a/Mage/src/main/java/mage/game/command/Commander.java b/Mage/src/main/java/mage/game/command/Commander.java index 6fe81c42817..b0ee9693dfb 100644 --- a/Mage/src/main/java/mage/game/command/Commander.java +++ b/Mage/src/main/java/mage/game/command/Commander.java @@ -27,6 +27,9 @@ */ package mage.game.command; +import java.util.EnumSet; +import java.util.List; +import java.util.UUID; import mage.MageInt; import mage.ObjectColor; import mage.abilities.Abilities; @@ -36,6 +39,7 @@ import mage.abilities.SpellAbility; import mage.abilities.common.CastCommanderAbility; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; +import mage.abilities.text.TextPart; import mage.cards.Card; import mage.cards.FrameStyle; import mage.constants.CardType; @@ -46,9 +50,6 @@ import mage.game.events.ZoneChangeEvent; import mage.util.GameLog; import mage.util.SubTypeList; -import java.util.EnumSet; -import java.util.UUID; - public class Commander implements CommandObject { private final Card sourceObject; @@ -229,7 +230,23 @@ public class Commander implements CommandObject { sourceObject.setZoneChangeCounter(value, game); } - public boolean isAllCreatureTypes() { return false;} + @Override + public boolean isAllCreatureTypes() { + return false; + } + + @Override + public void setIsAllCreatureTypes(boolean value) { + } + + @Override + public List getTextParts() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TextPart addTextPart(TextPart textPart) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } - public void setIsAllCreatureTypes(boolean value){} } diff --git a/Mage/src/main/java/mage/game/command/Emblem.java b/Mage/src/main/java/mage/game/command/Emblem.java index b0c0e671075..63746bdf6a0 100644 --- a/Mage/src/main/java/mage/game/command/Emblem.java +++ b/Mage/src/main/java/mage/game/command/Emblem.java @@ -27,6 +27,10 @@ */ package mage.game.command; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.ObjectColor; @@ -36,6 +40,7 @@ import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.text.TextPart; import mage.cards.Card; import mage.cards.FrameStyle; import mage.constants.CardType; @@ -46,18 +51,13 @@ import mage.game.events.ZoneChangeEvent; 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 nantuko */ public class Emblem implements CommandObject { private static EnumSet emptySet = EnumSet.noneOf(CardType.class); - private static List emptyList = new ArrayList(); + private static List emptyList = new ArrayList(); private static ObjectColor emptyColor = new ObjectColor(); private static ManaCosts emptyCost = new ManaCostsImpl(); @@ -268,8 +268,21 @@ public class Emblem implements CommandObject { throw new UnsupportedOperationException("Unsupported operation"); } - public boolean isAllCreatureTypes(){ return false;} + public boolean isAllCreatureTypes() { + return false; + } - public void setIsAllCreatureTypes(boolean value){} + public void setIsAllCreatureTypes(boolean value) { + } + + @Override + public List getTextParts() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TextPart addTextPart(TextPart textPart) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } } diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 106e61bcdf2..b0afa82a082 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -27,6 +27,7 @@ */ package mage.game.permanent; +import java.util.*; import mage.MageObject; import mage.MageObjectReference; import mage.ObjectColor; @@ -36,6 +37,7 @@ import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.RestrictionEffect; import mage.abilities.keyword.*; +import mage.abilities.text.TextPart; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.*; @@ -55,8 +57,6 @@ import mage.players.Player; import mage.util.GameLog; import mage.util.ThreadLocalStringBuilder; -import java.util.*; - /** * @author BetaSteward_at_googlemail.com */ @@ -204,6 +204,9 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { this.minBlockedBy = 1; this.maxBlockedBy = 0; this.copy = false; + for (TextPart textPart : textParts) { + textPart.reset(); + } } @Override @@ -1210,7 +1213,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { @Override public boolean imprint(UUID imprintedCard, Game game) { - if (!game.getExile().containsId(imprintedCard, game)){ + if (!game.getExile().containsId(imprintedCard, game)) { return false; } if (connectedCards.containsKey("imprint")) { diff --git a/Mage/src/main/java/mage/game/stack/Spell.java b/Mage/src/main/java/mage/game/stack/Spell.java index 288f757d9f9..b0815b2ffad 100644 --- a/Mage/src/main/java/mage/game/stack/Spell.java +++ b/Mage/src/main/java/mage/game/stack/Spell.java @@ -45,6 +45,7 @@ import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.keyword.BestowAbility; import mage.abilities.keyword.MorphAbility; +import mage.abilities.text.TextPart; import mage.cards.Card; import mage.cards.CardsImpl; import mage.cards.FrameStyle; @@ -927,10 +928,23 @@ public class Spell extends StackObjImpl implements Card { return copy; } + @Override public boolean isAllCreatureTypes() { return false; } + @Override public void setIsAllCreatureTypes(boolean value) { } + + @Override + public List getTextParts() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TextPart addTextPart(TextPart textPart) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + } diff --git a/Mage/src/main/java/mage/game/stack/StackAbility.java b/Mage/src/main/java/mage/game/stack/StackAbility.java index 3a6158ede3b..8af807bf2df 100644 --- a/Mage/src/main/java/mage/game/stack/StackAbility.java +++ b/Mage/src/main/java/mage/game/stack/StackAbility.java @@ -27,6 +27,10 @@ */ 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.ObjectColor; @@ -39,6 +43,7 @@ import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.Effects; +import mage.abilities.text.TextPart; import mage.cards.Card; import mage.cards.FrameStyle; import mage.constants.*; @@ -52,11 +57,6 @@ import mage.util.GameLog; import mage.util.SubTypeList; import mage.watchers.Watcher; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.UUID; - /** * * @author BetaSteward_at_googlemail.com @@ -593,9 +593,23 @@ public class StackAbility extends StackObjImpl implements Ability { return newStackAbility; } - public boolean isAllCreatureTypes(){ + @Override + public boolean isAllCreatureTypes() { return false; } - public void setIsAllCreatureTypes(boolean value){} + @Override + public void setIsAllCreatureTypes(boolean value) { + } + + @Override + public List getTextParts() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TextPart addTextPart(TextPart textPart) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + }