diff --git a/Mage.Sets/src/mage/cards/d/DecadentDragon.java b/Mage.Sets/src/mage/cards/d/DecadentDragon.java new file mode 100644 index 00000000000..8b299a57983 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DecadentDragon.java @@ -0,0 +1,118 @@ +package mage.cards.d; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.asthought.MayLookAtTargetCardEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.permanent.token.TreasureToken; +import mage.players.Player; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author Susucr + */ +public final class DecadentDragon extends AdventureCard { + + public DecadentDragon(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, new CardType[]{CardType.INSTANT}, "{2}{R}{R}", "Expensive Taste", "{2}{B}"); + + this.subtype.add(SubType.DRAGON); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Whenever Decadent Dragon attacks, create a Treasure token. + this.addAbility(new AttacksTriggeredAbility(new CreateTokenEffect(new TreasureToken()))); + + // Expensive Taste + // Exile the top two cards of target opponent's library face down. You may look at and play those cards for as long as they remain exiled. + this.getSpellCard().getSpellAbility().addEffect(new ExpensiveTasteEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetOpponent()); + } + + private DecadentDragon(final DecadentDragon card) { + super(card); + } + + @Override + public DecadentDragon copy() { + return new DecadentDragon(this); + } +} + +class ExpensiveTasteEffect extends OneShotEffect { + + private static final String VALUE_PREFIX = "ExileZones"; + + ExpensiveTasteEffect() { + super(Outcome.Benefit); + staticText = "exile the top two cards of target opponent's library face down. You may look at and play those cards for as long as they remain exiled."; + } + + private ExpensiveTasteEffect(final ExpensiveTasteEffect effect) { + super(effect); + } + + @Override + public ExpensiveTasteEffect copy() { + return new ExpensiveTasteEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player opponent = game.getPlayer(source.getFirstTarget()); + MageObject sourceObject = source.getSourceObject(game); + if (opponent == null || controller == null || sourceObject == null) { + return false; + } + + Cards topCards = new CardsImpl(); + topCards.addAllCards(opponent.getLibrary().getTopCards(game, 2)); + + for (Card card : topCards.getCards(game)) { + UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); + card.setFaceDown(true, game); + if (controller.moveCardsToExile(card, source, game, false, exileZoneId, sourceObject.getIdName())) { + card.setFaceDown(true, game); + Set exileZones = (Set) game.getState().getValue(VALUE_PREFIX + source.getSourceId().toString()); + if (exileZones == null) { + exileZones = new HashSet<>(); + game.getState().setValue(VALUE_PREFIX + source.getSourceId().toString(), exileZones); + } + exileZones.add(exileZoneId); + // allow to cast the card + CardUtil.makeCardPlayable(game, source, card, Duration.EndOfGame, false, controller.getId(), null); + // For as long as that card remains exiled, you may look at it + ContinuousEffect effect = new MayLookAtTargetCardEffect(controller.getId()); + effect.setTargetPointer(new FixedTarget(card.getId(), game)); + game.addEffect(effect, source); + } + } + return true; + } + +} diff --git a/Mage.Sets/src/mage/cards/g/GontiLordOfLuxury.java b/Mage.Sets/src/mage/cards/g/GontiLordOfLuxury.java index e5faa85135b..d7609d0821f 100644 --- a/Mage.Sets/src/mage/cards/g/GontiLordOfLuxury.java +++ b/Mage.Sets/src/mage/cards/g/GontiLordOfLuxury.java @@ -8,6 +8,7 @@ import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughManaEffect; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.asthought.MayLookAtTargetCardEffect; import mage.abilities.keyword.DeathtouchAbility; import mage.cards.*; import mage.constants.*; @@ -114,7 +115,7 @@ class GontiLordOfLuxuryEffect extends OneShotEffect { effect.setTargetPointer(new FixedTarget(card.getId(), game)); game.addEffect(effect, source); // For as long as that card remains exiled, you may look at it - effect = new GontiLordOfLuxuryLookEffect(controller.getId()); + effect = new MayLookAtTargetCardEffect(controller.getId()); effect.setTargetPointer(new FixedTarget(card.getId(), game)); game.addEffect(effect, source); } @@ -211,40 +212,4 @@ class GontiLordOfLuxurySpendAnyManaEffect extends AsThoughEffectImpl implements public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) { return mana.getFirstAvailable(); } -} - -class GontiLordOfLuxuryLookEffect extends AsThoughEffectImpl { - - private final UUID authorizedPlayerId; - - public GontiLordOfLuxuryLookEffect(UUID authorizedPlayerId) { - super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit); - this.authorizedPlayerId = authorizedPlayerId; - staticText = "You may look at the cards exiled with {this}"; - } - - private GontiLordOfLuxuryLookEffect(final GontiLordOfLuxuryLookEffect effect) { - super(effect); - this.authorizedPlayerId = effect.authorizedPlayerId; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public GontiLordOfLuxuryLookEffect copy() { - return new GontiLordOfLuxuryLookEffect(this); - } - - @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - UUID cardId = getTargetPointer().getFirst(game, source); - if (cardId == null) { - this.discard(); // card is no longer in the origin zone, effect can be discarded - } - return affectedControllerId.equals(authorizedPlayerId) - && objectId.equals(cardId); - } -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/p/PredatorsHour.java b/Mage.Sets/src/mage/cards/p/PredatorsHour.java index 2d1e4785a1f..af1878ddabb 100644 --- a/Mage.Sets/src/mage/cards/p/PredatorsHour.java +++ b/Mage.Sets/src/mage/cards/p/PredatorsHour.java @@ -7,6 +7,7 @@ import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughManaEffect; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.asthought.MayLookAtTargetCardEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.keyword.MenaceAbility; import mage.cards.*; @@ -119,7 +120,7 @@ class PredatorsHourEffect extends OneShotEffect { game.addEffect(effect, source); // For as long as that card remains exiled, you may look at it - effect = new PredatorsHourLookEffect(controller.getId()); + effect = new MayLookAtTargetCardEffect(controller.getId()); effect.setTargetPointer(new FixedTarget(topCard.getId(), game)); game.addEffect(effect, source); } @@ -204,36 +205,4 @@ class PredatorsHourSpendAnyManaEffect extends AsThoughEffectImpl implements AsTh public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) { return mana.getFirstAvailable(); } -} - -class PredatorsHourLookEffect extends AsThoughEffectImpl { - - private final UUID authorizedPlayerId; - - public PredatorsHourLookEffect(UUID authorizedPlayerId) { - super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit); - this.authorizedPlayerId = authorizedPlayerId; - staticText = "You may look at the cards exiled with {this}"; - } - - private PredatorsHourLookEffect(final PredatorsHourLookEffect effect) { - super(effect); - this.authorizedPlayerId = effect.authorizedPlayerId; - } - - @Override - public boolean apply(Game game, Ability source) { return true; } - - @Override - public PredatorsHourLookEffect copy() { return new PredatorsHourLookEffect(this); } - - @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - UUID cardId = getTargetPointer().getFirst(game, source); - - // card is no longer in the origin zone, effect can be discarded - if (cardId == null) { this.discard(); } - - return affectedControllerId.equals(authorizedPlayerId) && objectId.equals(cardId); - } -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/s/SiphonInsight.java b/Mage.Sets/src/mage/cards/s/SiphonInsight.java index b8a688c09b6..1c4bae9a501 100644 --- a/Mage.Sets/src/mage/cards/s/SiphonInsight.java +++ b/Mage.Sets/src/mage/cards/s/SiphonInsight.java @@ -7,6 +7,7 @@ import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughManaEffect; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.asthought.MayLookAtTargetCardEffect; import mage.abilities.keyword.FlashbackAbility; import mage.cards.*; import mage.constants.*; @@ -108,7 +109,7 @@ class SiphonInsightEffect extends OneShotEffect { effect.setTargetPointer(new FixedTarget(card.getId(), game)); game.addEffect(effect, source); // For as long as that card remains exiled, you may look at it - effect = new SiphonInsightLookEffect(controller.getId()); + effect = new MayLookAtTargetCardEffect(controller.getId()); effect.setTargetPointer(new FixedTarget(card.getId(), game)); game.addEffect(effect, source); } @@ -205,40 +206,4 @@ class SiphonInsightSpendAnyManaEffect extends AsThoughEffectImpl implements AsTh public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) { return mana.getFirstAvailable(); } -} - -class SiphonInsightLookEffect extends AsThoughEffectImpl { - - private final UUID authorizedPlayerId; - - public SiphonInsightLookEffect(UUID authorizedPlayerId) { - super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit); - this.authorizedPlayerId = authorizedPlayerId; - staticText = "You may look at the cards exiled with {this}"; - } - - private SiphonInsightLookEffect(final SiphonInsightLookEffect effect) { - super(effect); - this.authorizedPlayerId = effect.authorizedPlayerId; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public SiphonInsightLookEffect copy() { - return new SiphonInsightLookEffect(this); - } - - @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - UUID cardId = getTargetPointer().getFirst(game, source); - if (cardId == null) { - this.discard(); // card is no longer in the origin zone, effect can be discarded - } - return affectedControllerId.equals(authorizedPlayerId) - && objectId.equals(cardId); - } -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/t/ThiefOfSanity.java b/Mage.Sets/src/mage/cards/t/ThiefOfSanity.java index 8c5edb69e3f..95f010c0c3c 100644 --- a/Mage.Sets/src/mage/cards/t/ThiefOfSanity.java +++ b/Mage.Sets/src/mage/cards/t/ThiefOfSanity.java @@ -8,6 +8,7 @@ import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughManaEffect; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.asthought.MayLookAtTargetCardEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.*; import mage.constants.*; @@ -105,7 +106,7 @@ class ThiefOfSanityEffect extends OneShotEffect { effect.setTargetPointer(new FixedTarget(card.getId(), game)); game.addEffect(effect, source); // For as long as that card remains exiled, you may look at it - effect = new ThiefOfSanityLookEffect(controller.getId()); + effect = new MayLookAtTargetCardEffect(controller.getId()); effect.setTargetPointer(new FixedTarget(card.getId(), game)); game.addEffect(effect, source); } @@ -211,40 +212,4 @@ class ThiefOfSanitySpendAnyManaEffect extends AsThoughEffectImpl implements AsTh public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) { return mana.getFirstAvailable(); } -} - -class ThiefOfSanityLookEffect extends AsThoughEffectImpl { - - private final UUID authorizedPlayerId; - - public ThiefOfSanityLookEffect(UUID authorizedPlayerId) { - super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit); - this.authorizedPlayerId = authorizedPlayerId; - staticText = "For as long as that card remains exiled, you may look at it"; - } - - private ThiefOfSanityLookEffect(final ThiefOfSanityLookEffect effect) { - super(effect); - this.authorizedPlayerId = effect.authorizedPlayerId; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public ThiefOfSanityLookEffect copy() { - return new ThiefOfSanityLookEffect(this); - } - - @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - UUID cardId = getTargetPointer().getFirst(game, source); - if (cardId == null) { - this.discard(); // card is no longer in the origin zone, effect can be discarded - } - return affectedControllerId.equals(authorizedPlayerId) - && objectId.equals(cardId); - } -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/WildsOfEldraine.java b/Mage.Sets/src/mage/sets/WildsOfEldraine.java index b02e784220b..b0cfbea9f4a 100644 --- a/Mage.Sets/src/mage/sets/WildsOfEldraine.java +++ b/Mage.Sets/src/mage/sets/WildsOfEldraine.java @@ -33,6 +33,7 @@ public final class WildsOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Conceited Witch", 84, Rarity.COMMON, mage.cards.c.ConceitedWitch.class)); cards.add(new SetCardInfo("Cruel Somnophage", 222, Rarity.RARE, mage.cards.c.CruelSomnophage.class)); cards.add(new SetCardInfo("Cursed Courtier", 9, Rarity.UNCOMMON, mage.cards.c.CursedCourtier.class)); + cards.add(new SetCardInfo("Decadent Dragon", 223, Rarity.RARE, mage.cards.d.DecadentDragon.class)); cards.add(new SetCardInfo("Cut In", 125, Rarity.COMMON, mage.cards.c.CutIn.class)); cards.add(new SetCardInfo("Edgewall Inn", 255, Rarity.UNCOMMON, mage.cards.e.EdgewallInn.class)); cards.add(new SetCardInfo("Elvish Archivist", 168, Rarity.RARE, mage.cards.e.ElvishArchivist.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/asthought/MayLookAtTargetCardEffect.java b/Mage/src/main/java/mage/abilities/effects/common/asthought/MayLookAtTargetCardEffect.java new file mode 100644 index 00000000000..182b6fb3ccb --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/asthought/MayLookAtTargetCardEffect.java @@ -0,0 +1,51 @@ +package mage.abilities.effects.common.asthought; + + +import mage.abilities.Ability; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.constants.AsThoughEffectType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; + +import java.util.UUID; + +/** + * @author Susucr + *

+ * An authorized player may look at the target card for as long it remains exiled. + */ +public class MayLookAtTargetCardEffect extends AsThoughEffectImpl { + private final UUID authorizedPlayerId; + + public MayLookAtTargetCardEffect(UUID authorizedPlayerId) { + super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit); + this.authorizedPlayerId = authorizedPlayerId; + staticText = "You may look at the cards exiled with {this}"; + } + + private MayLookAtTargetCardEffect(final MayLookAtTargetCardEffect effect) { + super(effect); + this.authorizedPlayerId = effect.authorizedPlayerId; + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public MayLookAtTargetCardEffect copy() { + return new MayLookAtTargetCardEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + UUID cardId = getTargetPointer().getFirst(game, source); + if (cardId == null) { + this.discard(); // card is no longer in the origin zone, effect can be discarded + } + return affectedControllerId.equals(authorizedPlayerId) + && objectId.equals(cardId); + } +}