fixed some abilities not being properly copiable

This commit is contained in:
Evan Kranzler 2020-10-26 18:18:35 -04:00
parent a317a875e7
commit 1c4de38b92
5 changed files with 104 additions and 45 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
@ -11,31 +9,35 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.BlockedByIdPredicate;
import mage.filter.predicate.permanent.BlockingAttackerIdPredicate;
import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class AlmsBeast extends CardImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent();
static {
filter.add(BlockingOrBlockedBySourcePredicate.EITHER);
}
public AlmsBeast(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{B}");
this.subtype.add(SubType.BEAST);
this.power = new MageInt(6);
this.toughness = new MageInt(6);
// Creatures blocking or blocked by Alms Beast have lifelink.
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()),
new BlockingAttackerIdPredicate(this.getId())));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(LifelinkAbility.getInstance(), Duration.WhileOnBattlefield, filter,
"Creatures blocking or blocked by {this} have lifelink")));
this.addAbility(new SimpleStaticAbility(new GainAbilityAllEffect(
LifelinkAbility.getInstance(), Duration.WhileOnBattlefield,
filter, "Creatures blocking or blocked by {this} have lifelink"
)));
}
public AlmsBeast(final AlmsBeast card) {

View file

@ -12,12 +12,10 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.target.Target;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.target.common.TargetCardInGraveyardOrBattlefield;
import java.util.UUID;
@ -27,7 +25,13 @@ import java.util.UUID;
*/
public final class AngelOfSerenity extends CardImpl {
private static final String rule = "you may exile up to three other target creatures from the battlefield and/or creature cards from graveyards.";
private static final String rule = "you may exile up to three other target creatures " +
"from the battlefield and/or creature cards from graveyards.";
private static final FilterPermanent filter = new FilterCreaturePermanent("other target creatures");
static {
filter.add(AnotherPredicate.instance);
}
public AngelOfSerenity(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}{W}");
@ -40,12 +44,12 @@ public final class AngelOfSerenity extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When Angel of Serenity enters the battlefield, you may exile up to three other target creatures from the battlefield and/or creature cards from graveyards.
FilterCreaturePermanent filterBattle = new FilterCreaturePermanent("other target creatures");
filterBattle.add(Predicates.not(new CardIdPredicate(this.getId())));
FilterCreatureCard filterGrave = StaticFilters.FILTER_CARD_CREATURE;
Ability ability = new EntersBattlefieldTriggeredAbility(new ExileTargetForSourceEffect().setText(rule), true);
Target target = new TargetCardInGraveyardOrBattlefield(0, 3, filterGrave, filterBattle);
ability.addTarget(target);
Ability ability = new EntersBattlefieldTriggeredAbility(
new ExileTargetForSourceEffect().setText(rule), true
);
ability.addTarget(new TargetCardInGraveyardOrBattlefield(
0, 3, StaticFilters.FILTER_CARD_CREATURE, filter
));
this.addAbility(ability);
// When Angel of Serenity leaves the battlefield, return the exiled cards to their owners' hands.

View file

@ -11,6 +11,7 @@ import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterEquipmentPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.permanent.AttachedToPredicate;
@ -78,9 +79,9 @@ class ArmoryAutomatonEffect extends OneShotEffect {
if (player != null && sourcePermanent != null) {
// dynamic filter (can't selects own attaches and can't selects twice)
FilterPermanent currentFilter = filter.copy();
FilterPermanent currentFilter = new FilterEquipmentPermanent();
FilterPermanent filterSourceId = new FilterPermanent();
filterSourceId.add(new CardIdPredicate(this.getId()));
filterSourceId.add(new CardIdPredicate(source.getSourceId()));
currentFilter.add(Predicates.not(new AttachedToPredicate(filterSourceId)));
int countBattlefield = game.getBattlefield().getAllActivePermanents(currentFilter, game).size();

View file

@ -1,48 +1,51 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class BorderlandBehemoth extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.GIANT);
static {
filter.add(AnotherPredicate.instance);
}
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter, 4);
public BorderlandBehemoth(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{R}");
this.subtype.add(SubType.GIANT, SubType.WARRIOR);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Borderland Behemoth gets +4/+4 for each other Giant you control.
FilterCreaturePermanent filter = new FilterCreaturePermanent("other Giant you control");
filter.add(SubType.GIANT.getPredicate());
filter.add(Predicates.not(new PermanentIdPredicate(this.getId())));
filter.add(TargetController.YOU.getControllerPredicate());
DynamicValue xValue = new PermanentsOnBattlefieldCount(filter, 4);
Effect effect = new BoostSourceEffect(xValue, xValue, Duration.WhileOnBattlefield, false);
effect.setText("{this} gets +4/+4 for each other Giant you control");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new BoostSourceEffect(
xValue, xValue, Duration.WhileOnBattlefield, false
).setText("{this} gets +4/+4 for each other Giant you control")));
}
public BorderlandBehemoth(final BorderlandBehemoth card) {
private BorderlandBehemoth(final BorderlandBehemoth card) {
super(card);
}

View file

@ -0,0 +1,49 @@
package mage.filter.predicate.permanent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public enum BlockingOrBlockedBySourcePredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Permanent>> {
BLOCKING,
BLOCKED_BY,
EITHER;
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
return game
.getCombat()
.getGroups()
.stream()
.anyMatch(combatGroup -> checkBlocks(combatGroup, input.getSourceId(), input.getObject().getId()));
}
private boolean checkBlocks(CombatGroup combatGroup, UUID thisCreature, UUID otherCreature) {
switch (this) {
case BLOCKING:
return isBlocking(combatGroup, otherCreature, thisCreature);
case BLOCKED_BY:
return isBlocking(combatGroup, thisCreature, otherCreature);
case EITHER:
return isBlocking(combatGroup, otherCreature, thisCreature)
|| isBlocking(combatGroup, thisCreature, otherCreature);
}
return false;
}
private static final boolean isBlocking(CombatGroup combatGroup, UUID id1, UUID id2) {
return combatGroup.getBlockers().contains(id1) && combatGroup.getAttackers().contains(id2);
}
@Override
public String toString() {
return "Blocking or blocked by";
}
}