From 943ff0d78df0b5e01fa5bdeb0ab82647bfdd3daa Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 14 Jul 2014 09:05:33 +0200 Subject: [PATCH] Some minor formattings. --- .../java/mage/server/game/GameWorker.java | 6 +-- .../legends/TheTabernacleAtPendrellVale.java | 5 ++- .../src/mage/sets/magic2010/LilianaVess.java | 4 +- .../src/mage/sets/tempest/ScrollRack.java | 42 ++++++++++--------- .../mage/abilities/TriggeredAbilities.java | 2 +- .../continious/GainAbilityAllEffect.java | 9 ++++ .../SearchLibraryPutOnLibraryEffect.java | 32 ++++++++------ 7 files changed, 61 insertions(+), 39 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/game/GameWorker.java b/Mage.Server/src/main/java/mage/server/game/GameWorker.java index 1c73af6e051..789ecdee1df 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameWorker.java +++ b/Mage.Server/src/main/java/mage/server/game/GameWorker.java @@ -60,11 +60,11 @@ public class GameWorker implements Callable { result.gameResult(game.getWinner()); game.cleanUp(); } catch (MageException ex) { - logger.fatal("GameWorker mage error [" + game.getId() + "]", ex); + logger.fatal("GameWorker mage error [" + game.getId() + "]" +ex, ex); } catch (Exception e) { - logger.fatal("GameWorker general exception [" + game.getId() + "]", e); + logger.fatal("GameWorker general exception [" + game.getId() + "]" + e, e); } catch (Error err) { - logger.fatal("GameWorker general error [" + game.getId() + "]", err); + logger.fatal("GameWorker general error [" + game.getId() + "]" +err, err); } return null; } diff --git a/Mage.Sets/src/mage/sets/legends/TheTabernacleAtPendrellVale.java b/Mage.Sets/src/mage/sets/legends/TheTabernacleAtPendrellVale.java index d024576e58e..db62ab1af5b 100644 --- a/Mage.Sets/src/mage/sets/legends/TheTabernacleAtPendrellVale.java +++ b/Mage.Sets/src/mage/sets/legends/TheTabernacleAtPendrellVale.java @@ -57,7 +57,7 @@ public class TheTabernacleAtPendrellVale extends CardImpl { // All creatures have "At the beginning of your upkeep, destroy this creature unless you pay {1}." Ability ability = new BeginningOfUpkeepTriggeredAbility(new DestroySourceUnlessPaysEffect(new ManaCostsImpl("{1}")), TargetController.YOU, false); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(ability, Duration.WhileOnBattlefield, new FilterCreaturePermanent()))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(ability, Duration.WhileOnBattlefield, new FilterCreaturePermanent("Creatures")))); } public TheTabernacleAtPendrellVale(final TheTabernacleAtPendrellVale card) { @@ -91,8 +91,9 @@ class DestroySourceUnlessPaysEffect extends OneShotEffect { if (player != null && permanent != null) { if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "?", game)) { cost.clearPaid(); - if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) + if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) { return true; + } } permanent.destroy(source.getSourceId(), game, false); return true; diff --git a/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java b/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java index e2242252da4..cb8f8a217fe 100644 --- a/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java +++ b/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java @@ -60,13 +60,15 @@ public class LilianaVess extends CardImpl { this.subtype.add("Liliana"); this.color.setBlack(true); this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(5)), false)); - + // +1: Target player discards a card. LoyaltyAbility ability1 = new LoyaltyAbility(new DiscardTargetEffect(1), 1); ability1.addTarget(new TargetPlayer()); this.addAbility(ability1); + // -2: Search your library for a card, then shuffle your library and put that card on top of it. this.addAbility(new LoyaltyAbility(new SearchLibraryPutOnLibraryEffect(new TargetCardInLibrary()), -2)); + // -8: Put all creature cards from all graveyards onto the battlefield under your control. this.addAbility(new LoyaltyAbility(new LilianaVessEffect(), -8)); } diff --git a/Mage.Sets/src/mage/sets/tempest/ScrollRack.java b/Mage.Sets/src/mage/sets/tempest/ScrollRack.java index 8fa55251b11..2bc6be045d4 100644 --- a/Mage.Sets/src/mage/sets/tempest/ScrollRack.java +++ b/Mage.Sets/src/mage/sets/tempest/ScrollRack.java @@ -29,9 +29,7 @@ package mage.sets.tempest; import java.util.List; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; @@ -39,7 +37,9 @@ import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.ExileZone; @@ -87,57 +87,59 @@ class ScrollRackEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FilterCard filter = new FilterCard("card in your hand to exile"); - FilterCard filter2 = new FilterCard("card exiled by Scroll Rack to put on top of library"); - Player you = game.getPlayer(source.getControllerId()); - - if (you != null) { - TargetCardInHand target = new TargetCardInHand(0, you.getHand().size(), filter); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { + FilterCard filter = new FilterCard("card in your hand to exile"); + FilterCard filter2 = new FilterCard("(move the window) card exiled by " + sourceObject.getLogName() + " to put on top of library"); + TargetCardInHand target = new TargetCardInHand(0, controller.getHand().size(), filter); target.setRequired(false); int amountExiled = 0; - if (target.canChoose(source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getId(), game)) { + if (target.canChoose(source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { if (!target.getTargets().isEmpty()) { List targets = target.getTargets(); for (UUID targetId : targets) { Card card = game.getCard(targetId); if (card != null) { card.setFaceDown(true); - if (card.moveToExile(source.getSourceId(), "Scroll Rack Exile", source.getId(), game)) { + if (card.moveToExile(source.getSourceId(), sourceObject.getLogName(), source.getSourceId(), game)) { amountExiled++; } } } } } + game.informPlayers(controller.getName() + " exiles " + amountExiled + " card" + (amountExiled == 1 ? " ":"s ") + "face down from his or her hand"); if (amountExiled > 0) { - int count = Math.min(you.getLibrary().size(), amountExiled); + int count = Math.min(controller.getLibrary().size(), amountExiled); for (int i = 0; i < count; i++) { - Card card = you.getLibrary().removeFromTop(game); + Card card = controller.getLibrary().removeFromTop(game); if (card != null) { - card.moveToZone(Zone.HAND, id, game, false); + card.moveToZone(Zone.HAND, source.getSourceId(), game, false); } } } + game.informPlayers(controller.getName() + " moves " + amountExiled + " card" + (amountExiled == 1 ? " ":"s ") + "from library to hand"); TargetCardInExile target2 = new TargetCardInExile(filter2, source.getSourceId()); ExileZone scrollRackExileZone = game.getExile().getExileZone(source.getSourceId()); if (scrollRackExileZone != null) { - while (you.isInGame() && scrollRackExileZone.count(filter, game) > 1) { - you.lookAtCards("exiled cards with " + game.getCard(source.getSourceId()).getName(), scrollRackExileZone, game); - you.choose(Outcome.Neutral, scrollRackExileZone, target2, game); + while (controller.isInGame() && scrollRackExileZone.count(filter, game) > 1) { + controller.lookAtCards("exiled cards with " + sourceObject.getLogName(), scrollRackExileZone, game); + controller.choose(Outcome.Neutral, scrollRackExileZone, target2, game); Card card = game.getCard(target2.getFirstTarget()); if (card != null) { game.getExile().removeCard(card, game); - card.moveToZone(Zone.LIBRARY, source.getId(), game, true); + controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, true, false); } target2.clearChosen(); } if (scrollRackExileZone.count(filter, game) == 1) { Card card = scrollRackExileZone.get(scrollRackExileZone.iterator().next(), game); - card.moveToZone(Zone.LIBRARY, source.getId(), game, true); + controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, true, false); } - return true; } + return true; } return false; } diff --git a/Mage/src/mage/abilities/TriggeredAbilities.java b/Mage/src/mage/abilities/TriggeredAbilities.java index 4ae2d69551a..f56c628e720 100644 --- a/Mage/src/mage/abilities/TriggeredAbilities.java +++ b/Mage/src/mage/abilities/TriggeredAbilities.java @@ -61,7 +61,7 @@ public class TriggeredAbilities extends HashMap { public void checkTriggers(GameEvent event, Game game) { for (TriggeredAbility ability: this.values()) { // for effects like when leaves battlefield use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring) - if (ability.isInUseableZone(game, null, event.getType().equals(GameEvent.EventType.ZONE_CHANGE) ? true :false)) { + if (ability.isInUseableZone(game, null, event.getType().equals(GameEvent.EventType.ZONE_CHANGE))) { MageObject object = null; if (!ability.getZone().equals(Zone.COMMAND) && !game.getState().getZone(ability.getSourceId()).equals(ability.getZone())) { object = game.getShortLivingLKI(ability.getSourceId(), ability.getZone()); diff --git a/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java b/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java index 186b105c169..d58b57609c0 100644 --- a/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java @@ -33,6 +33,8 @@ import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.SubLayer; import mage.abilities.Ability; +import mage.abilities.TriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.effects.ContinuousEffectImpl; import mage.filter.FilterPermanent; import mage.game.Game; @@ -107,6 +109,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl { private void setText() { StringBuilder sb = new StringBuilder(); + boolean quotes = (ability instanceof SimpleActivatedAbility) || (ability instanceof TriggeredAbility); if (excludeSource) { sb.append("Other "); } @@ -124,7 +127,13 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl { sb.append(" gain "); } } + if (quotes) { + sb.append("\""); + } sb.append(ability.getRule()); + if (quotes) { + sb.append("\""); + } if (duration.toString().length() > 0) { sb.append(" ").append(duration.toString()); } diff --git a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutOnLibraryEffect.java b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutOnLibraryEffect.java index 04992a6a300..eb2cc34f25c 100644 --- a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutOnLibraryEffect.java +++ b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutOnLibraryEffect.java @@ -31,6 +31,7 @@ package mage.abilities.effects.common.search; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mage.MageObject; import mage.constants.Outcome; import mage.constants.Zone; import mage.abilities.Ability; @@ -75,32 +76,39 @@ public class SearchLibraryPutOnLibraryEffect extends SearchEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller == null || sourceObject == null) { return false; - if (player.searchLibrary(target, game)) { - List cards = new ArrayList(); + } + if (controller.searchLibrary(target, game)) { + List cards = new ArrayList<>(); for (UUID cardId: (List)target.getTargets()) { - Card card = player.getLibrary().remove(cardId, game); - if (card != null) + Card card = controller.getLibrary().remove(cardId, game); + if (card != null) { cards.add(card); + } } Cards foundCards = new CardsImpl(); foundCards.addAll(cards); if (reveal) { - player.revealCards("Revealed", foundCards, game); + controller.revealCards(sourceObject.getLogName(), foundCards, game); } if (forceShuffle) { - player.shuffleLibrary(game); + controller.shuffleLibrary(game); } - for (Card card: cards) { - card.moveToZone(Zone.LIBRARY, source.getId(), game, true); + if (cards.size() > 0) { + game.informPlayers(controller.getName() + " moves " + cards.size() + " card" + (cards.size() == 1 ? " ":"s ") + "on top of his or her library"); + } + for (Card card: cards) { + card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); } return true; } // shuffle - if (forceShuffle) - player.shuffleLibrary(game); + if (forceShuffle) { + controller.shuffleLibrary(game); + } return false; }