From 5095e644629f526b6be4b6086554fa17f4b14c58 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 5 May 2015 21:48:00 +0200 Subject: [PATCH 01/11] Fixed possible null pointer exception of TargetDefender. --- Mage/src/mage/target/common/TargetDefender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/src/mage/target/common/TargetDefender.java b/Mage/src/mage/target/common/TargetDefender.java index 1fe5435d37..105e6d1276 100644 --- a/Mage/src/mage/target/common/TargetDefender.java +++ b/Mage/src/mage/target/common/TargetDefender.java @@ -197,7 +197,7 @@ public class TargetDefender extends TargetImpl { public boolean canTarget(UUID id, Ability source, Game game) { Player player = game.getPlayer(id); MageObject targetSource = game.getObject(attackerId); - if (player != null) { + if (player != null && source != null) { return notTarget || (player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game)); } Permanent permanent = game.getPermanent(id); From 3e2f992fae59dbde04b9f6ccb2cd863c6e49be4f Mon Sep 17 00:00:00 2001 From: emerald000 Date: Tue, 5 May 2015 17:06:37 -0400 Subject: [PATCH 02/11] Added Sin of the Past. --- Mage.Client/serverlist.txt | 3 +- .../src/mage/sets/ravnica/SinsOfThePast.java | 193 ++++++++++++++++++ 2 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java diff --git a/Mage.Client/serverlist.txt b/Mage.Client/serverlist.txt index 59d6968638..8124af1f93 100644 --- a/Mage.Client/serverlist.txt +++ b/Mage.Client/serverlist.txt @@ -1,5 +1,6 @@ -woogerworks (North America/USA) :xmage.woogerworks.com:17171 XMage.de 1 (Europe/Germany) fast :xmage.de:17171 +woogerworks (North America/USA) :xmage.woogerworks.com:17171 +XMage.info 1 (Europe/France) slow :176.31.186.181:17171 XMage.info 2 (Europe/France) slow :176.31.186.181:17000 IceMage (Europe/Netherlands) :ring0.cc:17171 Seedds Server (Asia) :115.29.203.80:17171 diff --git a/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java b/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java new file mode 100644 index 0000000000..adf2dbb7a1 --- /dev/null +++ b/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java @@ -0,0 +1,193 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.ravnica; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.ExileSourceEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterInstantOrSorceryCard; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.players.Player; +import mage.target.common.TargetCardInGraveyard; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author emerald000 + */ +public class SinsOfThePast extends CardImpl { + + public SinsOfThePast(UUID ownerId) { + super(ownerId, 106, "Sins of the Past", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{B}{B}"); + this.expansionSetCode = "RAV"; + + // Until end of turn, you may cast target instant or sorcery card from your graveyard without paying its mana cost. If that card would be put into your graveyard this turn, exile it instead. Exile Sins of the Past. + this.getSpellAbility().addEffect(new SinsOfThePastEffect()); + this.getSpellAbility().addEffect(new ExileSourceEffect()); + this.getSpellAbility().addTarget(new TargetCardInGraveyard(new FilterInstantOrSorceryCard())); + } + + public SinsOfThePast(final SinsOfThePast card) { + super(card); + } + + @Override + public SinsOfThePast copy() { + return new SinsOfThePast(this); + } +} + +class SinsOfThePastEffect extends OneShotEffect { + + SinsOfThePastEffect() { + super(Outcome.PlayForFree); + this.staticText = "Until end of turn, you may cast target instant or sorcery card from your graveyard without paying its mana cost. If that card would be put into your graveyard this turn, exile it instead"; + } + + SinsOfThePastEffect(final SinsOfThePastEffect effect) { + super(effect); + } + + @Override + public SinsOfThePastEffect copy() { + return new SinsOfThePastEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); + if (card != null) { + ContinuousEffect effect = new SinsOfThePastCastFromGraveyardEffect(); + effect.setTargetPointer(new FixedTarget(card.getId())); + game.addEffect(effect, source); + effect = new SinsOfThePastReplacementEffect(card.getId()); + game.addEffect(effect, source); + return true; + } + return false; + } +} + +class SinsOfThePastCastFromGraveyardEffect extends AsThoughEffectImpl { + + SinsOfThePastCastFromGraveyardEffect() { + super(AsThoughEffectType.PLAY_FROM_NON_HAND_ZONE, Duration.EndOfTurn, Outcome.PlayForFree); + } + + SinsOfThePastCastFromGraveyardEffect(final SinsOfThePastCastFromGraveyardEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public SinsOfThePastCastFromGraveyardEffect copy() { + return new SinsOfThePastCastFromGraveyardEffect(this); + } + + @Override + public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { + /*if (this.getTargetPointer().getFirst(game, source) == null) { + discard(); + return false; + }*/ + + if (sourceId.equals(this.getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { + Player player = game.getPlayer(affectedControllerId); + player.setCastSourceIdWithoutMana(sourceId); + return true; + } + return false; + } +} + +class SinsOfThePastReplacementEffect extends ReplacementEffectImpl { + + private final UUID cardId; + + SinsOfThePastReplacementEffect(UUID cardId) { + super(Duration.EndOfTurn, Outcome.Exile); + this.cardId = cardId; + } + + SinsOfThePastReplacementEffect(final SinsOfThePastReplacementEffect effect) { + super(effect); + this.cardId = effect.cardId; + } + + @Override + public SinsOfThePastReplacementEffect copy() { + return new SinsOfThePastReplacementEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); + Card card = game.getCard(this.cardId); + if (controller != null && card != null) { + controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.STACK, true); + return true; + } + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + game.informPlayers(event.getType().name()); + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + return zEvent.getToZone() == Zone.GRAVEYARD + && zEvent.getTargetId().equals(this.cardId); + } +} From df5c39ed873472a9e9adfa13ef8971ea6bcda2d6 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 5 May 2015 23:13:10 +0200 Subject: [PATCH 03/11] * Inet, the Dreamer - Fixed that the card was not face down in exile and it was not possible to cast the card for free. --- .../sets/planarchaos/IntetTheDreamer.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java b/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java index 4320ea2504..6be8869dd3 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java +++ b/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java @@ -40,6 +40,8 @@ import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.keyword.FlyingAbility; import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.AsThoughEffectType; import mage.constants.CardType; import mage.constants.Duration; @@ -98,10 +100,12 @@ class IntetTheDreamerExileEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - Card card = player.getLibrary().removeFromTop(game); - MageObject sourceObject = game.getObject(source.getSourceId()); + Card card = player.getLibrary().getFromTop(game); + MageObject sourceObject = source.getSourceObject(game); if (card != null && sourceObject != null) { - player.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourceObject.getLogName(), source.getSourceId(), game, Zone.LIBRARY, true); + UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); + player.moveCardToExileWithInfo(card, exileZoneId, sourceObject.getLogName(), source.getSourceId(), game, Zone.LIBRARY, false); + card.setFaceDown(true, game); return true; } } @@ -117,8 +121,8 @@ class IntetTheDreamerExileEffect extends OneShotEffect { class IntetTheDreamerEffect extends AsThoughEffectImpl { public IntetTheDreamerEffect() { - super(AsThoughEffectType.PLAY_FROM_NON_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit); - staticText = "You may play the card from exile eithout paying its mana cost for as long as {this} remains on the battlefield"; + super(AsThoughEffectType.PLAY_FROM_NON_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "You may play the card from exile without paying its mana cost for as long as {this} remains on the battlefield"; } public IntetTheDreamerEffect(final IntetTheDreamerEffect effect) { @@ -137,10 +141,23 @@ class IntetTheDreamerEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - Card card = game.getCard(objectId); - if (affectedControllerId.equals(source.getControllerId()) && card != null && game.getState().getZone(card.getId()) == Zone.EXILED) { - ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); - return zone != null && zone.contains(card.getId()); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + Card card = game.getCard(objectId); + if (affectedControllerId.equals(source.getControllerId()) && card != null && game.getState().getZone(card.getId()) == Zone.EXILED) { + ExileZone zone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter())); + if (zone != null && zone.contains(card.getId())) { + if (controller.chooseUse(outcome, "Look at the card?", game)) { + Cards cards = new CardsImpl(); + cards.add(card); + controller.lookAtCards(sourceObject.getLogName(), cards, game); + return false; + } + controller.setCastSourceIdWithoutMana(objectId); + return true; + } + } } return false; } From c323c5b0b8d23331152b512823f9ae92cd07c69c Mon Sep 17 00:00:00 2001 From: North Date: Sat, 21 Feb 2015 11:57:42 +0100 Subject: [PATCH 04/11] replaced jboss Logger usage with log4j --- .../src/main/java/mage/server/tournament/TournamentManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentManager.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentManager.java index 0c692cb880..3954e63301 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentManager.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentManager.java @@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap; import mage.cards.decks.Deck; import mage.game.tournament.Tournament; import mage.view.TournamentView; -import org.jboss.logging.Logger; +import org.apache.log4j.Logger; /** * From 383b3f3bdb934fe323757778ad4aa081bb9672ab Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 May 2015 08:31:41 +0200 Subject: [PATCH 05/11] Added 2 legacy example decks. --- .../2015/Legacy/Manaless Dredge Example 1.dck | 23 +++++++++++++++++++ .../2015/Legacy/Manaless Dredge Example 2.dck | 22 ++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 1.dck create mode 100644 Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 2.dck diff --git a/Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 1.dck b/Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 1.dck new file mode 100644 index 0000000000..3d9867fc18 --- /dev/null +++ b/Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 1.dck @@ -0,0 +1,23 @@ +3 [RAV:230] Shambling Shell +4 [RAV:167] Golgari Grave-Troll +4 [RAV:87] Golgari Thug +4 [FUT:54] Narcomoeba +4 [TSP:104] Dread Return +4 [PLC:77] Phantasmagorian +3 [ALL:4] Contagion +4 [FUT:174] Dryad Arbor +4 [JUD:62] Cabal Therapy +4 [TOR:65] Ichorid +3 [AVR:106] Griselbrand +4 [RAV:107] Stinkweed Imp +2 [DKA:89] Flayer of the Hatebound +4 [FUT:81] Bridge from Below +4 [5ED:45] Nether Shadow +4 [FUT:90] Street Wraith +1 [BOK:82] Sickening Shoal +SB: 3 [NPH:118] Noxious Revival +SB: 4 [NMS:111] Reverent Silence +SB: 2 [ZEN:229] Verdant Catacombs +SB: 3 [WWK:108] Nature's Claim +SB: 1 [DTK:262] Forest +SB: 2 [BOK:82] Sickening Shoal diff --git a/Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 2.dck b/Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 2.dck new file mode 100644 index 0000000000..063ff8504c --- /dev/null +++ b/Mage.Client/release/sample-decks/2015/Legacy/Manaless Dredge Example 2.dck @@ -0,0 +1,22 @@ +3 [RAV:230] Shambling Shell +4 [RAV:167] Golgari Grave-Troll +4 [RAV:87] Golgari Thug +4 [FUT:54] Narcomoeba +3 [TSP:104] Dread Return +4 [PLC:77] Phantasmagorian +4 [FUT:174] Dryad Arbor +4 [JUD:62] Cabal Therapy +4 [TOR:65] Ichorid +4 [NPH:6] Chancellor of the Annex +2 [AVR:106] Griselbrand +4 [RAV:107] Stinkweed Imp +1 [DKA:89] Flayer of the Hatebound +4 [FUT:81] Bridge from Below +4 [FUT:90] Street Wraith +3 [5ED:45] Nether Shadow +4 [BOK:82] Sickening Shoal +SB: 4 [ZEN:57] Mindbreak Trap +SB: 1 [GPT:101] Angel of Despair +SB: 4 [M11:21] Leyline of Sanctity +SB: 4 [NPH:35] Gitaxian Probe +SB: 2 [ALL:4] Contagion From d4f25e2f9ea5857665de62ba794cf123bd108434 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 May 2015 15:52:37 +0200 Subject: [PATCH 06/11] * Nether Shadow - Fixed that the intervening if clause was not checked on resolution. --- .../mage/sets/limitedalpha/NetherShadow.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Mage.Sets/src/mage/sets/limitedalpha/NetherShadow.java b/Mage.Sets/src/mage/sets/limitedalpha/NetherShadow.java index c595027dfc..35ecf276b6 100644 --- a/Mage.Sets/src/mage/sets/limitedalpha/NetherShadow.java +++ b/Mage.Sets/src/mage/sets/limitedalpha/NetherShadow.java @@ -30,6 +30,7 @@ package mage.sets.limitedalpha; import java.util.UUID; import mage.MageInt; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect; import mage.abilities.keyword.HasteAbility; import mage.cards.Card; @@ -54,7 +55,7 @@ public class NetherShadow extends CardImpl { this.expansionSetCode = "LEA"; this.subtype.add("Spirit"); - this.color.setBlack(true); + this.power = new MageInt(1); this.toughness = new MageInt(1); @@ -75,12 +76,16 @@ public class NetherShadow extends CardImpl { } class NetherShadowTriggerdAbility extends BeginningOfUpkeepTriggeredAbility{ - private static final FilterCard filter = new FilterCreatureCard(); + public NetherShadowTriggerdAbility(){ super(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(), TargetController.YOU, true); } + public NetherShadowTriggerdAbility(final NetherShadowTriggerdAbility effect) { + super(effect); + } + @Override public boolean checkInterveningIfClause(Game game) { Player controller = game.getPlayer(controllerId); @@ -94,7 +99,7 @@ class NetherShadowTriggerdAbility extends BeginningOfUpkeepTriggeredAbility{ } else{ Card card = game.getCard(uuid); - if(card != null && filter.match(card, game)){ + if(card != null && card.getCardType().contains(CardType.CREATURE)){ count++; } } @@ -104,9 +109,14 @@ class NetherShadowTriggerdAbility extends BeginningOfUpkeepTriggeredAbility{ return false; } + @Override + public NetherShadowTriggerdAbility copy() { + return new NetherShadowTriggerdAbility(this); + } + @Override public String getRule() { - return "At the beginning of your upkeep, if {source} is in your graveyard with three or more creature cards above it, you may put {source} onto the battlefield"; + return "At the beginning of your upkeep, if {source} is in your graveyard with three or more creature cards above it, you may put {source} onto the battlefield."; } From 99d208a2d93e5fba8d45c9754c729b4078ff38c0 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 May 2015 15:53:27 +0200 Subject: [PATCH 07/11] * Phantasmagorian - Fixed wrong tooltip text for discard costs. --- Mage.Sets/src/mage/sets/planarchaos/Phantasmagorian.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/sets/planarchaos/Phantasmagorian.java b/Mage.Sets/src/mage/sets/planarchaos/Phantasmagorian.java index f557a1da4c..630a7fa050 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/Phantasmagorian.java +++ b/Mage.Sets/src/mage/sets/planarchaos/Phantasmagorian.java @@ -66,7 +66,7 @@ public class Phantasmagorian extends CardImpl { // When you cast Phantasmagorian, any player may discard three cards. If a player does, counter Phantasmagorian. this.addAbility(new CastSourceTriggeredAbility(new CounterSourceEffect())); // Discard three cards: Return Phantasmagorian from your graveyard to your hand. - this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new DiscardTargetCost(new TargetCardInHand(3, 3, new FilterCard())))); + this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new DiscardTargetCost(new TargetCardInHand(3, 3, new FilterCard("three cards"))))); } public Phantasmagorian(final Phantasmagorian card) { From 607680b78a28a1f8ba2ba6e5f3cdb3db5a115ce3 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 May 2015 15:56:11 +0200 Subject: [PATCH 08/11] Added source object name to effect rule text in choice window of replacment effects to select the order the effects resolve. --- Mage/src/mage/abilities/effects/ContinuousEffects.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/src/mage/abilities/effects/ContinuousEffects.java b/Mage/src/mage/abilities/effects/ContinuousEffects.java index 7b2f8722ca..2ef6f8f9e1 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffects.java @@ -1084,7 +1084,7 @@ public class ContinuousEffects implements Serializable { for (Ability ability :entry.getValue()) { MageObject object = game.getObject(ability.getSourceId()); if (object != null) { - texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), ability.getRule(object.getLogName())); + texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), object.getLogName() +": " + ability.getRule(object.getLogName())); } else { texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), entry.getKey().getText(null)); } From 5dbd5401fa21eecb768f321564f0598f00c4240a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 May 2015 15:57:39 +0200 Subject: [PATCH 09/11] * Dredge Ability - The effect is no longer active (e.g. for choosing the order of resolution) if not enough cards left in the library. --- Mage/src/mage/abilities/keyword/DredgeAbility.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Mage/src/mage/abilities/keyword/DredgeAbility.java b/Mage/src/mage/abilities/keyword/DredgeAbility.java index e24656c1b0..3bf8d0b04b 100644 --- a/Mage/src/mage/abilities/keyword/DredgeAbility.java +++ b/Mage/src/mage/abilities/keyword/DredgeAbility.java @@ -99,8 +99,9 @@ class DredgeEffect extends ReplacementEffectImpl { if (player != null && player.getLibrary().size() >= amount && player.chooseUse(outcome, new StringBuilder("Dredge ").append(sourceCard.getName()). append("? (").append(amount).append(" cards go from top of library to graveyard)").toString(), game)) { - if (!game.isSimulation()) + if (!game.isSimulation()) { game.informPlayers(new StringBuilder(player.getName()).append(" dreges ").append(sourceCard.getName()).toString()); + } Cards cardsToGrave = new CardsImpl(); cardsToGrave.addAll(player.getLibrary().getTopCards(game, amount)); player.moveCardsToGraveyardWithInfo(cardsToGrave, source, game, Zone.LIBRARY); @@ -118,6 +119,10 @@ class DredgeEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - return event.getPlayerId().equals(source.getControllerId()); + if (event.getPlayerId().equals(source.getControllerId())) { + Player controller = game.getPlayer(source.getControllerId()); + return controller != null && controller.getLibrary().size() >= amount; + } + return false; } } From bc990ad24aca60746964fc7a9e059c48dba99d2f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 May 2015 15:58:18 +0200 Subject: [PATCH 10/11] * Some minor fixed to tooltip texts. --- .../src/mage/sets/gatecrash/BalustradeSpy.java | 15 ++++++++------- Mage.Sets/src/mage/sets/torment/Ichorid.java | 3 +-- .../abilities/effects/common/DoIfCostPaid.java | 9 +++++++-- ...urnSourceFromGraveyardToBattlefieldEffect.java | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/sets/gatecrash/BalustradeSpy.java b/Mage.Sets/src/mage/sets/gatecrash/BalustradeSpy.java index 636e8649aa..6d5cda6300 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/BalustradeSpy.java +++ b/Mage.Sets/src/mage/sets/gatecrash/BalustradeSpy.java @@ -33,6 +33,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.effects.OneShotEffect; @@ -56,7 +57,6 @@ public class BalustradeSpy extends CardImpl { this.subtype.add("Vampire"); this.subtype.add("Rogue"); - this.color.setBlack(true); this.power = new MageInt(2); this.toughness = new MageInt(3); @@ -97,24 +97,25 @@ class BalustradeSpyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); - if (player == null) { + Player controller = game.getPlayer(getTargetPointer().getFirst(game, source)); + MageObject sourceObject = source.getSourceObject(game); + if (controller == null || sourceObject == null) { return false; } CardsImpl cards = new CardsImpl(); boolean landFound = false; - while (player.getLibrary().size() > 0 && !landFound) { - Card card = player.getLibrary().removeFromTop(game); + while (controller.getLibrary().size() > 0 && !landFound) { + Card card = controller.getLibrary().removeFromTop(game); if (card != null) { cards.add(card); - card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false); if (card.getCardType().contains(CardType.LAND)) { landFound = true; } } } if (!cards.isEmpty()) { - player.revealCards("Balustrade Spy", cards, game); + controller.moveCardsToGraveyardWithInfo(cards, source, game, Zone.LIBRARY); + controller.revealCards(sourceObject.getLogName(), cards, game); return true; } return true; diff --git a/Mage.Sets/src/mage/sets/torment/Ichorid.java b/Mage.Sets/src/mage/sets/torment/Ichorid.java index ab02a3e834..28187951a6 100644 --- a/Mage.Sets/src/mage/sets/torment/Ichorid.java +++ b/Mage.Sets/src/mage/sets/torment/Ichorid.java @@ -63,7 +63,6 @@ public class Ichorid extends CardImpl { this.expansionSetCode = "TOR"; this.subtype.add("Horror"); - this.color.setBlack(true); this.power = new MageInt(3); this.toughness = new MageInt(1); @@ -118,7 +117,7 @@ class IchoridTriggerdAbility extends BeginningOfUpkeepTriggeredAbility{ @Override public String getRule() { - return "At the beginning of your upkeep, if {source} is in your graveyard, you may exile a black creature card other than {source} from your graveyard. If you do, return {source} to the battlefield"; + return "At the beginning of your upkeep, if {source} is in your graveyard, you may exile a black creature card other than {source} from your graveyard. If you do, return {source} to the battlefield."; } } diff --git a/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java b/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java index edae3a4ba2..344e6aadc6 100644 --- a/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java +++ b/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java @@ -47,7 +47,11 @@ public class DoIfCostPaid extends OneShotEffect { if (player != null && mageObject != null) { String message; if (chooseUseText == null) { - message = new StringBuilder(getCostText()).append(" and ").append(executingEffects.getText(source.getModes().getMode())).append("?").toString(); + String effectText = executingEffects.getText(source.getModes().getMode()); + if (effectText.length() > 0 && effectText.charAt(effectText.length()-1)=='.') { + effectText = effectText.substring(0, effectText.length()-1); + } + message = getCostText() +" and " + effectText + "?"; } else { message = chooseUseText; } @@ -82,13 +86,14 @@ public class DoIfCostPaid extends OneShotEffect { if (!staticText.isEmpty()) { return staticText; } - return new StringBuilder("you may ").append(getCostText()).append(". If you do, ").append(executingEffects.getText(mode)).toString(); + return "you may " + getCostText() + ". If you do, " + executingEffects.getText(mode); } protected String getCostText() { StringBuilder sb = new StringBuilder(); String costText = cost.getText(); if (costText != null + && !costText.toLowerCase().startsWith("exile") && !costText.toLowerCase().startsWith("discard") && !costText.toLowerCase().startsWith("sacrifice") && !costText.toLowerCase().startsWith("remove") diff --git a/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java b/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java index f5ef7cf47c..a87f0360ff 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java @@ -96,7 +96,7 @@ public class ReturnSourceFromGraveyardToBattlefieldEffect extends OneShotEffect } private void setText() { - StringBuilder sb = new StringBuilder("Return {this} from your graveyard to the battlefield"); + StringBuilder sb = new StringBuilder("return {this} from your graveyard to the battlefield"); if (tapped) { sb.append(" tapped"); } From 4cf21739c488046196daa525ae70504306e9a465 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 May 2015 16:58:14 +0200 Subject: [PATCH 11/11] * Saved position and size of choice window during a game session. --- .../mage/client/dialog/PickChoiceDialog.java | 16 ++++-- .../main/java/mage/client/game/GamePanel.java | 26 +++------ .../mage/client/util/gui/GuiDisplayUtil.java | 5 +- .../mage/client/util/gui/MageDialogState.java | 56 +++++++++++++++++++ 4 files changed, 76 insertions(+), 27 deletions(-) create mode 100644 Mage.Client/src/main/java/mage/client/util/gui/MageDialogState.java diff --git a/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java index 818dc2fd96..dbf884f23d 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java @@ -42,6 +42,7 @@ import mage.choices.Choice; import mage.client.MageFrame; import mage.client.util.SettingsManager; import mage.client.util.gui.GuiDisplayUtil; +import mage.client.util.gui.MageDialogState; /** * @@ -57,7 +58,7 @@ public class PickChoiceDialog extends MageDialog { Choice choice; boolean autoSelect; - public void showDialog(Choice choice, UUID objectId) { + public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState) { this.lblMessage.setText("" + choice.getMessage()); this.choice = choice; this.autoSelect = false; @@ -77,10 +78,15 @@ public class PickChoiceDialog extends MageDialog { } MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); - - Point centered = SettingsManager.getInstance().getComponentPosition(getWidth(), getHeight()); - this.setLocation(centered.x, centered.y); - GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this); + if (mageDialogState != null) { + mageDialogState.setStateToDialog(this); + + } else { + Point centered = SettingsManager.getInstance().getComponentPosition(getWidth(), getHeight()); + this.setLocation(centered.x, centered.y); + GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this); + } + this.setVisible(true); } diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index a1ba349b4e..396ae4a322 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -99,6 +99,7 @@ import mage.client.util.Config; import mage.client.util.GameManager; import mage.client.util.audio.AudioManager; import mage.client.util.gui.ArrowBuilder; +import mage.client.util.gui.MageDialogState; import mage.constants.Constants; import mage.constants.EnlargeMode; import mage.constants.PhaseStep; @@ -154,15 +155,16 @@ public final class GamePanel extends javax.swing.JPanel { private String chosenHandKey = "You"; private boolean smallMode = false; private boolean initialized = false; - private int lastUpdatedTurn; + private boolean menuNameSet = false; private boolean handCardsOfOpponentAvailable = false; private Map loadedCards = new HashMap<>(); - private int storedHeight; - + private int storedHeight; private Map hoverButtons; + + private MageDialogState choiceWindowState; public GamePanel() { initComponents(); @@ -455,7 +457,6 @@ public final class GamePanel extends javax.swing.JPanel { public synchronized void init(GameView game) { addPlayers(game); updateGame(game); - lastUpdatedTurn = game.getTurn(); } private void addPlayers(GameView game) { @@ -795,27 +796,13 @@ public final class GamePanel extends javax.swing.JPanel { } private void showRevealed(GameView game) { -// List toRemove = new ArrayList(); -// toRemove.addAll(revealed.keySet()); -// for (ShowCardsDialog reveal: revealed.values()) { -// reveal.clearReloaded(); // seems not to be used -// } for (RevealedView reveal: game.getRevealed()) { if (!revealed.containsKey(reveal.getName())) { ShowCardsDialog newReveal = new ShowCardsDialog(); revealed.put(reveal.getName(), newReveal); } revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), CardsViewUtil.convertSimple(reveal.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false); -// toRemove.add(reveal.getName()); } -// for (String revealName: toRemove) { -// ShowCardsDialog revealDialog = revealed.get(revealName); -// if (revealDialog != null) { -// revealed.remove(revealName); -// revealDialog.cleanUp(); -// revealDialog.removeDialog(); -// } -// } } private void showLookedAt(GameView game) { @@ -967,7 +954,7 @@ public final class GamePanel extends javax.swing.JPanel { public void getChoice(Choice choice, UUID objectId) { hideAll(); PickChoiceDialog pickChoice = new PickChoiceDialog(); - pickChoice.showDialog(choice, objectId); + pickChoice.showDialog(choice, objectId,choiceWindowState); if (choice.isKeyChoice()) { if (pickChoice.isAutoSelect()) { session.sendPlayerString(gameId, "#" + choice.getChoiceKey()); @@ -977,6 +964,7 @@ public final class GamePanel extends javax.swing.JPanel { } else { session.sendPlayerString(gameId, choice.getChoice()); } + choiceWindowState = new MageDialogState(pickChoice); pickChoice.removeDialog(); } diff --git a/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java b/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java index 51be991cda..17e64cc600 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java @@ -12,10 +12,9 @@ import org.mage.card.arcane.UI; import javax.swing.*; import java.awt.*; -import java.net.URL; import java.util.ArrayList; +import mage.client.dialog.MageDialog; import mage.constants.Rarity; -import org.mage.plugins.card.utils.impl.ImageManagerImpl; public class GuiDisplayUtil { private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15); @@ -27,7 +26,7 @@ public class GuiDisplayUtil { public int basicTextLength; public ArrayList lines; } - + public static JXPanel getDescription(CardView card, int width, int height) { JXPanel descriptionPanel = new JXPanel(); diff --git a/Mage.Client/src/main/java/mage/client/util/gui/MageDialogState.java b/Mage.Client/src/main/java/mage/client/util/gui/MageDialogState.java new file mode 100644 index 0000000000..41b40a8d69 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/util/gui/MageDialogState.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.client.util.gui; + +import java.awt.Dimension; +import mage.client.dialog.MageDialog; + +/** + * Holds the position and size of MageDialogs. + * + * @author LevelX2 + */ +public class MageDialogState { + + Dimension dimension; + int xPos; + int yPos; + + public MageDialogState(MageDialog mageDialog) { + this.dimension = mageDialog.getSize(); + this.xPos = mageDialog.getX(); + this.yPos = mageDialog.getY(); + } + + public boolean setStateToDialog(MageDialog mageDialog) { + mageDialog.setSize(dimension); + mageDialog.setLocation(xPos, yPos); + GuiDisplayUtil.keepComponentInsideScreen(xPos, yPos, mageDialog); + return true; + } +} \ No newline at end of file