diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java index 418fd2d632d..a302664d68c 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -1199,10 +1199,9 @@ class TableTableModel extends AbstractTableModel { // set the column width from saved value or defaults int[] widths = Util.getIntArrayFromString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, null)); - int lengthW = widths.length; int i = 0; for (int width : defaultColumnsWidth) { - if (lengthW > i) { + if (widths != null && widths.length > i) { width = widths[i]; } TableColumn column = table.getColumnModel().getColumn(i++); diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/ShelteredAerie.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/ShelteredAerie.java index a87b81eca49..e4c44edaa09 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/ShelteredAerie.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/ShelteredAerie.java @@ -31,11 +31,11 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.Effect; import mage.abilities.effects.common.AddManaOfAnyColorEffect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; -import mage.abilities.mana.AnyColorManaAbility; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; import mage.constants.AttachmentType; @@ -66,7 +66,9 @@ public class ShelteredAerie extends CardImpl { // Enchanted land has "{T}: Add two mana of any one color to your mana pool." Ability gainedAbility = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost()); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA))); + Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA); + effect.setText("Enchanted land has \"{T}: Add two mana of any one color to your mana pool.\""); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); } diff --git a/Mage.Sets/src/mage/sets/fifthedition/Pox.java b/Mage.Sets/src/mage/sets/fifthedition/Pox.java index 71588c72c22..33d85181027 100644 --- a/Mage.Sets/src/mage/sets/fifthedition/Pox.java +++ b/Mage.Sets/src/mage/sets/fifthedition/Pox.java @@ -34,15 +34,15 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; -import mage.filter.common.FilterCreaturePermanent; -import mage.filter.common.FilterLandPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterControlledLandPermanent; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.Target; -import mage.target.common.TargetCreaturePermanent; -import mage.target.common.TargetLandPermanent; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetControlledPermanent; /** * @@ -104,7 +104,7 @@ class PoxEffect extends OneShotEffect { if (player != null) { int cardsToDiscard = (int) Math.ceil(player.getHand().size() / 3.0); if (cardsToDiscard > 0) { - player.discard(cardsToDiscard, source, game); + player.discard(cardsToDiscard, false, source, game); } } } @@ -112,12 +112,11 @@ class PoxEffect extends OneShotEffect { for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { - FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.add(new ControllerIdPredicate(playerId)); - int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3.0); + FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); + int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 3.0); if (creaturesToSacrifice > 0) { - Target target = new TargetCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true); - target.choose(Outcome.Sacrifice, playerId, source.getSourceId(), game); + Target target = new TargetControlledCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true); + target.chooseTarget(Outcome.Sacrifice, playerId, source, game); for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); if (permanent != null) { @@ -131,12 +130,11 @@ class PoxEffect extends OneShotEffect { for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { - FilterLandPermanent filter = new FilterLandPermanent(); - filter.add(new ControllerIdPredicate(playerId)); - int landsToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3.0); + FilterControlledLandPermanent filter = new FilterControlledLandPermanent(); + int landsToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 3.0); if (landsToSacrifice > 0) { - Target target = new TargetLandPermanent(landsToSacrifice, landsToSacrifice, filter, true); - target.choose(Outcome.Sacrifice, playerId, source.getSourceId(), game); + Target target = new TargetControlledPermanent(landsToSacrifice, landsToSacrifice, filter, true); + target.chooseTarget(Outcome.Sacrifice, playerId, source, game); for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); if (permanent != null) { diff --git a/Mage.Sets/src/mage/sets/guildpact/CerebralVortex.java b/Mage.Sets/src/mage/sets/guildpact/CerebralVortex.java new file mode 100644 index 00000000000..46db0fa845b --- /dev/null +++ b/Mage.Sets/src/mage/sets/guildpact/CerebralVortex.java @@ -0,0 +1,149 @@ +/* + * 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.guildpact; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawCardTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.watchers.Watcher; + +/** + * + * @author emerald000 + */ +public class CerebralVortex extends CardImpl { + + public CerebralVortex(UUID ownerId) { + super(ownerId, 107, "Cerebral Vortex", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{1}{U}{R}"); + this.expansionSetCode = "GPT"; + + // Target player draws two cards, then Cerebral Vortex deals damage to that player equal to the number of cards he or she has drawn this turn. + this.getSpellAbility().addEffect(new DrawCardTargetEffect(2)); + this.getSpellAbility().addEffect(new CerebralVortexEffect()); + this.getSpellAbility().addTarget(new TargetPlayer()); + this.getSpellAbility().addWatcher(new CerebralVortexWatcher()); + } + + public CerebralVortex(final CerebralVortex card) { + super(card); + } + + @Override + public CerebralVortex copy() { + return new CerebralVortex(this); + } +} + +class CerebralVortexEffect extends OneShotEffect { + + CerebralVortexEffect() { + super(Outcome.Damage); + this.staticText = ", then Cerebral Vortex deals damage to that player equal to the number of cards he or she has drawn this turn"; + } + + CerebralVortexEffect(final CerebralVortexEffect effect) { + super(effect); + } + + @Override + public CerebralVortexEffect copy() { + return new CerebralVortexEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); + if (targetPlayer != null) { + CerebralVortexWatcher watcher = (CerebralVortexWatcher) game.getState().getWatchers().get("CerebralVortexWatcher"); + if (watcher != null) { + targetPlayer.damage(watcher.getDraws(targetPlayer.getId()), source.getSourceId(), game, false, true); + return true; + } + } + return false; + } +} + +class CerebralVortexWatcher extends Watcher { + + private final Map draws = new HashMap<>(); + + CerebralVortexWatcher() { + super("CerebralVortexWatcher", WatcherScope.GAME); + } + + CerebralVortexWatcher(final CerebralVortexWatcher watcher) { + super(watcher); + for (Entry entry: watcher.draws.entrySet()) { + draws.put(entry.getKey(), entry.getValue()); + } + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == EventType.DREW_CARD) { + int count = 1; + if (draws.containsKey(event.getPlayerId())) { + count += draws.get(event.getPlayerId()); + } + draws.put(event.getPlayerId(), count); + } + } + + @Override + public void reset() { + super.reset(); + draws.clear(); + } + + public int getDraws(UUID playerId) { + if (draws.containsKey(playerId)) { + return draws.get(playerId); + } + return 0; + } + + @Override + public CerebralVortexWatcher copy() { + return new CerebralVortexWatcher(this); + } +} diff --git a/Mage.Sets/src/mage/sets/lorwyn/SowerOfTemptation.java b/Mage.Sets/src/mage/sets/lorwyn/SowerOfTemptation.java index ae244127086..a6f35a6c4d6 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/SowerOfTemptation.java +++ b/Mage.Sets/src/mage/sets/lorwyn/SowerOfTemptation.java @@ -32,7 +32,6 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.condition.common.SourceOnBattelfieldCondition; -import mage.abilities.condition.common.SourceOnBattlefieldControlUnchangedCondition; import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect; @@ -56,7 +55,7 @@ public class SowerOfTemptation extends CardImpl { this.expansionSetCode = "LRW"; this.subtype.add("Faerie"); this.subtype.add("Wizard"); - this.color.setBlue(true); + this.power = new MageInt(2); this.toughness = new MageInt(2); @@ -89,7 +88,7 @@ class SowerOfTemptationGainControlEffect extends OneShotEffect { public SowerOfTemptationGainControlEffect() { super(Outcome.GainControl); - this.staticText = "gain control of target creature for as long as Sower of Temptation remains on the battlefield"; + this.staticText = "gain control of target creature for as long as {this} remains on the battlefield"; } public SowerOfTemptationGainControlEffect(final SowerOfTemptationGainControlEffect effect) { @@ -106,7 +105,7 @@ class SowerOfTemptationGainControlEffect extends OneShotEffect { ConditionalContinuousEffect effect = new ConditionalContinuousEffect( new GainControlTargetEffect(Duration.Custom), new SourceOnBattelfieldCondition(), - "gain control of target creature for as long as Sower of Temptation remains on the battlefield"); + "gain control of target creature for as long as {this} remains on the battlefield"); game.addEffect(effect, source); return false; } diff --git a/Mage.Sets/src/mage/sets/shardsofalara/DragonFodder.java b/Mage.Sets/src/mage/sets/shardsofalara/DragonFodder.java index 8a1372315a8..c1b33de6731 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/DragonFodder.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/DragonFodder.java @@ -44,8 +44,6 @@ public class DragonFodder extends CardImpl { super(ownerId, 97, "Dragon Fodder", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{R}"); this.expansionSetCode = "ALA"; - this.color.setRed(true); - // Put two 1/1 red Goblin creature tokens onto the battlefield. this.getSpellAbility().addEffect(new CreateTokenEffect(new GoblinToken(), 2)); } diff --git a/Mage.Tests/src/test/java/org/mage/test/multiplayer/ControlChangeTest.java b/Mage.Tests/src/test/java/org/mage/test/multiplayer/ControlChangeTest.java new file mode 100644 index 00000000000..b85688d1b98 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/multiplayer/ControlChangeTest.java @@ -0,0 +1,82 @@ +/* + * 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 org.mage.test.multiplayer; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Assert; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestMultiPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class ControlChangeTest extends CardTestMultiPlayerBase { + + /** + * Checks that the change of max hand size changes if the control + * of Jin-Gitaxias, Core Augur changes. + * http://www.slightlymagic.net/forum/viewtopic.php?f=70&t=16910&p=177481#p177481 + */ + @Test + public void testSimple() { + // Each opponent's maximum hand size is reduced by seven. + addCard(Zone.BATTLEFIELD, playerA, "Jin-Gitaxias, Core Augur"); + + addCard(Zone.BATTLEFIELD, playerB, "Island",4); + addCard(Zone.HAND, playerB, "Sower of Temptation"); + addCard(Zone.HAND, playerB, "Leyline of Anticipation"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Sower of Temptation"); + addTarget(playerB, "Jin-Gitaxias, Core Augur"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertLife(playerC, 20); + assertLife(playerD, 20); + + assertPermanentCount(playerB, "Leyline of Anticipation", 1); + + assertHandCount(playerB, "Sower of Temptation", 0); + assertGraveyardCount(playerB, "Sower of Temptation", 0); + + assertPermanentCount(playerB, "Jin-Gitaxias, Core Augur", 1); + assertPermanentCount(playerB, "Sower of Temptation", 1); + + Assert.assertEquals(0, playerA.getMaxHandSize()); + Assert.assertEquals(7, playerB.getMaxHandSize()); + Assert.assertEquals(0, playerC.getMaxHandSize()); + Assert.assertEquals(7, playerD.getMaxHandSize()); + } + +} \ No newline at end of file diff --git a/Mage/src/mage/game/permanent/token/GoblinToken.java b/Mage/src/mage/game/permanent/token/GoblinToken.java index 36021d30df4..6b37933e5d2 100644 --- a/Mage/src/mage/game/permanent/token/GoblinToken.java +++ b/Mage/src/mage/game/permanent/token/GoblinToken.java @@ -40,7 +40,7 @@ import mage.constants.CardType; public class GoblinToken extends Token { static List imageSetCodes = Arrays.asList( - "M10", "C14", "KTK", "EVG" + "M10", "C14", "KTK", "EVG", "DTK" ); public GoblinToken() {