[PIP] Implement V.A.T.S.

This commit is contained in:
theelk801 2023-10-22 16:29:59 -04:00
parent 5b845ef7e4
commit 8ff9aac5f3
2 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,83 @@
package mage.cards.v;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.keyword.SplitSecondAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import java.util.Objects;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class VATS extends CardImpl {
public VATS(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{B}{B}");
// Split second
this.addAbility(new SplitSecondAbility());
// Choose any number of target creatures with equal toughness. Destroy the chosen creatures.
this.getSpellAbility().addEffect(new DestroyTargetEffect()
.setText("choose any number of target creatures with equal toughness. Destroy the chosen creatures"));
this.getSpellAbility().addTarget(new VATSTarget());
}
private VATS(final VATS card) {
super(card);
}
@Override
public VATS copy() {
return new VATS(this);
}
}
class VATSTarget extends TargetPermanent {
private static final FilterPermanent filter = new FilterCreaturePermanent("creatures with equal toughness");
VATSTarget() {
super(0, Integer.MAX_VALUE, filter, false);
}
private VATSTarget(final VATSTarget target) {
super(target);
}
@Override
public VATSTarget copy() {
return new VATSTarget(this);
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
if (!super.canTarget(controllerId, id, source, game)) {
return false;
}
if (this.getTargets().isEmpty()) {
return true;
}
Permanent creature = game.getPermanent(id);
return creature != null
&& this.getTargets()
.stream()
.map(game::getPermanent)
.filter(Objects::nonNull)
.map(MageObject::getToughness)
.mapToInt(MageInt::getValue)
.findFirst()
.orElse(0) == creature.getToughness().getValue();
}
}

View file

@ -33,6 +33,7 @@ public final class Fallout extends ExpansionSet {
cards.add(new SetCardInfo("Radstorm", 37, Rarity.RARE, mage.cards.r.Radstorm.class));
cards.add(new SetCardInfo("Sol Ring", 359, Rarity.MYTHIC, mage.cards.s.SolRing.class));
cards.add(new SetCardInfo("Swamp", 321, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("V.A.T.S.", 50, Rarity.RARE, mage.cards.v.VATS.class));
cards.add(new SetCardInfo("Wasteland", 361, Rarity.RARE, mage.cards.w.Wasteland.class));
}
}