Misfortune's Gain

implemented misfortune's gain
This commit is contained in:
Scott Crawford 2017-05-03 19:41:10 -07:00
parent 61e3166492
commit f88876d137

View file

@ -28,13 +28,20 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.game.Game;
import mage.constants.Outcome;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author anonymous
* @author Scott-Crawford
*/
public class MisfortunesGain extends CardImpl {
@ -43,6 +50,8 @@ public class MisfortunesGain extends CardImpl {
// Destroy target creature. Its owner gains 4 life.
this.getSpellAbility().addEffect(new PathOfPeaceEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
public MisfortunesGain(final MisfortunesGain card) {
@ -54,3 +63,33 @@ public class MisfortunesGain extends CardImpl {
return new MisfortunesGain(this);
}
}
class MisfortunesGainEffect extends OneShotEffect {
public MisfortunesGainEffect() {
super(Outcome.DestroyPermanent);
this.staticText = "Destroy target creature. Its owner gains 4 life.";
}
public MisfortunesGainEffect(final MisfortunesGainEffect effect) {
super(effect);
}
@Override
public MisfortunesGainEffect copy() {
return new MisfortunesGainEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent target = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (controller != null && target != null) {
target.destroy(source.getSourceId(), game, false);
Player player = game.getPlayer(target.getOwnerId());
player.gainLife(4, game);
return true;
}
return false;
}
}