From 085211035f0f1941a734564e8ae29c42883d2515 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 18 May 2019 22:24:37 +0400 Subject: [PATCH] * Ugin, the Ineffable - improved +1 ability (one window for all exiled cards, card's id in lookup window); --- .../src/mage/cards/u/UginTheIneffable.java | 34 +++++++++++++------ .../main/java/mage/players/PlayerImpl.java | 5 +-- Mage/src/main/java/mage/util/CardUtil.java | 3 ++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/cards/u/UginTheIneffable.java b/Mage.Sets/src/mage/cards/u/UginTheIneffable.java index 18a511fffa..3a6d1670c7 100644 --- a/Mage.Sets/src/mage/cards/u/UginTheIneffable.java +++ b/Mage.Sets/src/mage/cards/u/UginTheIneffable.java @@ -1,15 +1,20 @@ package mage.cards.u; +import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.InfoEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect; import mage.cards.Card; import mage.cards.CardImpl; @@ -27,13 +32,11 @@ import mage.game.permanent.token.UginTheIneffableToken; import mage.players.Player; import mage.target.TargetPermanent; import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; + import java.util.HashSet; import java.util.Set; import java.util.UUID; -import mage.abilities.effects.AsThoughEffectImpl; -import mage.abilities.effects.common.CreateTokenEffect; -import mage.abilities.effects.common.InfoEffect; -import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import static mage.constants.Outcome.Benefit; @@ -101,20 +104,31 @@ class UginTheIneffableEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Player player = game.getPlayer(source.getControllerId()); - if (player == null) { + MageObject sourceObject = source.getSourceObject(game); + if (player == null || sourceObject == null) { return false; } + Card card = player.getLibrary().getFromTop(game); - player.lookAtCards(sourcePermanent.getIdName(), card, game); - player.moveCards(card, Zone.EXILED, source, game); - card.turnFaceDown(game, source.getControllerId()); + if (card == null) { + return false; + } + + // exile and look + UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); + if (player.moveCardsToExile(card, source, game, false, exileZoneId, sourceObject.getIdName() + " (" + player.getName() + ")")) { + card.turnFaceDown(game, source.getControllerId()); + player.lookAtCards(player.getName() + " - " + card.getIdName() + " - " + CardUtil.sdf.format(System.currentTimeMillis()), card, game); + } + + // create token Set tokenObjs = new HashSet<>(); CreateTokenEffect effect = new CreateTokenEffect(new UginTheIneffableToken()); effect.apply(game, source); - for (UUID addedTokenId : effect.getLastAddedTokenIds()) { + // with return ability + for (UUID addedTokenId : effect.getLastAddedTokenIds()) { // display referenced exiled face-down card on token SimpleStaticAbility sa = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("Referenced object: " + card.getId().toString().substring(0, 3))); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 9df46c83ea..dce0116701 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -67,7 +67,6 @@ import mage.util.RandomUtil; import org.apache.log4j.Logger; import java.io.Serializable; -import java.text.SimpleDateFormat; import java.util.*; import java.util.Map.Entry; @@ -75,8 +74,6 @@ public abstract class PlayerImpl implements Player, Serializable { private static final Logger logger = Logger.getLogger(PlayerImpl.class); - private static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS"); - /** * Used to cancel waiting requests send to the player */ @@ -3471,7 +3468,7 @@ public abstract class PlayerImpl implements Player, Serializable { String lookNo = abilitiesToActivate > 0 ? "No, activate ability" : "No"; if (chooseUse(Outcome.Benefit, lookMessage, "", lookYes, lookNo, null, game)) { Cards cards = new CardsImpl(card); - this.lookAtCards(getName() + " - " + sdf.format(System.currentTimeMillis()), cards, game); + this.lookAtCards(getName() + " - " + card.getIdName() + " - " + CardUtil.sdf.format(System.currentTimeMillis()), cards, game); return true; } } diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index 94d2da8d54..851d83c8de 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -14,6 +14,7 @@ import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; import mage.util.functions.CopyTokenFunction; +import java.text.SimpleDateFormat; import java.util.UUID; /** @@ -29,6 +30,8 @@ public final class CardUtil { static final String[] ordinalStrings = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eightth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth"}; + public static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS"); + /** * Increase spell or ability cost to be paid. *