This commit is contained in:
Jean-Baptiste Onofré 2015-04-28 07:18:57 +02:00
commit 1dd0289044
8 changed files with 253 additions and 26 deletions

View file

@ -1199,10 +1199,9 @@ class TableTableModel extends AbstractTableModel {
// set the column width from saved value or defaults // set the column width from saved value or defaults
int[] widths = Util.getIntArrayFromString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, null)); int[] widths = Util.getIntArrayFromString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, null));
int lengthW = widths.length;
int i = 0; int i = 0;
for (int width : defaultColumnsWidth) { for (int width : defaultColumnsWidth) {
if (lengthW > i) { if (widths != null && widths.length > i) {
width = widths[i]; width = widths[i];
} }
TableColumn column = table.getColumnModel().getColumn(i++); TableColumn column = table.getColumnModel().getColumn(i++);

View file

@ -31,11 +31,11 @@ import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddManaOfAnyColorEffect; import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.AnyColorManaAbility;
import mage.abilities.mana.SimpleManaAbility; import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.AttachmentType; 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." // 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()); 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));
} }

View file

@ -34,15 +34,15 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.Target; import mage.target.Target;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetLandPermanent; import mage.target.common.TargetControlledPermanent;
/** /**
* *
@ -104,7 +104,7 @@ class PoxEffect extends OneShotEffect {
if (player != null) { if (player != null) {
int cardsToDiscard = (int) Math.ceil(player.getHand().size() / 3.0); int cardsToDiscard = (int) Math.ceil(player.getHand().size() / 3.0);
if (cardsToDiscard > 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()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent(); FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(new ControllerIdPredicate(playerId)); int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 3.0);
int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3.0);
if (creaturesToSacrifice > 0) { if (creaturesToSacrifice > 0) {
Target target = new TargetCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true); Target target = new TargetControlledCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true);
target.choose(Outcome.Sacrifice, playerId, source.getSourceId(), game); target.chooseTarget(Outcome.Sacrifice, playerId, source, game);
for (UUID permanentId : target.getTargets()) { for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId); Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) { if (permanent != null) {
@ -131,12 +130,11 @@ class PoxEffect extends OneShotEffect {
for (UUID playerId : controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
FilterLandPermanent filter = new FilterLandPermanent(); FilterControlledLandPermanent filter = new FilterControlledLandPermanent();
filter.add(new ControllerIdPredicate(playerId)); int landsToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 3.0);
int landsToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3.0);
if (landsToSacrifice > 0) { if (landsToSacrifice > 0) {
Target target = new TargetLandPermanent(landsToSacrifice, landsToSacrifice, filter, true); Target target = new TargetControlledPermanent(landsToSacrifice, landsToSacrifice, filter, true);
target.choose(Outcome.Sacrifice, playerId, source.getSourceId(), game); target.chooseTarget(Outcome.Sacrifice, playerId, source, game);
for (UUID permanentId : target.getTargets()) { for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId); Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) { if (permanent != null) {

View file

@ -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<UUID, Integer> draws = new HashMap<>();
CerebralVortexWatcher() {
super("CerebralVortexWatcher", WatcherScope.GAME);
}
CerebralVortexWatcher(final CerebralVortexWatcher watcher) {
super(watcher);
for (Entry<UUID, Integer> 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);
}
}

View file

@ -32,7 +32,6 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.SourceOnBattelfieldCondition; import mage.abilities.condition.common.SourceOnBattelfieldCondition;
import mage.abilities.condition.common.SourceOnBattlefieldControlUnchangedCondition;
import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect;
@ -56,7 +55,7 @@ public class SowerOfTemptation extends CardImpl {
this.expansionSetCode = "LRW"; this.expansionSetCode = "LRW";
this.subtype.add("Faerie"); this.subtype.add("Faerie");
this.subtype.add("Wizard"); this.subtype.add("Wizard");
this.color.setBlue(true);
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
@ -89,7 +88,7 @@ class SowerOfTemptationGainControlEffect extends OneShotEffect {
public SowerOfTemptationGainControlEffect() { public SowerOfTemptationGainControlEffect() {
super(Outcome.GainControl); 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) { public SowerOfTemptationGainControlEffect(final SowerOfTemptationGainControlEffect effect) {
@ -106,7 +105,7 @@ class SowerOfTemptationGainControlEffect extends OneShotEffect {
ConditionalContinuousEffect effect = new ConditionalContinuousEffect( ConditionalContinuousEffect effect = new ConditionalContinuousEffect(
new GainControlTargetEffect(Duration.Custom), new GainControlTargetEffect(Duration.Custom),
new SourceOnBattelfieldCondition(), 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); game.addEffect(effect, source);
return false; return false;
} }

View file

@ -44,8 +44,6 @@ public class DragonFodder extends CardImpl {
super(ownerId, 97, "Dragon Fodder", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{R}"); super(ownerId, 97, "Dragon Fodder", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{R}");
this.expansionSetCode = "ALA"; this.expansionSetCode = "ALA";
this.color.setRed(true);
// Put two 1/1 red Goblin creature tokens onto the battlefield. // Put two 1/1 red Goblin creature tokens onto the battlefield.
this.getSpellAbility().addEffect(new CreateTokenEffect(new GoblinToken(), 2)); this.getSpellAbility().addEffect(new CreateTokenEffect(new GoblinToken(), 2));
} }

View file

@ -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());
}
}

View file

@ -40,7 +40,7 @@ import mage.constants.CardType;
public class GoblinToken extends Token { public class GoblinToken extends Token {
static List<String> imageSetCodes = Arrays.asList( static List<String> imageSetCodes = Arrays.asList(
"M10", "C14", "KTK", "EVG" "M10", "C14", "KTK", "EVG", "DTK"
); );
public GoblinToken() { public GoblinToken() {