diff --git a/Mage.Sets/src/mage/cards/b/BillPotts.java b/Mage.Sets/src/mage/cards/b/BillPotts.java new file mode 100644 index 00000000000..ad9402aa5a0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BillPotts.java @@ -0,0 +1,124 @@ +package mage.cards.b; + +import mage.MageInt; +import mage.MageItem; +import mage.abilities.Ability; +import mage.abilities.Abilities; +import mage.abilities.AbilitiesImpl; +import mage.abilities.Mode; +import mage.abilities.common.ActivateAbilityTriggeredAbility; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.common.CopyStackObjectEffect; +import mage.abilities.meta.OrTriggeredAbility; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.abilities.keyword.DoctorsCompanionAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SetTargetPointer; +import mage.constants.Zone; +import mage.filter.common.FilterInstantOrSorcerySpell; +import mage.filter.FilterSpell; +import mage.filter.FilterStackObject; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.stack.StackObject; +import mage.game.stack.Spell; +import mage.target.Target; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.UUID; + +/** + * + * @author padfoot + */ +public final class BillPotts extends CardImpl { + + private static final FilterSpell filterInstantOrSorcery = new FilterInstantOrSorcerySpell("an instant or sorcery that targets only {this}"); + private static final FilterStackObject filterAbility = new FilterStackObject("an ability that targets only {this}"); + + static { + filterInstantOrSorcery.add(BillPottsPredicate.instance); + filterAbility.add(BillPottsPredicate.instance); + } + + public BillPotts(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // Whenever you cast an instant or sorcery spell that targets only Bill Potts or activate an ability that targets only Bill Potts, copy that spell or ability. You may choose new targets for the copy. This ability triggers only once each turn. + this.addAbility(new OrTriggeredAbility( + Zone.BATTLEFIELD, + new CopyStackObjectEffect("that spell or ability"), + false, + "", + new SpellCastControllerTriggeredAbility( + null, + filterInstantOrSorcery, + false, + SetTargetPointer.SPELL + ), + new ActivateAbilityTriggeredAbility( + null, + filterAbility, + SetTargetPointer.SPELL + ) + ).setTriggersLimitEachTurn(1)); + + // Doctor's companion + this.addAbility(DoctorsCompanionAbility.getInstance()); + + } + + private BillPotts(final BillPotts card) { + super(card); + } + + @Override + public BillPotts copy() { + return new BillPotts(this); + } +} + +enum BillPottsPredicate implements ObjectSourcePlayerPredicate { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + List oneTargetList = Arrays.asList(input.getSourceId()); + return (makeStream(input, game).collect(Collectors.toList()).equals(oneTargetList)); + } + + private static final Stream makeStream(ObjectSourcePlayer input, Game game) { + Abilities objectAbilities = new AbilitiesImpl<>(); + if (input.getObject() instanceof Spell) { + objectAbilities.addAll(((Spell) input.getObject()).getSpellAbilities()); + } else { + objectAbilities.add(input.getObject().getStackAbility()); + } + return objectAbilities + .stream() + .map(Ability::getModes) + .flatMap(m -> m.getSelectedModes().stream().map(m::get)) + .filter(Objects::nonNull) + .map(Mode::getTargets) + .flatMap(Collection::stream) + .filter(t -> !t.isNotTarget()) + .map(Target::getTargets) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .distinct(); + } +} diff --git a/Mage.Sets/src/mage/sets/DoctorWho.java b/Mage.Sets/src/mage/sets/DoctorWho.java index e0a8dc21424..22e233305a0 100644 --- a/Mage.Sets/src/mage/sets/DoctorWho.java +++ b/Mage.Sets/src/mage/sets/DoctorWho.java @@ -95,10 +95,10 @@ public final class DoctorWho extends ExpansionSet { cards.add(new SetCardInfo("Bessie, the Doctor's Roadster", 776, Rarity.RARE, mage.cards.b.BessieTheDoctorsRoadster.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Bigger on the Inside", 115, Rarity.UNCOMMON, mage.cards.b.BiggerOnTheInside.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Bigger on the Inside", 720, Rarity.UNCOMMON, mage.cards.b.BiggerOnTheInside.class, NON_FULL_USE_VARIOUS)); - //cards.add(new SetCardInfo("Bill Potts", 379, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); - //cards.add(new SetCardInfo("Bill Potts", 681, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); - //cards.add(new SetCardInfo("Bill Potts", 76, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); - //cards.add(new SetCardInfo("Bill Potts", 970, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Bill Potts", 379, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Bill Potts", 681, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Bill Potts", 76, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Bill Potts", 970, Rarity.RARE, mage.cards.b.BillPotts.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Blasphemous Act", 1063, Rarity.RARE, mage.cards.b.BlasphemousAct.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Blasphemous Act", 224, Rarity.RARE, mage.cards.b.BlasphemousAct.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Blasphemous Act", 472, Rarity.RARE, mage.cards.b.BlasphemousAct.class, NON_FULL_USE_VARIOUS));