Path of Peace

implemented Path of Peace
This commit is contained in:
Scott Crawford 2017-05-03 19:37:41 -07:00
parent b2db8057b5
commit 61e3166492

View file

@ -28,13 +28,20 @@
package mage.cards.p;
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 PathOfPeace extends CardImpl {
@ -43,6 +50,10 @@ public class PathOfPeace extends CardImpl {
// Destroy target creature. Its owner gains 4 life.
this.getSpellAbility().addEffect(new PathOfPeaceEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
public PathOfPeace(final PathOfPeace card) {
@ -54,3 +65,33 @@ public class PathOfPeace extends CardImpl {
return new PathOfPeace(this);
}
}
class PathOfPeaceEffect extends OneShotEffect {
public PathOfPeaceEffect() {
super(Outcome.DestroyPermanent);
this.staticText = "Destroy target creature. Its owner gains 4 life.";
}
public PathOfPeaceEffect(final PathOfPeaceEffect effect) {
super(effect);
}
@Override
public PathOfPeaceEffect copy() {
return new PathOfPeaceEffect(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;
}
}