[BRO] Implement Lay Down Arms

This commit is contained in:
Evan Kranzler 2022-11-08 09:11:37 -05:00
parent 68a634b4a0
commit f60b48400a
2 changed files with 106 additions and 0 deletions

View file

@ -0,0 +1,105 @@
package mage.cards.l;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import java.util.Optional;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class LayDownArms extends CardImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent(
"creature with mana value less than or equal to the number of Plains you control"
);
static {
filter.add(LayDownArmsPredicate.instance);
}
public LayDownArms(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}");
// Exile target creature with mana value less than or equal to the number of Plains you control. Its controller gains 3 life.
this.getSpellAbility().addEffect(new LayDownArmsEffect());
this.getSpellAbility().addTarget(new TargetPermanent(filter));
this.getSpellAbility().addHint(LayDownArmsPredicate.getHint());
}
private LayDownArms(final LayDownArms card) {
super(card);
}
@Override
public LayDownArms copy() {
return new LayDownArms(this);
}
}
enum LayDownArmsPredicate implements ObjectSourcePlayerPredicate<Permanent> {
instance;
private static final DynamicValue xValue
= new PermanentsOnBattlefieldCount(new FilterControlledPermanent(SubType.PLAINS));
private static final Hint hint = new ValueHint("Plains you control", xValue);
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
return input.getObject().getManaValue() <= xValue.calculate(game, input.getSource(), null);
}
public static Hint getHint() {
return hint;
}
}
class LayDownArmsEffect extends OneShotEffect {
LayDownArmsEffect() {
super(Outcome.Benefit);
staticText = "exile target creature with mana value less than or equal " +
"to the number of Plains you control. Its controller gains 3 life";
}
private LayDownArmsEffect(final LayDownArmsEffect effect) {
super(effect);
}
@Override
public LayDownArmsEffect copy() {
return new LayDownArmsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (controller == null || permanent == null) {
return false;
}
controller.moveCards(permanent, Zone.EXILED, source, game);
Optional.ofNullable(game.getPlayer(permanent.getControllerId()))
.ifPresent(player -> player.gainLife(3, game, source));
return true;
}
}

View file

@ -152,6 +152,7 @@ public final class TheBrothersWar extends ExpansionSet {
cards.add(new SetCardInfo("Kill-Zone Acrobat", 106, Rarity.COMMON, mage.cards.k.KillZoneAcrobat.class));
cards.add(new SetCardInfo("Koilos Roc", 55, Rarity.COMMON, mage.cards.k.KoilosRoc.class));
cards.add(new SetCardInfo("Lat-Nam Adept", 56, Rarity.COMMON, mage.cards.l.LatNamAdept.class));
cards.add(new SetCardInfo("Lay Down Arms", 11, Rarity.UNCOMMON, mage.cards.l.LayDownArms.class));
cards.add(new SetCardInfo("Levitating Statue", 236, Rarity.UNCOMMON, mage.cards.l.LevitatingStatue.class));
cards.add(new SetCardInfo("Liberator, Urza's Battlethopter", 237, Rarity.RARE, mage.cards.l.LiberatorUrzasBattlethopter.class));
cards.add(new SetCardInfo("Llanowar Wastes", 264, Rarity.RARE, mage.cards.l.LlanowarWastes.class));