From a4e374f96a04e4d7edaa05a7a1d85f28cdc8f542 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Thu, 3 Jan 2019 11:41:34 +0400 Subject: [PATCH 1/3] Refactor: improved emblem rules generation; --- .../src/mage/cards/a/AurraSingBaneOfJedi.java | 13 +++-- .../src/mage/cards/g/GarrukApexPredator.java | 11 +++-- .../mage/cards/r/RikuOfTwoReflections.java | 14 ++---- Mage.Sets/src/mage/cards/r/RowanKenrith.java | 17 ++----- Mage.Sets/src/mage/cards/w/WillKenrith.java | 16 ++---- .../effects/common/CopyTargetSpellEffect.java | 9 +++- .../common/GetEmblemTargetPlayerEffect.java | 6 +-- .../continuous/GainAbilityTargetEffect.java | 49 +++++++++---------- .../main/java/mage/filter/StaticFilters.java | 2 +- .../emblems/GarrukApexPredatorEmblem.java | 12 ++--- .../command/emblems/WillKenrithEmblem.java | 5 +- 11 files changed, 63 insertions(+), 91 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java b/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java index b09ac13a39..3ec0575da4 100644 --- a/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java +++ b/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java @@ -1,8 +1,5 @@ - package mage.cards.a; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; @@ -27,8 +24,10 @@ import mage.players.Player; import mage.target.TargetPlayer; import mage.target.common.TargetCreaturePermanent; +import java.util.List; +import java.util.UUID; + /** - * * @author Styxo */ public final class AurraSingBaneOfJedi extends CardImpl { @@ -39,17 +38,17 @@ public final class AurraSingBaneOfJedi extends CardImpl { this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(3)); - // +1:You may have {this} deal 2 damage to target creature. If you don't, {this} deals 1 damage to you. + // +1: You may have {this} deal 2 damage to target creature. If you don't, {this} deals 1 damage to you. Ability ability = new LoyaltyAbility(new AurraSingBaneOfJediEffect(), +1); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); - // -4:Target player gets an emblem wiht "Whenever a nontoken creature you control leave the battlefied, discard a card.". + // -4: Target player gets an emblem wiht "Whenever a nontoken creature you control leave the battlefied, discard a card.". ability = new LoyaltyAbility(new GetEmblemTargetPlayerEffect(new AurraSingBaneOfJediEmblem()), -4); ability.addTarget(new TargetPlayer()); this.addAbility(ability); - // -6:Each player discards their hand and sacrificies all creatures he or she controls. Each player's life total becomes 1." + // -6: Each player discards their hand and sacrificies all creatures he or she controls. Each player's life total becomes 1." ability = new LoyaltyAbility(new DiscardHandAllEffect(), -6); ability.addEffect(new SacrificeAllEffect()); Effect effect = new SetPlayerLifeAllEffect(1, TargetController.ANY); diff --git a/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java b/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java index 58e8d5284b..c0698ec16e 100644 --- a/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java +++ b/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java @@ -1,7 +1,5 @@ - package mage.cards.g; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; @@ -12,7 +10,10 @@ import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.GetEmblemTargetPlayerEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.permanent.AnotherPredicate; @@ -25,8 +26,9 @@ import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class GarrukApexPredator extends CardImpl { @@ -62,7 +64,6 @@ public final class GarrukApexPredator extends CardImpl { // -8: Target opponent gets an emblem with "Whenever a creature attacks you, it gets +5/+5 and gains trample until end of turn." Effect effect = new GetEmblemTargetPlayerEffect(new GarrukApexPredatorEmblem()); - effect.setText("Target opponent gets an emblem with \"Whenever a creature attacks you, it gets +5/+5 and gains trample until end of turn.\""); ability = new LoyaltyAbility(effect, -8); ability.addTarget(new TargetOpponent()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/r/RikuOfTwoReflections.java b/Mage.Sets/src/mage/cards/r/RikuOfTwoReflections.java index ba5d5bab91..de22cb3cc4 100644 --- a/Mage.Sets/src/mage/cards/r/RikuOfTwoReflections.java +++ b/Mage.Sets/src/mage/cards/r/RikuOfTwoReflections.java @@ -1,22 +1,16 @@ - package mage.cards.r; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.CopyTargetSpellEffect; -import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.CreateTokenCopyTargetEffect; +import mage.abilities.effects.common.DoIfCostPaid; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.SetTargetPointer; -import mage.constants.SuperType; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.FilterSpell; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.Predicates; @@ -24,8 +18,9 @@ import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.TokenPredicate; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class RikuOfTwoReflections extends CardImpl { @@ -53,7 +48,6 @@ public final class RikuOfTwoReflections extends CardImpl { // Whenever you cast an instant or sorcery spell, you may pay {U}{R}. If you do, copy that spell. You may choose new targets for the copy. Effect effect = new CopyTargetSpellEffect(true); - effect.setText("copy that spell. You may choose new targets for the copy"); this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(effect, new ManaCostsImpl("{U}{R}")), filter, false, true)); // Whenever another nontoken creature enters the battlefield under your control, you may pay {G}{U}. If you do, create a token that's a copy of that creature. diff --git a/Mage.Sets/src/mage/cards/r/RowanKenrith.java b/Mage.Sets/src/mage/cards/r/RowanKenrith.java index a5ef32577d..665f4066c2 100644 --- a/Mage.Sets/src/mage/cards/r/RowanKenrith.java +++ b/Mage.Sets/src/mage/cards/r/RowanKenrith.java @@ -1,7 +1,5 @@ - package mage.cards.r; -import java.util.UUID; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; @@ -13,14 +11,9 @@ import mage.abilities.effects.RequirementEffect; import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.effects.common.GetEmblemTargetPlayerEffect; import mage.abilities.keyword.PartnerWithAbility; -import mage.constants.SubType; -import mage.constants.SuperType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.TurnPhase; +import mage.constants.*; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.filter.predicate.permanent.TappedPredicate; @@ -29,8 +22,9 @@ import mage.game.command.emblems.RowanKenrithEmblem; import mage.game.permanent.Permanent; import mage.target.TargetPlayer; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class RowanKenrith extends CardImpl { @@ -54,11 +48,6 @@ public final class RowanKenrith extends CardImpl { // -8: Target player gets an emblem with "Whenever you activate an ability that isn't a mana ability, copy it. You may choose new targets for the copy." Effect effect = new GetEmblemTargetPlayerEffect(new RowanKenrithEmblem()); - effect.setText( - "Target player gets an emblem with " - + "\"Whenever you activate an ability that isn't a mana ability, " - + "copy it. You may choose new targets for the copy.\"" - ); ability = new LoyaltyAbility(effect, -8); ability.addTarget(new TargetPlayer()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/w/WillKenrith.java b/Mage.Sets/src/mage/cards/w/WillKenrith.java index e1d623e8fd..8a4c55d726 100644 --- a/Mage.Sets/src/mage/cards/w/WillKenrith.java +++ b/Mage.Sets/src/mage/cards/w/WillKenrith.java @@ -1,7 +1,5 @@ - package mage.cards.w; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.CanBeYourCommanderAbility; @@ -16,11 +14,7 @@ import mage.abilities.effects.common.cost.SpellsCostReductionAllEffect; import mage.abilities.keyword.PartnerWithAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.SubType; -import mage.constants.SuperType; +import mage.constants.*; import mage.filter.FilterCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; @@ -29,8 +23,9 @@ import mage.game.command.emblems.WillKenrithEmblem; import mage.target.TargetPlayer; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class WillKenrith extends CardImpl { @@ -60,11 +55,6 @@ public final class WillKenrith extends CardImpl { // -8: Target player gets an emblem with "Whenever you cast an instant or sorcery spell, copy it. You may choose new targets for the copy." Effect effect = new GetEmblemTargetPlayerEffect(new WillKenrithEmblem()); - effect.setText( - "Target player gets an emblem with " - + "\"Whenever you cast an instant or sorcery spell, " - + "copy it. You may choose new targets for the copy.\"" - ); ability = new LoyaltyAbility(effect, -8); ability.addTarget(new TargetPlayer()); this.addAbility(ability); diff --git a/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java index 93c6712292..f108df1a28 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java @@ -2,6 +2,7 @@ package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.Mode; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; import mage.constants.Zone; @@ -17,6 +18,7 @@ public class CopyTargetSpellEffect extends OneShotEffect { private final boolean useController; private final boolean useLKI; + private String copyThatSpellName = "that spell"; public CopyTargetSpellEffect() { this(false); @@ -38,6 +40,11 @@ public class CopyTargetSpellEffect extends OneShotEffect { this.useController = effect.useController; } + public Effect withSpellName(String copyThatSpellName) { + this.copyThatSpellName = copyThatSpellName; + return this; + } + @Override public boolean apply(Game game, Ability source) { Spell spell; @@ -81,7 +88,7 @@ public class CopyTargetSpellEffect extends OneShotEffect { if (!mode.getTargets().isEmpty()) { sb.append("target ").append(mode.getTargets().get(0).getTargetName()); } else { - sb.append("that spell"); + sb.append(copyThatSpellName); } sb.append(". You may choose new targets for the copy"); diff --git a/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java index 58fb0c2cf3..a99b93a6f3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java @@ -1,4 +1,3 @@ - package mage.abilities.effects.common; import mage.MageObject; @@ -10,8 +9,9 @@ import mage.game.Game; import mage.game.command.Emblem; import mage.players.Player; +import java.util.stream.Collectors; + /** - * * @author LevelX2 */ public class GetEmblemTargetPlayerEffect extends OneShotEffect { @@ -53,6 +53,6 @@ public class GetEmblemTargetPlayerEffect extends OneShotEffect { if (staticText != null && !staticText.isEmpty()) { return staticText; } - return "Target " + mode.getTargets().get(0).getTargetName() + " gets an emblem with \"" + emblem.getAbilities().getRules(null) + '"'; + return "Target " + mode.getTargets().get(0).getTargetName() + " gets an emblem with \"" + emblem.getAbilities().getRules(null).stream().collect(Collectors.joining("; ")) + "\""; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java index 881e319024..ba4747be4e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java @@ -1,24 +1,18 @@ - package mage.abilities.effects.common.continuous; -import java.util.Locale; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.ContinuousEffectImpl; import mage.cards.Card; -import mage.constants.DependencyType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.PhaseStep; -import mage.constants.SubLayer; +import mage.constants.*; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.Target; +import java.util.Locale; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ public class GainAbilityTargetEffect extends ContinuousEffectImpl { @@ -88,9 +82,7 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl { return true; } if (durationPhaseStep != null && durationPhaseStep == game.getPhase().getStep().getType()) { - if (!sameStep && game.isActivePlayer(durationPlayerId) || game.getPlayer(durationPlayerId).hasReachedNextTurnAfterLeaving()) { - return true; - } + return !sameStep && game.isActivePlayer(durationPlayerId) || game.getPlayer(durationPlayerId).hasReachedNextTurnAfterLeaving(); } else { sameStep = false; } @@ -137,21 +129,26 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl { return staticText; } StringBuilder sb = new StringBuilder(); - Target target = mode.getTargets().get(0); - if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) { - sb.append("any number of target ").append(target.getTargetName()).append(" gain "); - } else if (target.getMaxNumberOfTargets() > 1) { - if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) { - sb.append("up to "); - } - sb.append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName()).append(" gain "); - } else { - if (!target.getTargetName().toUpperCase(Locale.ENGLISH).startsWith("ANOTHER")) { - sb.append("target "); - } - sb.append(target.getTargetName()).append(" gains "); + if (mode.getTargets().size() > 0) { + Target target = mode.getTargets().get(0); + if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) { + sb.append("any number of target ").append(target.getTargetName()).append(" gain "); + } else if (target.getMaxNumberOfTargets() > 1) { + if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) { + sb.append("up to "); + } + sb.append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName()).append(" gain "); + } else { + if (!target.getTargetName().toUpperCase(Locale.ENGLISH).startsWith("ANOTHER")) { + sb.append("target "); + } + sb.append(target.getTargetName()).append(" gains "); + } + } else { + sb.append("gains "); } + sb.append(ability.getRule()); if (durationPhaseStep != null) { sb.append(" until your next ").append(durationPhaseStep.toString().toLowerCase(Locale.ENGLISH)); diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index 4226afe876..ba874fdace 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -477,7 +477,7 @@ public final class StaticFilters { FILTER_SPELL_AN_INSTANT_OR_SORCERY.setLockedFilter(true); } - public static final FilterSpell FILTER_SPELL_INSTANT_OR_SORCERY = new FilterSpell("instant or sorcery spell"); + public static final FilterSpell FILTER_SPELL_INSTANT_OR_SORCERY = new FilterSpell("an instant or sorcery spell"); static { FILTER_SPELL_INSTANT_OR_SORCERY.add(Predicates.or( diff --git a/Mage/src/main/java/mage/game/command/emblems/GarrukApexPredatorEmblem.java b/Mage/src/main/java/mage/game/command/emblems/GarrukApexPredatorEmblem.java index 63bae300ec..da013f9121 100644 --- a/Mage/src/main/java/mage/game/command/emblems/GarrukApexPredatorEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/GarrukApexPredatorEmblem.java @@ -1,4 +1,3 @@ - package mage.game.command.emblems; import mage.abilities.Ability; @@ -13,7 +12,6 @@ import mage.constants.Zone; import mage.game.command.Emblem; /** - * * @author spjspj */ public final class GarrukApexPredatorEmblem extends Emblem { @@ -25,12 +23,12 @@ public final class GarrukApexPredatorEmblem extends Emblem { public GarrukApexPredatorEmblem() { setName("Emblem Garruk"); - Effect effect = new BoostTargetEffect(5, 5, Duration.EndOfTurn); - effect.setText("it gets +5/+5"); + + Effect effect = new BoostTargetEffect(-1, 0, Duration.EndOfTurn); + effect.setText("it gets -1/-0"); Ability ability = new AttackedByCreatureTriggeredAbility(Zone.COMMAND, effect, false, SetTargetPointer.PERMANENT); - effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, - "and gains trample until end of turn"); - ability.addEffect(effect); + effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn); + ability.addEffect(effect.concatBy("and")); this.getAbilities().add(ability); } } diff --git a/Mage/src/main/java/mage/game/command/emblems/WillKenrithEmblem.java b/Mage/src/main/java/mage/game/command/emblems/WillKenrithEmblem.java index 9a0f1bbbe6..1442e71972 100644 --- a/Mage/src/main/java/mage/game/command/emblems/WillKenrithEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/WillKenrithEmblem.java @@ -1,4 +1,3 @@ - package mage.game.command.emblems; import mage.abilities.common.SpellCastControllerTriggeredAbility; @@ -8,7 +7,6 @@ import mage.filter.StaticFilters; import mage.game.command.Emblem; /** - * * @author TheElk801 */ public final class WillKenrithEmblem extends Emblem { @@ -18,8 +16,7 @@ public final class WillKenrithEmblem extends Emblem { this.setName("Emblem Will Kenrith"); this.getAbilities().add(new SpellCastControllerTriggeredAbility( Zone.COMMAND, - new CopyTargetSpellEffect(true) - .setText("copy that spell. You may choose new targets for the copy"), + new CopyTargetSpellEffect(true).withSpellName("it"), StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY, false, true From f6585ef7344c1a6eb9a201f023b340fcc583a6d3 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 4 Jan 2019 23:51:42 +0400 Subject: [PATCH 2/3] Improved and fixed cards texts: * fixed wrong texts for draw card abilities; * added multi-effects text generation instead copy-paste (concatBy). --- .../mage/cards/a/ArgothianEnchantress.java | 11 +++--- Mage.Sets/src/mage/cards/a/AsylumVisitor.java | 9 +++-- Mage.Sets/src/mage/cards/b/BalefulForce.java | 12 +++---- Mage.Sets/src/mage/cards/b/Betrayal.java | 10 +++--- .../src/mage/cards/b/BrassTalonChimera.java | 6 ++-- Mage.Sets/src/mage/cards/c/Cryptbreaker.java | 13 +++---- Mage.Sets/src/mage/cards/d/DarkProphecy.java | 15 ++++---- Mage.Sets/src/mage/cards/d/DimirCutpurse.java | 11 +++--- .../mage/cards/d/DisinformationCampaign.java | 10 +++--- Mage.Sets/src/mage/cards/d/DivinersWand.java | 36 ++++++++++--------- .../src/mage/cards/d/DuskLegionZealot.java | 24 ++++++------- Mage.Sets/src/mage/cards/f/Foreshadow.java | 4 +-- .../src/mage/cards/f/FretworkColony.java | 10 +++--- .../src/mage/cards/f/FreyalisesCharm.java | 7 ++-- .../src/mage/cards/g/GlintSleeveSiphoner.java | 8 ++--- .../mage/cards/m/MetalspinnersPuzzleknot.java | 13 +++---- .../src/mage/cards/m/MidnightEntourage.java | 10 +++--- .../src/mage/cards/o/ObNixilisReignited.java | 12 +++---- .../java/mage/abilities/effects/Effect.java | 10 +++--- .../mage/abilities/effects/EffectImpl.java | 24 +++++++++---- .../java/mage/abilities/effects/Effects.java | 10 +++++- .../effects/common/CopyTargetSpellEffect.java | 1 + .../DrawCardSourceControllerEffect.java | 18 +++++++--- 23 files changed, 144 insertions(+), 140 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/ArgothianEnchantress.java b/Mage.Sets/src/mage/cards/a/ArgothianEnchantress.java index 27cd7898b1..f6e8dd769a 100644 --- a/Mage.Sets/src/mage/cards/a/ArgothianEnchantress.java +++ b/Mage.Sets/src/mage/cards/a/ArgothianEnchantress.java @@ -1,7 +1,5 @@ - package mage.cards.a; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.effects.common.DrawCardSourceControllerEffect; @@ -13,8 +11,9 @@ import mage.constants.SubType; import mage.filter.FilterSpell; import mage.filter.predicate.mageobject.CardTypePredicate; +import java.util.UUID; + /** - * * @author Backfir3 */ public final class ArgothianEnchantress extends CardImpl { @@ -26,16 +25,18 @@ public final class ArgothianEnchantress extends CardImpl { } public ArgothianEnchantress(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.DRUID); this.power = new MageInt(0); this.toughness = new MageInt(1); + // Shroud this.addAbility(ShroudAbility.getInstance()); + // Whenever you cast an Enchantment spell, you draw a card. - this.addAbility(new SpellCastControllerTriggeredAbility(new DrawCardSourceControllerEffect(1), filter, false)); + this.addAbility(new SpellCastControllerTriggeredAbility(new DrawCardSourceControllerEffect(1, "you"), filter, false)); } public ArgothianEnchantress(final ArgothianEnchantress card) { diff --git a/Mage.Sets/src/mage/cards/a/AsylumVisitor.java b/Mage.Sets/src/mage/cards/a/AsylumVisitor.java index bf7ea122ec..d31eb4c570 100644 --- a/Mage.Sets/src/mage/cards/a/AsylumVisitor.java +++ b/Mage.Sets/src/mage/cards/a/AsylumVisitor.java @@ -1,7 +1,5 @@ - package mage.cards.a; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; @@ -19,8 +17,9 @@ import mage.constants.ComparisonType; import mage.constants.SubType; import mage.constants.TargetController; +import java.util.UUID; + /** - * * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com) */ public final class AsylumVisitor extends CardImpl { @@ -33,11 +32,11 @@ public final class AsylumVisitor extends CardImpl { this.toughness = new MageInt(1); // At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life. - Ability ability = new ConditionalInterveningIfTriggeredAbility(new BeginningOfUpkeepTriggeredAbility(new DrawCardSourceControllerEffect(1), TargetController.ANY, false), + Ability ability = new ConditionalInterveningIfTriggeredAbility( + new BeginningOfUpkeepTriggeredAbility(new DrawCardSourceControllerEffect(1, "you"), TargetController.ANY, false), new CardsInHandCondition(ComparisonType.EQUAL_TO, 0, null, TargetController.ACTIVE), "At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life."); Effect effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/b/BalefulForce.java b/Mage.Sets/src/mage/cards/b/BalefulForce.java index 09b09a0e70..4107df5840 100644 --- a/Mage.Sets/src/mage/cards/b/BalefulForce.java +++ b/Mage.Sets/src/mage/cards/b/BalefulForce.java @@ -1,7 +1,5 @@ - package mage.cards.b; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; @@ -14,24 +12,24 @@ import mage.constants.CardType; import mage.constants.SubType; import mage.constants.TargetController; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class BalefulForce extends CardImpl { public BalefulForce(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{B}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{B}{B}{B}"); this.subtype.add(SubType.ELEMENTAL); this.power = new MageInt(7); this.toughness = new MageInt(7); // At the beginning of each upkeep, you draw a card and you lose 1 life. - Ability ability = new BeginningOfUpkeepTriggeredAbility(new DrawCardSourceControllerEffect(1), TargetController.ANY, false); + Ability ability = new BeginningOfUpkeepTriggeredAbility(new DrawCardSourceControllerEffect(1, "you"), TargetController.ANY, false); Effect effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); - ability.addEffect(effect); + ability.addEffect(effect.concatBy("and")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/b/Betrayal.java b/Mage.Sets/src/mage/cards/b/Betrayal.java index 46d61656e4..89f60dd1d1 100644 --- a/Mage.Sets/src/mage/cards/b/Betrayal.java +++ b/Mage.Sets/src/mage/cards/b/Betrayal.java @@ -1,7 +1,5 @@ - package mage.cards.b; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.BecomesTappedAttachedTriggeredAbility; import mage.abilities.effects.common.AttachEffect; @@ -18,8 +16,9 @@ import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author LoneFox */ public final class Betrayal extends CardImpl { @@ -31,7 +30,7 @@ public final class Betrayal extends CardImpl { } public Betrayal(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{U}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}"); this.subtype.add(SubType.AURA); // Enchant creature an opponent controls @@ -40,8 +39,9 @@ public final class Betrayal extends CardImpl { this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); + // Whenever enchanted creature becomes tapped, you draw a card. - this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DrawCardSourceControllerEffect(1), "enchanted creature")); + this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DrawCardSourceControllerEffect(1, "you"), "enchanted creature")); } public Betrayal(final Betrayal card) { diff --git a/Mage.Sets/src/mage/cards/b/BrassTalonChimera.java b/Mage.Sets/src/mage/cards/b/BrassTalonChimera.java index e0add84040..6d80495ed5 100644 --- a/Mage.Sets/src/mage/cards/b/BrassTalonChimera.java +++ b/Mage.Sets/src/mage/cards/b/BrassTalonChimera.java @@ -1,4 +1,3 @@ - package mage.cards.b; import mage.MageInt; @@ -22,7 +21,6 @@ import mage.target.common.TargetCreaturePermanent; import java.util.UUID; /** - * * @author TheElk801 */ public final class BrassTalonChimera extends CardImpl { @@ -43,9 +41,9 @@ public final class BrassTalonChimera extends CardImpl { // First strike this.addAbility(FirstStrikeAbility.getInstance()); - // Sacrifice Brass-Talon Chimera: Put a +2/+2 counter on target Chimera creature. It gains first strike. + // Sacrifice Brass-Talon Chimera: Put a +2/+2 counter on target Chimera creature. It gains first strike. (This effect lasts indefinitely.) Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.P2P2.createInstance()), new SacrificeSourceCost()); - ability.addEffect(new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.WhileOnBattlefield).setText("It gains first strike. (This effect lasts indefinitely.)")); + ability.addEffect(new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.WhileOnBattlefield).setText("It gains first strike. (This effect lasts indefinitely.)")); ability.addTarget(new TargetCreaturePermanent(filter)); addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/c/Cryptbreaker.java b/Mage.Sets/src/mage/cards/c/Cryptbreaker.java index 446fe224f6..788303c91b 100644 --- a/Mage.Sets/src/mage/cards/c/Cryptbreaker.java +++ b/Mage.Sets/src/mage/cards/c/Cryptbreaker.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -25,8 +23,9 @@ import mage.filter.predicate.permanent.TappedPredicate; import mage.game.permanent.token.ZombieToken; import mage.target.common.TargetControlledCreaturePermanent; +import java.util.UUID; + /** - * * @author fireshoes */ public final class Cryptbreaker extends CardImpl { @@ -39,7 +38,7 @@ public final class Cryptbreaker extends CardImpl { } public Cryptbreaker(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}"); this.subtype.add(SubType.ZOMBIE); this.power = new MageInt(1); this.toughness = new MageInt(1); @@ -51,12 +50,10 @@ public final class Cryptbreaker extends CardImpl { this.addAbility(ability); // Tap three untapped Zombies you control: You draw a card and you lose 1 life. - Effect effect = new DrawCardSourceControllerEffect(1); - effect.setText("You draw a card"); + Effect effect = new DrawCardSourceControllerEffect(1, "you"); ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new TapTargetCost(new TargetControlledCreaturePermanent(3, 3, filter, true))); effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); - ability.addEffect(effect); + ability.addEffect(effect.concatBy("and")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/d/DarkProphecy.java b/Mage.Sets/src/mage/cards/d/DarkProphecy.java index 91c3f34f59..4881da9516 100644 --- a/Mage.Sets/src/mage/cards/d/DarkProphecy.java +++ b/Mage.Sets/src/mage/cards/d/DarkProphecy.java @@ -1,7 +1,5 @@ - package mage.cards.d; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.DiesCreatureTriggeredAbility; import mage.abilities.effects.Effect; @@ -14,28 +12,27 @@ import mage.constants.TargetController; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.ControllerPredicate; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class DarkProphecy extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature you control"); + static { filter.add(new ControllerPredicate(TargetController.YOU)); } public DarkProphecy(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{B}{B}{B}"); - + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}{B}{B}"); // Whenever a creature you control dies, you draw a card and you lose 1 life. - Effect effect = new DrawCardSourceControllerEffect(1); - effect.setText("you draw a card"); + Effect effect = new DrawCardSourceControllerEffect(1, "you"); Ability ability = new DiesCreatureTriggeredAbility(effect, false, filter); effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); - ability.addEffect(effect); + ability.addEffect(effect.concatBy("and")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/d/DimirCutpurse.java b/Mage.Sets/src/mage/cards/d/DimirCutpurse.java index 90bdf07a64..54476bf662 100644 --- a/Mage.Sets/src/mage/cards/d/DimirCutpurse.java +++ b/Mage.Sets/src/mage/cards/d/DimirCutpurse.java @@ -1,7 +1,5 @@ - package mage.cards.d; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; @@ -9,20 +7,20 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.game.Game; import mage.players.Player; +import java.util.UUID; + /** - * * @author jeffwadsworth - * */ public final class DimirCutpurse extends CardImpl { public DimirCutpurse(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{B}"); this.subtype.add(SubType.SPIRIT); this.power = new MageInt(2); @@ -30,7 +28,6 @@ public final class DimirCutpurse extends CardImpl { // Whenever Dimir Cutpurse deals combat damage to a player, that player discards a card and you draw a card. this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DimirCutpurseEffect(), false, true)); - } public DimirCutpurse(final DimirCutpurse card) { diff --git a/Mage.Sets/src/mage/cards/d/DisinformationCampaign.java b/Mage.Sets/src/mage/cards/d/DisinformationCampaign.java index ab9a61804f..7b67d4bc80 100644 --- a/Mage.Sets/src/mage/cards/d/DisinformationCampaign.java +++ b/Mage.Sets/src/mage/cards/d/DisinformationCampaign.java @@ -1,6 +1,5 @@ package mage.cards.d; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -16,8 +15,9 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class DisinformationCampaign extends CardImpl { @@ -27,11 +27,9 @@ public final class DisinformationCampaign extends CardImpl { // When Disinformation Campaign enters the battlefield, you draw a card and each opponent discards a card. Ability ability = new EntersBattlefieldTriggeredAbility( - new DrawCardSourceControllerEffect(1).setText("you draw a card") - ); + new DrawCardSourceControllerEffect(1, "you")); ability.addEffect(new DiscardEachPlayerEffect( - new StaticValue(1), false, TargetController.OPPONENT - ).setText("and each opponent discards a card")); + new StaticValue(1), false, TargetController.OPPONENT).concatBy("and")); this.addAbility(ability); // Whenever you surveil, return Disinformation Campaign to its owner's hand. diff --git a/Mage.Sets/src/mage/cards/d/DivinersWand.java b/Mage.Sets/src/mage/cards/d/DivinersWand.java index b1387f8927..5008753221 100644 --- a/Mage.Sets/src/mage/cards/d/DivinersWand.java +++ b/Mage.Sets/src/mage/cards/d/DivinersWand.java @@ -1,7 +1,5 @@ - package mage.cards.d; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.DrawCardControllerTriggeredAbility; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; @@ -23,40 +21,46 @@ import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class DivinersWand extends CardImpl { private static final FilterPermanent filter = new FilterCreaturePermanent("a Wizard creature"); + static { filter.add(new SubtypePredicate(SubType.WIZARD)); } public DivinersWand(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.TRIBAL,CardType.ARTIFACT},"{3}"); + super(ownerId, setInfo, new CardType[]{CardType.TRIBAL, CardType.ARTIFACT}, "{3}"); this.subtype.add(SubType.WIZARD); this.subtype.add(SubType.EQUIPMENT); - // Equipped creature has "Whenever you draw a card, this creature gets +1/+1 and gains flying until end of turn" and "{4}: Draw a card." - Ability gainedAbility = new DrawCardControllerTriggeredAbility(new BoostSourceEffect(1,1, Duration.EndOfTurn), false); - gainedAbility.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn)); - Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.EQUIPMENT); - effect.setText("Equipped creature has \"Whenever you draw a card, this creature gets +1/+1 and gains flying until end of turn\""); - Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect); - effect = new GainAbilityAttachedEffect( - new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new GenericManaCost(4)), AttachmentType.EQUIPMENT); - effect.setText("and \"{4}: Draw a card.\""); - ability.addEffect(effect); - this.addAbility(ability); - // Whenever a Wizard creature enters the battlefield, you may attach Diviner's Wand to it. this.addAbility(new EntersBattlefieldAllTriggeredAbility( Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "attach {source} to it"), filter, true, SetTargetPointer.PERMANENT, null)); + // Equip {3} this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3))); + + // Equipped creature has "Whenever you draw a card, this creature gets +1/+1 and gains flying until end of turn" and "{4}: Draw a card." + // new abilities + Ability newBoost = new DrawCardControllerTriggeredAbility(new BoostSourceEffect(1, 1, Duration.EndOfTurn), false); + newBoost.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn).concatBy("and")); + Ability newDraw = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new GenericManaCost(4)); + // gain new abilities + Effect effectBoost = new GainAbilityAttachedEffect(newBoost, AttachmentType.EQUIPMENT) + .setText("Equipped creature has \"Whenever you draw a card, this creature gets +1/+1 and gains flying until end of turn\""); + Effect effectDraw = new GainAbilityAttachedEffect(newDraw, AttachmentType.EQUIPMENT) + .setText("\"{4}: Draw a card.\""); + // total ability + Ability totalAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, effectBoost); + totalAbility.addEffect(effectDraw.concatBy("and")); + this.addAbility(totalAbility); } public DivinersWand(final DivinersWand card) { diff --git a/Mage.Sets/src/mage/cards/d/DuskLegionZealot.java b/Mage.Sets/src/mage/cards/d/DuskLegionZealot.java index ff374e32e4..a80dddca0d 100644 --- a/Mage.Sets/src/mage/cards/d/DuskLegionZealot.java +++ b/Mage.Sets/src/mage/cards/d/DuskLegionZealot.java @@ -1,24 +1,24 @@ - package mage.cards.d; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.LoseLifeSourceControllerEffect; -import mage.constants.*; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.UUID; /** - * * @author JayDi85 */ -public final class DuskLegionZealot extends CardImpl { +public final class DuskLegionZealot extends CardImpl { - public DuskLegionZealot (UUID ownerId, CardSetInfo setInfo) { + public DuskLegionZealot(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); this.subtype.add(SubType.VAMPIRE); @@ -27,21 +27,19 @@ public final class DuskLegionZealot extends CardImpl { this.toughness = new MageInt(1); // When Dusk Legion Zealot enters the battlefield, you draw a card and you lose 1 life. - Effect drawEffect = new DrawCardSourceControllerEffect(1); - drawEffect.setText("you draw a card"); + Effect drawEffect = new DrawCardSourceControllerEffect(1, "you"); Ability ability = new EntersBattlefieldTriggeredAbility(drawEffect); Effect lifeEffect = new LoseLifeSourceControllerEffect(1); - lifeEffect.setText("and you lose 1 life"); - ability.addEffect(lifeEffect); + ability.addEffect(lifeEffect.concatBy("and")); this.addAbility(ability); } - public DuskLegionZealot (final DuskLegionZealot card) { + public DuskLegionZealot(final DuskLegionZealot card) { super(card); } @Override - public DuskLegionZealot copy() { - return new DuskLegionZealot (this); + public DuskLegionZealot copy() { + return new DuskLegionZealot(this); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/f/Foreshadow.java b/Mage.Sets/src/mage/cards/f/Foreshadow.java index e1d86d5e56..01fabc683e 100644 --- a/Mage.Sets/src/mage/cards/f/Foreshadow.java +++ b/Mage.Sets/src/mage/cards/f/Foreshadow.java @@ -29,7 +29,7 @@ public final class Foreshadow extends CardImpl { // Choose a card name, then target opponent puts the top card of their library into their graveyard. If that card has the chosen name, you draw a card. this.getSpellAbility().addEffect(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL)); - this.getSpellAbility().addEffect(new ForeshadowEffect()); + this.getSpellAbility().addEffect(new ForeshadowEffect().concatBy("then")); this.getSpellAbility().addTarget(new TargetOpponent()); // Draw a card at the beginning of the next turn's upkeep. @@ -51,7 +51,7 @@ class ForeshadowEffect extends OneShotEffect { public ForeshadowEffect() { super(Outcome.DrawCard); - this.staticText = ", then target opponent puts the top card of their library into their graveyard. If that card has the chosen name, you draw a card"; + this.staticText = "target opponent puts the top card of their library into their graveyard. If that card has the chosen name, you draw a card"; } public ForeshadowEffect(final ForeshadowEffect effect) { diff --git a/Mage.Sets/src/mage/cards/f/FretworkColony.java b/Mage.Sets/src/mage/cards/f/FretworkColony.java index 6c08fb8a16..5521f29bbb 100644 --- a/Mage.Sets/src/mage/cards/f/FretworkColony.java +++ b/Mage.Sets/src/mage/cards/f/FretworkColony.java @@ -1,7 +1,5 @@ - package mage.cards.f; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; @@ -16,14 +14,15 @@ import mage.constants.SubType; import mage.constants.TargetController; import mage.counters.CounterType; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class FretworkColony extends CardImpl { public FretworkColony(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); this.subtype.add(SubType.INSECT); this.power = new MageInt(1); this.toughness = new MageInt(1); @@ -34,8 +33,7 @@ public final class FretworkColony extends CardImpl { // At the beginning of your upkeep, put a +1/+1 counter on Fretwork Colony and you lose 1 life. Ability ability = new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), TargetController.YOU, false); Effect effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); - ability.addEffect(effect); + ability.addEffect(effect.concatBy("and")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/f/FreyalisesCharm.java b/Mage.Sets/src/mage/cards/f/FreyalisesCharm.java index 2690555929..35a573cb4f 100644 --- a/Mage.Sets/src/mage/cards/f/FreyalisesCharm.java +++ b/Mage.Sets/src/mage/cards/f/FreyalisesCharm.java @@ -1,7 +1,5 @@ - package mage.cards.f; -import java.util.UUID; import mage.ObjectColor; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SpellCastOpponentTriggeredAbility; @@ -15,8 +13,9 @@ import mage.constants.CardType; import mage.filter.FilterSpell; import mage.filter.predicate.mageobject.ColorPredicate; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class FreyalisesCharm extends CardImpl { @@ -33,7 +32,7 @@ public final class FreyalisesCharm extends CardImpl { // Whenever an opponent casts a black spell, you may pay {G}{G}. If you do, you draw a card. this.addAbility(new SpellCastOpponentTriggeredAbility( new DoIfCostPaid( - new DrawCardSourceControllerEffect(1), + new DrawCardSourceControllerEffect(1, "you"), new ManaCostsImpl("{G}{G}") ), filter, false )); diff --git a/Mage.Sets/src/mage/cards/g/GlintSleeveSiphoner.java b/Mage.Sets/src/mage/cards/g/GlintSleeveSiphoner.java index 09d2a2af10..27d9623720 100644 --- a/Mage.Sets/src/mage/cards/g/GlintSleeveSiphoner.java +++ b/Mage.Sets/src/mage/cards/g/GlintSleeveSiphoner.java @@ -1,7 +1,5 @@ - package mage.cards.g; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility; @@ -19,8 +17,9 @@ import mage.constants.SubType; import mage.constants.TargetController; import mage.constants.Zone; +import java.util.UUID; + /** - * * @author fireshoes */ public final class GlintSleeveSiphoner extends CardImpl { @@ -42,8 +41,7 @@ public final class GlintSleeveSiphoner extends CardImpl { // At the beginning of your upkeep, you may pay {E}{E}. If you do, draw a card and you lose 1 life. DoIfCostPaid doIfCostPaidEffect = new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new PayEnergyCost(2)); Effect effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); - doIfCostPaidEffect.addEffect(effect); + doIfCostPaidEffect.addEffect(effect.concatBy("and")); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, doIfCostPaidEffect, TargetController.YOU, false, false, "At the beginning of your upkeep, ")); } diff --git a/Mage.Sets/src/mage/cards/m/MetalspinnersPuzzleknot.java b/Mage.Sets/src/mage/cards/m/MetalspinnersPuzzleknot.java index 38acc7c2cc..377521781d 100644 --- a/Mage.Sets/src/mage/cards/m/MetalspinnersPuzzleknot.java +++ b/Mage.Sets/src/mage/cards/m/MetalspinnersPuzzleknot.java @@ -1,7 +1,5 @@ - package mage.cards.m; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; @@ -15,22 +13,21 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Zone; +import java.util.UUID; + /** - * * @author emerald000 */ public final class MetalspinnersPuzzleknot extends CardImpl { public MetalspinnersPuzzleknot(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); // When Metalspinner's Puzzleknot enters the battlefield, you draw a card and you lose 1 life. - Effect drawEffect = new DrawCardSourceControllerEffect(1); - drawEffect.setText("you draw a card"); + Effect drawEffect = new DrawCardSourceControllerEffect(1, "you"); Ability ability = new EntersBattlefieldTriggeredAbility(drawEffect); Effect lifeEffect = new LoseLifeSourceControllerEffect(1); - lifeEffect.setText("and you lose 1 life"); - ability.addEffect(lifeEffect); + ability.addEffect(lifeEffect.concatBy("and")); this.addAbility(ability); // {2}{B}, Sacrifice Metalspinner's Puzzleknot: You draw a card and you lose 1 life. diff --git a/Mage.Sets/src/mage/cards/m/MidnightEntourage.java b/Mage.Sets/src/mage/cards/m/MidnightEntourage.java index 9c0843b6d7..4fdd87ec21 100644 --- a/Mage.Sets/src/mage/cards/m/MidnightEntourage.java +++ b/Mage.Sets/src/mage/cards/m/MidnightEntourage.java @@ -1,7 +1,5 @@ - package mage.cards.m; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesThisOrAnotherCreatureTriggeredAbility; @@ -17,8 +15,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.ControllerPredicate; +import java.util.UUID; + /** - * * @author Styxo */ public final class MidnightEntourage extends CardImpl { @@ -42,10 +41,9 @@ public final class MidnightEntourage extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, true))); // Whenever Midnight Entourage or another Aetherborn you control dies, you draw a card and you lose 1 life. - Ability ability = new DiesThisOrAnotherCreatureTriggeredAbility(new DrawCardSourceControllerEffect(1), false, filter); + Ability ability = new DiesThisOrAnotherCreatureTriggeredAbility(new DrawCardSourceControllerEffect(1, "you"), false, filter); Effect effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); - ability.addEffect(effect); + ability.addEffect(effect.concatBy("and")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/o/ObNixilisReignited.java b/Mage.Sets/src/mage/cards/o/ObNixilisReignited.java index 5bea48f7f8..3a1003695b 100644 --- a/Mage.Sets/src/mage/cards/o/ObNixilisReignited.java +++ b/Mage.Sets/src/mage/cards/o/ObNixilisReignited.java @@ -1,7 +1,5 @@ - package mage.cards.o; -import java.util.UUID; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; import mage.abilities.effects.Effect; @@ -18,8 +16,9 @@ import mage.game.command.emblems.ObNixilisReignitedEmblem; import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** - * * @author fireshoes */ public final class ObNixilisReignited extends CardImpl { @@ -32,12 +31,10 @@ public final class ObNixilisReignited extends CardImpl { this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(5)); // +1: You draw a card and you lose 1 life. - Effect effect = new DrawCardSourceControllerEffect(1); - effect.setText("You draw a card"); + Effect effect = new DrawCardSourceControllerEffect(1, "you"); LoyaltyAbility ability1 = new LoyaltyAbility(effect, 1); effect = new LoseLifeSourceControllerEffect(1); - effect.setText("and you lose 1 life"); - ability1.addEffect(effect); + ability1.addEffect(effect.concatBy("and")); this.addAbility(ability1); // -3: Destroy target creature. @@ -47,7 +44,6 @@ public final class ObNixilisReignited extends CardImpl { // -8: Target opponent gets an emblem with "Whenever a player draws a card, you lose 2 life." effect = new GetEmblemTargetPlayerEffect(new ObNixilisReignitedEmblem()); - effect.setText("Target opponent gets an emblem with \"Whenever a player draws a card, you lose 2 life.\""); LoyaltyAbility ability3 = new LoyaltyAbility(effect, -8); ability3.addTarget(new TargetOpponent()); this.addAbility(ability3); diff --git a/Mage/src/main/java/mage/abilities/effects/Effect.java b/Mage/src/main/java/mage/abilities/effects/Effect.java index f956b7bf7d..07312ebdf1 100644 --- a/Mage/src/main/java/mage/abilities/effects/Effect.java +++ b/Mage/src/main/java/mage/abilities/effects/Effect.java @@ -1,8 +1,5 @@ - package mage.abilities.effects; -import java.io.Serializable; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.Mode; import mage.constants.EffectType; @@ -10,8 +7,10 @@ import mage.constants.Outcome; import mage.game.Game; import mage.target.targetpointer.TargetPointer; +import java.io.Serializable; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ public interface Effect extends Serializable { @@ -64,4 +63,7 @@ public interface Effect extends Serializable { Effect copy(); + Effect concatBy(String concatPrefix); + + String getConcatPrefix(); } diff --git a/Mage/src/main/java/mage/abilities/effects/EffectImpl.java b/Mage/src/main/java/mage/abilities/effects/EffectImpl.java index f640ec9aad..65e0bbada8 100644 --- a/Mage/src/main/java/mage/abilities/effects/EffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/EffectImpl.java @@ -1,9 +1,5 @@ - package mage.abilities.effects; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import mage.abilities.MageSingleton; import mage.abilities.Mode; import mage.constants.EffectType; @@ -11,8 +7,11 @@ import mage.constants.Outcome; import mage.target.targetpointer.FirstTargetPointer; import mage.target.targetpointer.TargetPointer; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ public abstract class EffectImpl implements Effect { @@ -23,7 +22,7 @@ public abstract class EffectImpl implements Effect { protected TargetPointer targetPointer = FirstTargetPointer.getInstance(); protected String staticText = ""; protected Map values; - protected boolean applyEffectsAfter = false; + protected String concatPrefix = ""; // combines multiple effects in text rule public EffectImpl(Outcome outcome) { this.id = UUID.randomUUID(); @@ -36,6 +35,7 @@ public abstract class EffectImpl implements Effect { this.staticText = effect.staticText; this.effectType = effect.effectType; this.targetPointer = effect.targetPointer.copy(); + this.concatPrefix = effect.concatPrefix; if (effect.values != null) { values = new HashMap<>(); Map map = effect.values; @@ -43,7 +43,6 @@ public abstract class EffectImpl implements Effect { values.put(entry.getKey(), entry.getValue()); } } - this.applyEffectsAfter = effect.applyEffectsAfter; } @Override @@ -112,4 +111,15 @@ public abstract class EffectImpl implements Effect { } return values.get(key); } + + @Override + public Effect concatBy(String concatPrefix) { + this.concatPrefix = concatPrefix; + return this; + } + + @Override + public String getConcatPrefix() { + return this.concatPrefix; + } } diff --git a/Mage/src/main/java/mage/abilities/effects/Effects.java b/Mage/src/main/java/mage/abilities/effects/Effects.java index 0fa4a32095..df2661806b 100644 --- a/Mage/src/main/java/mage/abilities/effects/Effects.java +++ b/Mage/src/main/java/mage/abilities/effects/Effects.java @@ -42,6 +42,7 @@ public class Effects extends ArrayList { public String getText(Mode mode) { StringBuilder sbText = new StringBuilder(); String lastRule = null; + int effectNum = 0; for (Effect effect : this) { String endString = ""; String nextRule = effect.getText(mode); @@ -50,9 +51,16 @@ public class Effects extends ArrayList { if (nextRule == null || nextRule.isEmpty()) { continue; } + effectNum++; + + // concat effects (default: each effect with a new sentence) + String concatPrefix = effect.getConcatPrefix(); + if (effectNum > 1 && !concatPrefix.isEmpty() && !concatPrefix.equals(".")) { + nextRule = concatPrefix + " " + nextRule; + } if (nextRule != null) { - if (nextRule.startsWith("and ") || nextRule.startsWith("with ")) { + if (nextRule.startsWith("and ") || nextRule.startsWith("with ") || nextRule.startsWith("then ")) { endString = " "; } else if (nextRule.startsWith(",") || nextRule.startsWith(" ")) { endString = ""; diff --git a/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java index f108df1a28..c3a4879b4d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java @@ -38,6 +38,7 @@ public class CopyTargetSpellEffect extends OneShotEffect { super(effect); this.useLKI = effect.useLKI; this.useController = effect.useController; + this.copyThatSpellName = effect.copyThatSpellName; } public Effect withSpellName(String copyThatSpellName) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DrawCardSourceControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DrawCardSourceControllerEffect.java index ce8822a9d1..c56a4f28b8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DrawCardSourceControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DrawCardSourceControllerEffect.java @@ -1,9 +1,7 @@ - package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; -import mage.abilities.dynamicvalue.common.MultikickerCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; @@ -18,20 +16,32 @@ import mage.util.CardUtil; public class DrawCardSourceControllerEffect extends OneShotEffect { protected DynamicValue amount; + protected String whoDrawCard = ""; public DrawCardSourceControllerEffect(int amount) { - this(new StaticValue(amount)); + this(amount, ""); + } + + public DrawCardSourceControllerEffect(int amount, String whoDrawCard) { + this(new StaticValue(amount), whoDrawCard); } public DrawCardSourceControllerEffect(DynamicValue amount) { + this(amount, ""); + } + + public DrawCardSourceControllerEffect(DynamicValue amount, String whoDrawCard) { super(Outcome.DrawCard); this.amount = amount.copy(); + this.whoDrawCard = whoDrawCard; setText(); } public DrawCardSourceControllerEffect(final DrawCardSourceControllerEffect effect) { super(effect); this.amount = effect.amount.copy(); + this.whoDrawCard = effect.whoDrawCard; + setText(); } @Override @@ -53,7 +63,7 @@ public class DrawCardSourceControllerEffect extends OneShotEffect { StringBuilder sb = new StringBuilder(); boolean oneCard = (amount instanceof StaticValue && amount.calculate(null, null, this) == 1) || amount instanceof PermanentsOnBattlefieldCount || amount.toString().equals("1") || amount.toString().equals("a"); - sb.append("draw ").append(oneCard ? "a" : CardUtil.numberToText(amount.toString())).append(" card"); + sb.append(whoDrawCard.isEmpty() ? "" : whoDrawCard + " ").append("draw ").append(oneCard ? "a" : CardUtil.numberToText(amount.toString())).append(" card"); if (!oneCard) { sb.append('s'); } From d81d253395bac9535a1b85047d8644098ca307b9 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 4 Jan 2019 23:57:28 +0400 Subject: [PATCH 3/3] Fixed GainAbilityAttachedEffect that it can't apply some effects after enchantment dies (from gitter); --- .../effects/common/continuous/GainAbilityAttachedEffect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAttachedEffect.java index 034f7a273e..fb52506093 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAttachedEffect.java @@ -70,7 +70,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); if (affectedObjectsSet) { - Permanent equipment = game.getPermanent(source.getSourceId()); + Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (equipment != null && equipment.getAttachedTo() != null) { this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo()))); } @@ -107,7 +107,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl { } else { sb.append("gains "); } - sb.append(ability.getRule()); + sb.append('"' + ability.getRule("this creature") + '"'); if (!duration.toString().isEmpty()) { sb.append(' ').append(duration.toString()); }