Merge pull request #5067 from NoahGleason/delirium

Implement Delirium
This commit is contained in:
theelk801 2018-06-23 21:43:57 -04:00 committed by GitHub
commit 235974f21a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 116 additions and 0 deletions

View file

@ -0,0 +1,87 @@
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.*;
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 Delirium extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
filter.add(new ControllerIsActivePlayerPredicate());
}
public Delirium(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.getSpellAbility().addEffect(new TapTargetEffect().setText("target creature that player controls"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
this.getSpellAbility().addEffect(new DeliriumEffect());
this.getSpellAbility().addEffect(new PreventDamageToTargetEffect(Duration.EndOfTurn, true).setText("Prevent all combat damage that would be dealt to"));
this.getSpellAbility().addEffect(new PreventDamageByTargetEffect(Duration.EndOfTurn, true).setText("and dealt by the creature this turn."));
}
public Delirium(final Delirium card) {
super(card);
}
@Override
public Delirium copy() {
return new Delirium(this);
}
}
class DeliriumEffect extends OneShotEffect {
public DeliriumEffect() {
super(Outcome.Damage);
this.staticText = "that creature deals damage equal to its power to the player";
}
public DeliriumEffect(DeliriumEffect 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 DeliriumEffect copy() {
return new DeliriumEffect(this);
}
}

View file

@ -1,6 +1,7 @@
package mage.sets;
import mage.cards.ExpansionSet;
import mage.cards.d.Delirium;
import mage.constants.Rarity;
import mage.constants.SetType;
@ -83,6 +84,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, Delirium.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";
}
}