[BRO] Implement Meticulous Excavation

This commit is contained in:
Evan Kranzler 2022-11-08 08:40:17 -05:00
parent 4cb8466d07
commit 17e42d2895
2 changed files with 79 additions and 0 deletions

View file

@ -0,0 +1,78 @@
package mage.cards.m;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.condition.common.MyTurnCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.UnearthAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class MeticulousExcavation extends CardImpl {
public MeticulousExcavation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
// {2}{W}: Return target permanent you control to its owner's hand. If it has unearth, instead exile it, then return that card to its owner's hand. Activate only during your turn.
Ability ability = new ActivateIfConditionActivatedAbility(
Zone.BATTLEFIELD, new MeticulousExcavationEffect(),
new ManaCostsImpl<>("{2}{W}"), MyTurnCondition.instance
);
ability.addTarget(new TargetControlledPermanent());
this.addAbility(ability);
}
private MeticulousExcavation(final MeticulousExcavation card) {
super(card);
}
@Override
public MeticulousExcavation copy() {
return new MeticulousExcavation(this);
}
}
class MeticulousExcavationEffect extends OneShotEffect {
MeticulousExcavationEffect() {
super(Outcome.Benefit);
staticText = "return target permanent you control to its owner's hand. " +
"If it has unearth, instead exile it, then return that card to its owner's hand";
}
private MeticulousExcavationEffect(final MeticulousExcavationEffect effect) {
super(effect);
}
@Override
public MeticulousExcavationEffect copy() {
return new MeticulousExcavationEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (player == null || permanent == null) {
return false;
}
if (!permanent.getAbilities(game).containsClass(UnearthAbility.class)) {
return player.moveCards(permanent, Zone.HAND, source, game);
}
player.moveCards(permanent, Zone.EXILED, source, game);
return player.moveCards(game.getCard(permanent.getMainCard().getId()), Zone.HAND, source, game);
}
}

View file

@ -163,6 +163,7 @@ public final class TheBrothersWar extends ExpansionSet {
cards.add(new SetCardInfo("Mass Production", 15, Rarity.UNCOMMON, mage.cards.m.MassProduction.class));
cards.add(new SetCardInfo("Mechanized Warfare", 139, Rarity.RARE, mage.cards.m.MechanizedWarfare.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mechanized Warfare", 338, Rarity.RARE, mage.cards.m.MechanizedWarfare.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Meticulous Excavation", 16, Rarity.UNCOMMON, mage.cards.m.MeticulousExcavation.class));
cards.add(new SetCardInfo("Mightstone's Animation", 58, Rarity.COMMON, mage.cards.m.MightstonesAnimation.class));
cards.add(new SetCardInfo("Military Discipline", 17, Rarity.COMMON, mage.cards.m.MilitaryDiscipline.class));
cards.add(new SetCardInfo("Mine Worker", 239, Rarity.COMMON, mage.cards.m.MineWorker.class));