Add Delirium, not recognized as a card

This commit is contained in:
Noah Gleason 2018-06-23 17:30:57 -04:00
parent eb85146367
commit b97719fbb6
No known key found for this signature in database
GPG key ID: EC030EC6B0650A40
3 changed files with 117 additions and 0 deletions

View file

@ -0,0 +1,89 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.CastOnlyIfConditionIsTrueAbility;
import mage.abilities.condition.common.OnOpponentsTurnCondition;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PreventCombatDamageBySourceEffect;
import mage.abilities.effects.common.PreventCombatDamageToSourceEffect;
import mage.abilities.effects.common.TapTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIsActivePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author noahg
*/
public final class DeliriumCard extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
filter.add(new ControllerIsActivePlayerPredicate());
}
public DeliriumCard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}{R}");
// Cast this spell only during an opponents turn.
this.addAbility(new CastOnlyIfConditionIsTrueAbility(OnOpponentsTurnCondition.instance, "Cast this spell only during an opponents turn."));
// Tap target creature that player controls. That creature deals damage equal to its power to the player. Prevent all combat damage that would be dealt to and dealt by the creature this turn.
this.spellAbility.addEffect(new TapTargetEffect().setText("tap target creature that player controls"));
this.spellAbility.addTarget(new TargetCreaturePermanent(filter));
this.spellAbility.addEffect(new DeliriumCardEffect());
this.spellAbility.addEffect(new PreventCombatDamageBySourceEffect(Duration.EndOfTurn).setText("Prevent all combat damage that would be dealt to"));
this.spellAbility.addEffect(new PreventCombatDamageToSourceEffect(Duration.EndOfTurn).setText("and dealt by the creature this turn."));
}
public DeliriumCard(final DeliriumCard card) {
super(card);
}
@Override
public DeliriumCard copy() {
return new DeliriumCard(this);
}
}
class DeliriumCardEffect extends OneShotEffect {
public DeliriumCardEffect() {
super(Outcome.Damage);
this.staticText = "that creature deals damage equal to its power to the player";
}
public DeliriumCardEffect(DeliriumCardEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(source.getFirstTarget());
if (creature != null) {
int amount = creature.getPower().getValue();
Player controller = game.getPlayer(creature.getControllerId());
if (controller != null) {
controller.damage(amount, creature.getId(), game, false, true);
return true;
}
}
return false;
}
@Override
public DeliriumCardEffect copy() {
return new DeliriumCardEffect(this);
}
}

View file

@ -83,6 +83,7 @@ public final class Mirage extends ExpansionSet {
cards.add(new SetCardInfo("Dark Banishing", 115, Rarity.COMMON, mage.cards.d.DarkBanishing.class));
cards.add(new SetCardInfo("Dark Ritual", 116, Rarity.COMMON, mage.cards.d.DarkRitual.class));
cards.add(new SetCardInfo("Dazzling Beauty", 8, Rarity.COMMON, mage.cards.d.DazzlingBeauty.class));
cards.add(new SetCardInfo("Delirium", 260, Rarity.UNCOMMON, mage.cards.d.DeliriumCard.class));
cards.add(new SetCardInfo("Dirtwater Wraith", 117, Rarity.COMMON, mage.cards.d.DirtwaterWraith.class));
cards.add(new SetCardInfo("Disempower", 9, Rarity.COMMON, mage.cards.d.Disempower.class));
cards.add(new SetCardInfo("Disenchant", 10, Rarity.COMMON, mage.cards.d.Disenchant.class));

View file

@ -0,0 +1,27 @@
package mage.filter.predicate.permanent;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author North
*/
public class ControllerIsActivePlayerPredicate implements Predicate<Permanent> {
@Override
public boolean apply(Permanent input, Game game) {
if(input.getControllerId() == null){
return false;
}
return game.getActivePlayerId().equals(input.getControllerId());
}
@Override
public String toString() {
return "controlled by the active player";
}
}