[refactoring] removed DrawCardEffect (misleading and there was better solution already implemented); also fixed Cruel Ultimatum

[refactoring] removed special char from deck name.
This commit is contained in:
North 2012-01-29 22:39:58 +02:00
parent 90ad4a16c6
commit 34765debdc
6 changed files with 23 additions and 123 deletions

View file

@ -32,7 +32,6 @@ import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.DrawCardEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.common.FilterControlledPermanent;

View file

@ -28,20 +28,17 @@
package mage.sets.magic2010;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.DrawCardEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.TargetPlayer;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.target.targetpointer.FixedTarget;
/**
* @author BetaSteward_at_googlemail.com
@ -68,7 +65,7 @@ public class HowlingMine extends CardImpl<HowlingMine> {
class HowlingMineAbility extends TriggeredAbilityImpl<HowlingMineAbility> {
public HowlingMineAbility() {
super(Zone.BATTLEFIELD, new DrawCardEffect(1));
super(Zone.BATTLEFIELD, new DrawCardTargetEffect(1));
}
public HowlingMineAbility(final HowlingMineAbility ability) {
@ -83,9 +80,7 @@ class HowlingMineAbility extends TriggeredAbilityImpl<HowlingMineAbility> {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.DRAW_STEP_PRE) {
List<UUID> targets = new ArrayList<UUID>();
targets.add(event.getPlayerId());
this.getEffects().get(0).setValue("players", targets);
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
return true;
}
return false;

View file

@ -27,20 +27,18 @@
*/
package mage.sets.magic2012;
import mage.Constants;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.DrawCardEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.effects.common.continious.PlayAdditionalLandsAllEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.target.targetpointer.FixedTarget;
/**
* @author nantuko
@ -57,7 +55,7 @@ public class RitesOfFlourishing extends CardImpl<RitesOfFlourishing> {
this.addAbility(new RitesOfFlourishingAbility());
// Each player may play an additional land on each of his or her turns.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new PlayAdditionalLandsAllEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayAdditionalLandsAllEffect()));
}
public RitesOfFlourishing(final RitesOfFlourishing card) {
@ -73,7 +71,7 @@ public class RitesOfFlourishing extends CardImpl<RitesOfFlourishing> {
class RitesOfFlourishingAbility extends TriggeredAbilityImpl<RitesOfFlourishingAbility> {
public RitesOfFlourishingAbility() {
super(Constants.Zone.BATTLEFIELD, new DrawCardEffect(1));
super(Zone.BATTLEFIELD, new DrawCardTargetEffect(1));
}
public RitesOfFlourishingAbility(final RitesOfFlourishingAbility ability) {
@ -88,9 +86,7 @@ class RitesOfFlourishingAbility extends TriggeredAbilityImpl<RitesOfFlourishingA
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DRAW_STEP_PRE) {
List<UUID> targets = new ArrayList<UUID>();
targets.add(event.getPlayerId());
this.getEffects().get(0).setValue("players", targets);
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
return true;
}
return false;

View file

@ -34,16 +34,13 @@ import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DiscardTargetEffect;
import mage.abilities.effects.common.DrawCardEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.effects.common.SacrificeEffect;
import mage.abilities.effects.common.*;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetOpponent;
@ -67,9 +64,8 @@ public class CruelUltimatum extends CardImpl<CruelUltimatum> {
this.getSpellAbility().addEffect(new DiscardTargetEffect(3));
this.getSpellAbility().addEffect(new LoseLifeTargetEffect(5));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard")));
this.getSpellAbility().addEffect(new CruelUltimatumEffect());
this.getSpellAbility().addEffect(new DrawCardEffect(3));
this.getSpellAbility().addEffect(new DrawCardControllerEffect(3));
this.getSpellAbility().addEffect(new GainLifeEffect(5));
}
@ -87,6 +83,7 @@ class CruelUltimatumEffect extends OneShotEffect<CruelUltimatumEffect> {
public CruelUltimatumEffect() {
super(Outcome.ReturnToHand);
this.staticText = "return a creature card from your graveyard to your hand";
}
public CruelUltimatumEffect(final CruelUltimatumEffect effect) {
@ -100,9 +97,13 @@ class CruelUltimatumEffect extends OneShotEffect<CruelUltimatumEffect> {
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getTargets().get(1).getFirstTarget());
if (card != null) {
return card.moveToZone(Zone.HAND, source.getId(), game, true);
Player player = game.getPlayer(source.getControllerId());
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"));
if (player != null && player.choose(Outcome.ReturnToHand, target, source.getId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
return card.moveToZone(Zone.HAND, source.getId(), game, true);
}
}
return false;
}

View file

@ -1,91 +0,0 @@
/*
* 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.abilities.effects.common;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.game.Game;
import mage.players.Player;
import java.util.List;
import java.util.UUID;
/**
*
* @author nantuko
*/
public class DrawCardEffect extends OneShotEffect<DrawCardEffect> {
protected DynamicValue amount;
public DrawCardEffect(int amount) {
this(new StaticValue(amount));
}
public DrawCardEffect(DynamicValue amount) {
super(Outcome.DrawCard);
this.amount = amount.clone();
}
public DrawCardEffect(final DrawCardEffect effect) {
super(effect);
this.amount = effect.amount.clone();
}
@Override
public DrawCardEffect copy() {
return new DrawCardEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
List<UUID> targets = (List<UUID>)getValue("players");
if (targets != null) {
for (UUID uuid : targets) {
Player player = game.getPlayer(uuid);
if (player != null) {
player.drawCards(amount.calculate(game, source), game);
return true;
}
}
}
return false;
}
@Override
public String getText(Mode mode) {
return "";
}
}