Some minor updates to the cards of the recently merged pull requests.

This commit is contained in:
LevelX2 2015-09-15 00:24:08 +02:00
parent 83230aebc2
commit 310627c924
10 changed files with 126 additions and 139 deletions

View file

@ -31,7 +31,6 @@ import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Abilities; import mage.abilities.Abilities;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
@ -39,6 +38,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.UntapTargetEffect; import mage.abilities.effects.common.UntapTargetEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.AbilityType;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
@ -52,18 +52,18 @@ import mage.target.common.TargetCreaturePermanent;
* @author BursegSardaukar * @author BursegSardaukar
*/ */
public class MagewrightsStone extends CardImpl { public class MagewrightsStone extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that has an ability with {T} in its cost"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that has an ability with {T} in its cost");
static { static {
filter.add(new HasAbilityWithTapSymbolPredicate()); filter.add(new HasAbilityWithTapSymbolPredicate());
} }
public MagewrightsStone(UUID ownerId) { public MagewrightsStone(UUID ownerId) {
super(ownerId, 162, "Magewright's Stone", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); super(ownerId, 162, "Magewright's Stone", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "DIS"; this.expansionSetCode = "DIS";
// {1}, {tap}: Untap target creature that has an activated ability with {T} in its cost. // {1}, {T}: Untap target creature that has an activated ability with {T} in its cost.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new UntapTargetEffect(), new ManaCostsImpl("{1}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new UntapTargetEffect(), new ManaCostsImpl("{1}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(filter)); ability.addTarget(new TargetCreaturePermanent(filter));
@ -80,27 +80,19 @@ public class MagewrightsStone extends CardImpl {
} }
} }
/**
*
* @author North
*/
class HasAbilityWithTapSymbolPredicate implements Predicate<MageObject> { class HasAbilityWithTapSymbolPredicate implements Predicate<MageObject> {
public HasAbilityWithTapSymbolPredicate() {
}
@Override @Override
public boolean apply(MageObject input, Game game) { public boolean apply(MageObject input, Game game) {
Abilities<Ability> abilities; Abilities<Ability> abilities;
if (input instanceof Card){ if (input instanceof Card) {
abilities = ((Card)input).getAbilities(game); abilities = ((Card) input).getAbilities(game);
} else { } else {
abilities = input.getAbilities(); abilities = input.getAbilities();
} }
for (Ability ability : abilities) { for (Ability ability : abilities) {
if((ability instanceof ActivatedAbilityImpl) && ability.getCosts().size() > 0){ if (ability.getAbilityType().equals(AbilityType.ACTIVATED) && !ability.getCosts().isEmpty()) {
for (Cost cost : ability.getCosts()) { for (Cost cost : ability.getCosts()) {
if (cost instanceof TapSourceCost) { if (cost instanceof TapSourceCost) {
return true; return true;
@ -113,6 +105,6 @@ class HasAbilityWithTapSymbolPredicate implements Predicate<MageObject> {
@Override @Override
public String toString() { public String toString() {
return "Ability contains {T} symbol."; return "activated ability with {T} in its cost";
} }
} }

View file

@ -1,7 +1,7 @@
package mage.sets.futuresight; package mage.sets.futuresight;
import java.util.UUID; import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.decorator.ConditionalTriggeredAbility;
@ -12,37 +12,36 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreatureCard;
import mage.MageInt;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
public class GraveScrabbler extends CardImpl{ public class GraveScrabbler extends CardImpl {
public GraveScrabbler(UUID ownerId) { public GraveScrabbler(UUID ownerId) {
super(ownerId, 86, "Grave Scrabbler", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{3}{B}"); super(ownerId, 86, "Grave Scrabbler", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.expansionSetCode = "FUT"; this.expansionSetCode = "FUT";
this.subtype.add("Zombie"); this.subtype.add("Zombie");
this.power = new MageInt(2);
this.toughness = new MageInt(2);
//Madness {1}{B}
this.addAbility(new MadnessAbility(this, new ManaCostsImpl("{1}{B}")));
//When Grave Scrabbler enters the battlefield, if its madness cost was paid,
//you may return target creature card from a graveyard to its owner's hand.
EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), true);
ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
this.addAbility(new ConditionalTriggeredAbility(ability, MadnessAbility.GetCondition(),
"When {this} enters the battlefield, if its madness cost was paid, you may return target creature card from a graveyard to its owner's hand."));
}
public GraveScrabbler(final GraveScrabbler card){
super(card);
}
@Override this.power = new MageInt(2);
public Card copy() { this.toughness = new MageInt(2);
return new GraveScrabbler(this);
} //Madness {1}{B}
this.addAbility(new MadnessAbility(this, new ManaCostsImpl("{1}{B}")));
//When Grave Scrabbler enters the battlefield, if its madness cost was paid,
//you may return target creature card from a graveyard to its owner's hand.
EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), true);
ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
this.addAbility(new ConditionalTriggeredAbility(ability, MadnessAbility.GetCondition(),
"When {this} enters the battlefield, if its madness cost was paid, you may return target creature card from a graveyard to its owner's hand."));
}
public GraveScrabbler(final GraveScrabbler card) {
super(card);
}
@Override
public Card copy() {
return new GraveScrabbler(this);
}
} }

View file

@ -49,18 +49,19 @@ import mage.target.common.TargetCreaturePermanent;
* @author Leathios * @author Leathios
*/ */
public class AegisOfTheMeek extends CardImpl { public class AegisOfTheMeek extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("1/1 creature"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("1/1 creature");
static { static {
filter.add(new PowerPredicate(Filter.ComparisonType.Equal, 1)); filter.add(new PowerPredicate(Filter.ComparisonType.Equal, 1));
filter.add(new ToughnessPredicate(Filter.ComparisonType.Equal, 1)); filter.add(new ToughnessPredicate(Filter.ComparisonType.Equal, 1));
} }
public AegisOfTheMeek(UUID ownerId) { public AegisOfTheMeek(UUID ownerId) {
super(ownerId, 282, "Aegis of the Meek", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}"); super(ownerId, 282, "Aegis of the Meek", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}");
this.expansionSetCode = "ICE"; this.expansionSetCode = "ICE";
// {1}, {tap}: Target 1/1 creature gets +1/+2 until end of turn. // {1}, {T}: Target 1/1 creature gets +1/+2 until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(1, 2, Duration.EndOfTurn), new ManaCostsImpl("{1}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(1, 2, Duration.EndOfTurn), new ManaCostsImpl("{1}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(filter)); ability.addTarget(new TargetCreaturePermanent(filter));

View file

@ -49,12 +49,12 @@ import mage.filter.predicate.permanent.AnotherPredicate;
public class Aurochs extends CardImpl { public class Aurochs extends CardImpl {
private static final FilterAttackingCreature filter1 = new FilterAttackingCreature("other attacking Aurochs"); private static final FilterAttackingCreature filter1 = new FilterAttackingCreature("other attacking Aurochs");
static { static {
filter1.add(new SubtypePredicate("Aurochs")); filter1.add(new SubtypePredicate("Aurochs"));
filter1.add(new AnotherPredicate()); filter1.add(new AnotherPredicate());
} }
public Aurochs(UUID ownerId) { public Aurochs(UUID ownerId) {
super(ownerId, 113, "Aurochs", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{3}{G}"); super(ownerId, 113, "Aurochs", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.expansionSetCode = "ICE"; this.expansionSetCode = "ICE";

View file

@ -68,6 +68,7 @@ public class SoldeviMachinist extends CardImpl {
} }
class SoldeviMachinistManaBuilder extends ConditionalManaBuilder { class SoldeviMachinistManaBuilder extends ConditionalManaBuilder {
@Override @Override
public ConditionalMana build(Object... options) { public ConditionalMana build(Object... options) {
return new ArtifactCastConditionalMana(this.mana); return new ArtifactCastConditionalMana(this.mana);

View file

@ -28,20 +28,20 @@
package mage.sets.onslaught; package mage.sets.onslaught;
import java.util.UUID; import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.LoseHalfLifeEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LoseHalfLifeEffect;
import mage.abilities.keyword.MorphAbility; import mage.abilities.keyword.MorphAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -49,30 +49,28 @@ import mage.players.Player;
* *
* @author BijanT * @author BijanT
*/ */
public class EbonbladeReaper extends CardImpl{ public class EbonbladeReaper extends CardImpl {
public EbonbladeReaper(UUID ownerId) public EbonbladeReaper(UUID ownerId) {
{
super(ownerId, 141, "Ebonblade Reaper", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{B}"); super(ownerId, 141, "Ebonblade Reaper", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{B}");
this.expansionSetCode = "ONS"; this.expansionSetCode = "ONS";
this.subtype.add("Human"); this.subtype.add("Human");
this.subtype.add("Cleric"); this.subtype.add("Cleric");
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
//Whenever Ebonblade Reaper attacks, you lose half your life, rounded up. //Whenever Ebonblade Reaper attacks, you lose half your life, rounded up.
this.addAbility(new AttacksTriggeredAbility(new LoseHalfLifeEffect(), false)); this.addAbility(new AttacksTriggeredAbility(new LoseHalfLifeEffect(), false));
//Whenever Ebonblade Reaper deals combat damage to a player, that player loses half his or her life, rounded up. //Whenever Ebonblade Reaper deals combat damage to a player, that player loses half his or her life, rounded up.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new EbonbladeReaperEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new EbonbladeReaperEffect(), false, true));
//Morph {3}{B}{B} //Morph {3}{B}{B}
this.addAbility(new MorphAbility(this, new ManaCostsImpl<>("{3}{B}{B}"))); this.addAbility(new MorphAbility(this, new ManaCostsImpl<>("{3}{B}{B}")));
} }
public EbonbladeReaper(final EbonbladeReaper card) public EbonbladeReaper(final EbonbladeReaper card) {
{
super(card); super(card);
} }
@ -82,25 +80,22 @@ public class EbonbladeReaper extends CardImpl{
} }
} }
class EbonbladeReaperEffect extends OneShotEffect class EbonbladeReaperEffect extends OneShotEffect {
{
public EbonbladeReaperEffect() public EbonbladeReaperEffect() {
{
super(Outcome.Damage); super(Outcome.Damage);
this.staticText = "that player loses half his or her life, rounded up."; this.staticText = "that player loses half his or her life, rounded up";
} }
public EbonbladeReaperEffect(final EbonbladeReaperEffect effect) public EbonbladeReaperEffect(final EbonbladeReaperEffect effect) {
{
super(effect); super(effect);
} }
@Override @Override
public Effect copy() { public Effect copy() {
return new EbonbladeReaperEffect(this); return new EbonbladeReaperEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); Player player = game.getPlayer(getTargetPointer().getFirst(game, source));

View file

@ -31,11 +31,11 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect; import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.ProtectionAbility; import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
@ -58,36 +58,37 @@ public class GoblinWizard extends CardImpl {
private static final FilterPermanentCard filter = new FilterPermanentCard("Goblin"); private static final FilterPermanentCard filter = new FilterPermanentCard("Goblin");
private static final FilterCard protectionFilter = new FilterCard("white"); private static final FilterCard protectionFilter = new FilterCard("white");
private static final FilterPermanent goblinCard = new FilterPermanent("Goblin"); private static final FilterPermanent goblinPermanent = new FilterPermanent("Goblin");
static { static {
filter.add(new SubtypePredicate("Goblin")); filter.add(new SubtypePredicate("Goblin"));
goblinCard.add(new SubtypePredicate("Goblin")); goblinPermanent.add(new SubtypePredicate("Goblin"));
protectionFilter.add(new ColorPredicate(ObjectColor.WHITE)); protectionFilter.add(new ColorPredicate(ObjectColor.WHITE));
} }
public GoblinWizard(UUID ownerId) { public GoblinWizard(UUID ownerId) {
super(ownerId, 68, "Goblin Wizard", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{R}{R}"); super(ownerId, 68, "Goblin Wizard", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{R}{R}");
this.expansionSetCode = "DRK"; this.expansionSetCode = "DRK";
this.rarity = Rarity.RARE; this.rarity = Rarity.RARE;
this.subtype.add("Goblin"); this.subtype.add("Goblin");
this.subtype.add("Wizard"); this.subtype.add("Wizard");
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {tap}: You may put a Goblin permanent card from your hand onto the battlefield. // {tap}: You may put a Goblin permanent card from your hand onto the battlefield.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new PutPermanentOnBattlefieldEffect(filter), new PutPermanentOnBattlefieldEffect(filter),
new TapSourceCost())); new TapSourceCost()));
// {R}: Target Goblin gains protection from white until end of turn. // {R}: Target Goblin gains protection from white until end of turn.
Ability ability = new mage.abilities.common.SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilityTargetEffect(new ProtectionAbility(protectionFilter), Duration.EndOfTurn), new ManaCostsImpl("{R}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
Target target = new TargetPermanent(goblinCard); new GainAbilityTargetEffect(new ProtectionAbility(protectionFilter), Duration.EndOfTurn), new ManaCostsImpl("{R}"));
Target target = new TargetPermanent(goblinPermanent);
ability.addTarget(target); ability.addTarget(target);
this.addAbility(ability); this.addAbility(ability);
} }
public GoblinWizard(final GoblinWizard card) { public GoblinWizard(final GoblinWizard card) {

View file

@ -54,7 +54,7 @@ public class LastDitchEffort extends CardImpl {
// Sacrifice any number of creatures. Last-Ditch Effort deals that much damage to target creature or player. // Sacrifice any number of creatures. Last-Ditch Effort deals that much damage to target creature or player.
this.getSpellAbility().addEffect(new LastDitchEffortEffect()); this.getSpellAbility().addEffect(new LastDitchEffortEffect());
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer(1)); this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
} }
public LastDitchEffort(final LastDitchEffort card) { public LastDitchEffort(final LastDitchEffort card) {
@ -68,21 +68,21 @@ public class LastDitchEffort extends CardImpl {
} }
class LastDitchEffortEffect extends OneShotEffect { class LastDitchEffortEffect extends OneShotEffect {
LastDitchEffortEffect() { LastDitchEffortEffect() {
super(Outcome.Damage); super(Outcome.Damage);
this.staticText = "Sacrifice any number of creatures. Last-Ditch Effort deals that much damage to target creature or player."; this.staticText = "Sacrifice any number of creatures. {this} deals that much damage to target creature or player";
} }
LastDitchEffortEffect(final LastDitchEffortEffect effect) { LastDitchEffortEffect(final LastDitchEffortEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public LastDitchEffortEffect copy() { public LastDitchEffortEffect copy() {
return new LastDitchEffortEffect(this); return new LastDitchEffortEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
@ -109,10 +109,9 @@ class LastDitchEffortEffect extends OneShotEffect {
if (opponent != null) { if (opponent != null) {
opponent.damage(damage, source.getSourceId(), game, false, true); opponent.damage(damage, source.getSourceId(), game, false, true);
} }
return true;
} }
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -13,7 +13,7 @@ public class LoseHalfLifeEffect extends OneShotEffect {
public LoseHalfLifeEffect() { public LoseHalfLifeEffect() {
super(Outcome.LoseLife); super(Outcome.LoseLife);
staticText = "You lose half your life, rounded up"; staticText = "you lose half your life, rounded up";
} }
public LoseHalfLifeEffect(final LoseHalfLifeEffect effect) { public LoseHalfLifeEffect(final LoseHalfLifeEffect effect) {
@ -37,4 +37,4 @@ public class LoseHalfLifeEffect extends OneShotEffect {
} }
return false; return false;
} }
} }

View file

@ -24,27 +24,30 @@ import mage.players.Player;
* *
* 702.33a. Madness is a keyword that represents two abilities. * 702.33a. Madness is a keyword that represents two abilities.
* *
* The first is a static ability that functions while the card with madness is in a player's hand. * The first is a static ability that functions while the card with madness is
* The second is a triggered ability that functions when the first ability is applied. * in a player's hand. The second is a triggered ability that functions when the
* first ability is applied.
* *
* "Madness [cost]" means "If a player would discard this card, that player discards it, but may exile it instead of putting it into his or her graveyard" and * "Madness [cost]" means "If a player would discard this card, that player
* "When this card is exiled this way, its owner may cast it by paying [cost] rather than paying its mana cost. * discards it, but may exile it instead of putting it into his or her
* If that player doesn't, he or she puts this card into his or her graveyard. * graveyard" and "When this card is exiled this way, its owner may cast it by
* paying [cost] rather than paying its mana cost. If that player doesn't, he or
* she puts this card into his or her graveyard.
* *
* 702.33b. Casting a spell using its madness ability follows the rules for paying alternative costs in rules 601.2b and 601.2e-g. * 702.33b. Casting a spell using its madness ability follows the rules for
* paying alternative costs in rules 601.2b and 601.2e-g.
* *
* @author LevelX2 * @author LevelX2
*/ */
public class MadnessAbility extends StaticAbility { public class MadnessAbility extends StaticAbility {
private String rule; private String rule;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MadnessAbility(Card card, ManaCosts madnessCost) { public MadnessAbility(Card card, ManaCosts madnessCost) {
super(Zone.HAND, new MadnessReplacementEffect((ManaCosts<ManaCost>)madnessCost)); super(Zone.HAND, new MadnessReplacementEffect((ManaCosts<ManaCost>) madnessCost));
addSubAbility(new MadnessTriggeredAbility((ManaCosts<ManaCost>)madnessCost)); addSubAbility(new MadnessTriggeredAbility((ManaCosts<ManaCost>) madnessCost));
rule = "Madness " + madnessCost.getText() + " <i>(If you discard this card, you may cast it for its madness cost instead of putting it into your graveyard.)<i/>"; rule = "Madness " + madnessCost.getText() + " <i>(If you discard this card, you may cast it for its madness cost instead of putting it into your graveyard.)<i/>";
} }
public MadnessAbility(final MadnessAbility ability) { public MadnessAbility(final MadnessAbility ability) {
@ -55,9 +58,8 @@ public class MadnessAbility extends StaticAbility {
public MadnessAbility copy() { public MadnessAbility copy() {
return new MadnessAbility(this); return new MadnessAbility(this);
} }
public static Condition GetCondition() public static Condition GetCondition() {
{
return MadnessCondition.getInstance(); return MadnessCondition.getInstance();
} }
@ -67,11 +69,10 @@ public class MadnessAbility extends StaticAbility {
} }
} }
class MadnessReplacementEffect extends ReplacementEffectImpl { class MadnessReplacementEffect extends ReplacementEffectImpl {
public MadnessReplacementEffect(ManaCosts<ManaCost> madnessCost) { public MadnessReplacementEffect(ManaCosts<ManaCost> madnessCost) {
super(Duration.EndOfGame, Outcome.Benefit); super(Duration.EndOfGame, Outcome.Benefit);
staticText = "Madness " + madnessCost.getText() + " <i>(If you discard this card, you may cast it for its madness cost instead of putting it into your graveyard.)<i/>"; staticText = "Madness " + madnessCost.getText() + " <i>(If you discard this card, you may cast it for its madness cost instead of putting it into your graveyard.)<i/>";
} }
@ -97,14 +98,14 @@ class MadnessReplacementEffect extends ReplacementEffectImpl {
if (card != null) { if (card != null) {
if (controller.chooseUse(outcome, "Move " + card.getLogName() + " to exile to cast it by Madness?", source, game)) { if (controller.chooseUse(outcome, "Move " + card.getLogName() + " to exile to cast it by Madness?", source, game)) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), "Madness", source.getSourceId(), game, ((ZoneChangeEvent) event).getFromZone(), true); controller.moveCardToExileWithInfo(card, source.getSourceId(), "Madness", source.getSourceId(), game, ((ZoneChangeEvent) event).getFromZone(), true);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.MADNESS_CARD_EXILED, card.getId(), card.getId(),controller.getId())); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.MADNESS_CARD_EXILED, card.getId(), card.getId(), controller.getId()));
return true; return true;
} }
} }
} }
return false; return false;
} }
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE; return event.getType() == GameEvent.EventType.ZONE_CHANGE;
@ -112,23 +113,24 @@ class MadnessReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
return event.getTargetId().equals(source.getSourceId()) && return event.getTargetId().equals(source.getSourceId())
((ZoneChangeEvent) event).getFromZone() == Zone.HAND && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD; && ((ZoneChangeEvent) event).getFromZone() == Zone.HAND && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD;
} }
} }
/** /**
* Checks for the MADNESS_CARD_EXILED event to ask the player * Checks for the MADNESS_CARD_EXILED event to ask the player if he wants to
* if he wants to cast the card by it's Madness costs. * cast the card by it's Madness costs. If not, the card goes to the graveyard.
* If not, the card goes to the graveyard.
*/ */
class MadnessTriggeredAbility extends TriggeredAbilityImpl { class MadnessTriggeredAbility extends TriggeredAbilityImpl {
//This array holds the Id's of all of the cards that activated madness //This array holds the Id's of all of the cards that activated madness
private static ArrayList<UUID> activatedIds = new ArrayList<UUID>(); private static ArrayList<UUID> activatedIds = new ArrayList<>();
MadnessTriggeredAbility(ManaCosts<ManaCost> madnessCost ) {
MadnessTriggeredAbility(ManaCosts<ManaCost> madnessCost) {
super(Zone.EXILED, new MadnessCastEffect(madnessCost), true); super(Zone.EXILED, new MadnessCastEffect(madnessCost), true);
this.setRuleVisible(false); this.setRuleVisible(false);
} }
MadnessTriggeredAbility(final MadnessTriggeredAbility ability) { MadnessTriggeredAbility(final MadnessTriggeredAbility ability) {
@ -155,12 +157,12 @@ class MadnessTriggeredAbility extends TriggeredAbilityImpl {
if (!super.resolve(game)) { if (!super.resolve(game)) {
Card card = game.getCard(getSourceId()); Card card = game.getCard(getSourceId());
if (card != null) { if (card != null) {
Player owner = game.getPlayer(card.getOwnerId()); Player owner = game.getPlayer(card.getOwnerId());
if (owner != null) { if (owner != null) {
// if cast was not successfull, the card is moved to graveyard // if cast was not successfull, the card is moved to graveyard
owner.moveCards(card, Zone.EXILED, Zone.GRAVEYARD, this, game); owner.moveCards(card, Zone.EXILED, Zone.GRAVEYARD, this, game);
} }
} }
return false; return false;
} }
activatedIds.add(getSourceId()); activatedIds.add(getSourceId());
@ -168,13 +170,10 @@ class MadnessTriggeredAbility extends TriggeredAbilityImpl {
} }
@Override @Override
public boolean isActivated() public boolean isActivated() {
{
//Look through the list of activated Ids and see if the current source's Id is one of them //Look through the list of activated Ids and see if the current source's Id is one of them
for(UUID currentId : activatedIds) for (UUID currentId : activatedIds) {
{ if (currentId.equals(getSourceId())) {
if(currentId.equals(getSourceId()))
{
//Remove the current source from the list, so if the card is somehow recast without //Remove the current source from the list, so if the card is somehow recast without
//paying the madness cost, this will return false //paying the madness cost, this will return false
activatedIds.remove(currentId); activatedIds.remove(currentId);
@ -184,7 +183,7 @@ class MadnessTriggeredAbility extends TriggeredAbilityImpl {
//If the current source's Id was not found, return false //If the current source's Id was not found, return false
return false; return false;
} }
@Override @Override
public String getRule() { public String getRule() {
return "When this card is exiled this way, " + super.getRule(); return "When this card is exiled this way, " + super.getRule();
@ -192,13 +191,13 @@ class MadnessTriggeredAbility extends TriggeredAbilityImpl {
} }
class MadnessCastEffect extends OneShotEffect { class MadnessCastEffect extends OneShotEffect {
private final ManaCosts<ManaCost> madnessCost; private final ManaCosts<ManaCost> madnessCost;
public MadnessCastEffect(ManaCosts<ManaCost> madnessCost) { public MadnessCastEffect(ManaCosts<ManaCost> madnessCost) {
super(Outcome.Benefit); super(Outcome.Benefit);
this.madnessCost = madnessCost; this.madnessCost = madnessCost;
staticText = "cast it by paying " + madnessCost.getText() + " rather than paying its mana cost. If that player doesnt, he or she puts this card into his or her graveyard."; staticText = "cast it by paying " + madnessCost.getText() + " rather than paying its mana cost. If that player doesnt, he or she puts this card into his or her graveyard.";
} }
public MadnessCastEffect(final MadnessCastEffect effect) { public MadnessCastEffect(final MadnessCastEffect effect) {
@ -212,7 +211,7 @@ class MadnessCastEffect extends OneShotEffect {
Card card = game.getCard(source.getSourceId()); Card card = game.getCard(source.getSourceId());
if (card != null) { if (card != null) {
owner = game.getPlayer(card.getOwnerId()); owner = game.getPlayer(card.getOwnerId());
} }
if (owner != null && card != null) { if (owner != null && card != null) {
ManaCosts<ManaCost> costRef = card.getSpellAbility().getManaCostsToPay(); ManaCosts<ManaCost> costRef = card.getSpellAbility().getManaCostsToPay();
// replace with the new cost // replace with the new cost