Implemented Generous Gift

This commit is contained in:
Evan Kranzler 2019-05-23 18:10:15 -04:00
parent 9f71e2d7f3
commit e457aba61d
2 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,74 @@
package mage.cards.g;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.ElephantToken;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class GenerousGift extends CardImpl {
public GenerousGift(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}");
// Destroy target permanent. Its controller creates a 3/3 green Elephant creature token.
this.getSpellAbility().addEffect(new GenerousGiftEffect());
this.getSpellAbility().addTarget(new TargetPermanent());
}
private GenerousGift(final GenerousGift card) {
super(card);
}
@Override
public GenerousGift copy() {
return new GenerousGift(this);
}
}
class GenerousGiftEffect extends OneShotEffect {
GenerousGiftEffect() {
super(Outcome.Benefit);
staticText = "Destroy target permanent. Its controller creates a 3/3 green Elephant creature token.";
}
private GenerousGiftEffect(final GenerousGiftEffect effect) {
super(effect);
}
@Override
public GenerousGiftEffect copy() {
return new GenerousGiftEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
Player player = game.getPlayer(permanent.getControllerId());
permanent.destroy(source.getSourceId(), game, false);
if (player == null) {
return false;
}
Effect effect = new CreateTokenTargetEffect(new ElephantToken());
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
}

View file

@ -45,6 +45,7 @@ public final class ModernHorizons extends ExpansionSet {
cards.add(new SetCardInfo("Fiery Islet", 238, Rarity.RARE, mage.cards.f.FieryIslet.class)); cards.add(new SetCardInfo("Fiery Islet", 238, Rarity.RARE, mage.cards.f.FieryIslet.class));
cards.add(new SetCardInfo("Firebolt", 122, Rarity.UNCOMMON, mage.cards.f.Firebolt.class)); cards.add(new SetCardInfo("Firebolt", 122, Rarity.UNCOMMON, mage.cards.f.Firebolt.class));
cards.add(new SetCardInfo("Flusterstorm", 255, Rarity.RARE, mage.cards.f.Flusterstorm.class)); cards.add(new SetCardInfo("Flusterstorm", 255, Rarity.RARE, mage.cards.f.Flusterstorm.class));
cards.add(new SetCardInfo("Generous Gift", 11, Rarity.UNCOMMON, mage.cards.g.GenerousGift.class));
cards.add(new SetCardInfo("Goblin Engineer", 128, Rarity.RARE, mage.cards.g.GoblinEngineer.class)); cards.add(new SetCardInfo("Goblin Engineer", 128, Rarity.RARE, mage.cards.g.GoblinEngineer.class));
cards.add(new SetCardInfo("Goblin Matron", 129, Rarity.UNCOMMON, mage.cards.g.GoblinMatron.class)); cards.add(new SetCardInfo("Goblin Matron", 129, Rarity.UNCOMMON, mage.cards.g.GoblinMatron.class));
cards.add(new SetCardInfo("Goblin War Party", 131, Rarity.COMMON, mage.cards.g.GoblinWarParty.class)); cards.add(new SetCardInfo("Goblin War Party", 131, Rarity.COMMON, mage.cards.g.GoblinWarParty.class));