mirror of
https://github.com/correl/mage.git
synced 2025-01-13 19:11:33 +00:00
reworked auras which grant protection but don't remove themselves
This commit is contained in:
parent
4024acdb28
commit
eb4366013b
10 changed files with 125 additions and 231 deletions
|
@ -1,36 +1,29 @@
|
||||||
|
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.AttachmentType;
|
||||||
import mage.filter.FilterCard;
|
import mage.constants.CardType;
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LoneFox
|
* @author LoneFox
|
||||||
*/
|
*/
|
||||||
public final class BlackWard extends CardImpl {
|
public final class BlackWard extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCard filter = new FilterCard("black");
|
|
||||||
|
|
||||||
static {
|
|
||||||
filter.add(new ColorPredicate(ObjectColor.BLACK));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlackWard(UUID ownerId, CardSetInfo setInfo) {
|
public BlackWard(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||||
this.subtype.add(SubType.AURA);
|
this.subtype.add(SubType.AURA);
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
|
@ -38,12 +31,11 @@ public final class BlackWard extends CardImpl {
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
||||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
|
|
||||||
// Enchanted creature has protection from black. This effect doesn't remove Black Ward.
|
// Enchanted creature has protection from black. This effect doesn't remove Black Ward.
|
||||||
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
|
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||||
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
|
ProtectionAbility.from(ObjectColor.BLACK), AttachmentType.AURA
|
||||||
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
|
).setDoesntRemoveItself(true)));
|
||||||
effect.setText("Enchanted creature has protection from black. This effect doesn't remove {this}.");
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlackWard(final BlackWard card) {
|
private BlackWard(final BlackWard card) {
|
||||||
|
|
|
@ -1,36 +1,29 @@
|
||||||
|
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.AttachmentType;
|
||||||
import mage.filter.FilterCard;
|
import mage.constants.CardType;
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LoneFox
|
* @author LoneFox
|
||||||
*/
|
*/
|
||||||
public final class BlueWard extends CardImpl {
|
public final class BlueWard extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCard filter = new FilterCard("blue");
|
|
||||||
|
|
||||||
static {
|
|
||||||
filter.add(new ColorPredicate(ObjectColor.BLUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlueWard(UUID ownerId, CardSetInfo setInfo) {
|
public BlueWard(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||||
this.subtype.add(SubType.AURA);
|
this.subtype.add(SubType.AURA);
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
|
@ -38,12 +31,11 @@ public final class BlueWard extends CardImpl {
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
||||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
|
|
||||||
// Enchanted creature has protection from blue. This effect doesn't remove Blue Ward.
|
// Enchanted creature has protection from blue. This effect doesn't remove Blue Ward.
|
||||||
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
|
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||||
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
|
ProtectionAbility.from(ObjectColor.BLUE), AttachmentType.AURA
|
||||||
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
|
).setDoesntRemoveItself(true)));
|
||||||
effect.setText("Enchanted creature has protection from blue. This effect doesn't remove {this}.");
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlueWard(final BlueWard card) {
|
private BlueWard(final BlueWard card) {
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
@ -13,28 +10,20 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.AttachmentType;
|
import mage.constants.AttachmentType;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.SubType;
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LoneFox
|
* @author LoneFox
|
||||||
*/
|
*/
|
||||||
public final class GreenWard extends CardImpl {
|
public final class GreenWard extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCard filter = new FilterCard("green");
|
|
||||||
|
|
||||||
static {
|
|
||||||
filter.add(new ColorPredicate(ObjectColor.GREEN));
|
|
||||||
}
|
|
||||||
|
|
||||||
public GreenWard(UUID ownerId, CardSetInfo setInfo) {
|
public GreenWard(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||||
this.subtype.add(SubType.AURA);
|
this.subtype.add(SubType.AURA);
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
|
@ -42,12 +31,11 @@ public final class GreenWard extends CardImpl {
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
||||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
|
|
||||||
// Enchanted creature has protection from green. This effect doesn't remove Green Ward.
|
// Enchanted creature has protection from green. This effect doesn't remove Green Ward.
|
||||||
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
|
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||||
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
|
ProtectionAbility.from(ObjectColor.GREEN), AttachmentType.AURA
|
||||||
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
|
).setDoesntRemoveItself(true)));
|
||||||
effect.setText("Enchanted creature has protection from green. This effect doesn't remove {this}.");
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private GreenWard(final GreenWard card) {
|
private GreenWard(final GreenWard card) {
|
||||||
|
|
|
@ -1,56 +1,54 @@
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
|
||||||
import mage.constants.*;
|
|
||||||
import mage.filter.Filter;
|
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.filter.FilterObject;
|
|
||||||
import mage.filter.predicate.Predicate;
|
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.target.TargetPermanent;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.AttachmentType;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author noahg
|
* @author noahg
|
||||||
*/
|
*/
|
||||||
public final class PledgeOfLoyalty extends CardImpl {
|
public final class PledgeOfLoyalty extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterCard filter = new FilterCard("the colors of permanents you control");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(PledgeOfLoyaltyPredicate.instance);
|
||||||
|
}
|
||||||
|
|
||||||
public PledgeOfLoyalty(UUID ownerId, CardSetInfo setInfo) {
|
public PledgeOfLoyalty(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
|
||||||
|
|
||||||
this.subtype.add(SubType.AURA);
|
this.subtype.add(SubType.AURA);
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
this.addAbility(ability);
|
|
||||||
|
|
||||||
// Enchanted creature has protection from the colors of permanents you control. This effect doesn't remove Pledge of Loyalty.
|
// Enchanted creature has protection from the colors of permanents you control. This effect doesn't remove Pledge of Loyalty.
|
||||||
ProtectionAbility gainedAbility = new PledgeOfLoyaltyProtectionAbility();
|
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||||
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
|
new ProtectionAbility(filter), AttachmentType.AURA
|
||||||
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
|
).setDoesntRemoveItself(true)));
|
||||||
effect.setText("Enchanted creature has protection from the colors of permanents you control. This effect doesn't remove {this}.");
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PledgeOfLoyalty(final PledgeOfLoyalty card) {
|
private PledgeOfLoyalty(final PledgeOfLoyalty card) {
|
||||||
|
@ -61,73 +59,21 @@ public final class PledgeOfLoyalty extends CardImpl {
|
||||||
public PledgeOfLoyalty copy() {
|
public PledgeOfLoyalty copy() {
|
||||||
return new PledgeOfLoyalty(this);
|
return new PledgeOfLoyalty(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PledgeOfLoyaltyProtectionAbility extends ProtectionAbility {
|
enum PledgeOfLoyaltyPredicate implements ObjectSourcePlayerPredicate<MageObject> {
|
||||||
|
instance;
|
||||||
|
|
||||||
public PledgeOfLoyaltyProtectionAbility() {
|
@Override
|
||||||
super(new FilterCard());
|
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
|
||||||
}
|
ObjectColor color = input.getObject().getColor(game);
|
||||||
|
return color.hasColor()
|
||||||
public PledgeOfLoyaltyProtectionAbility(final PledgeOfLoyaltyProtectionAbility ability) {
|
&& game
|
||||||
super(ability);
|
.getBattlefield()
|
||||||
}
|
.getActivePermanents(
|
||||||
|
StaticFilters.FILTER_CONTROLLED_PERMANENT,
|
||||||
@Override
|
input.getPlayerId(), input.getSourceId(), game
|
||||||
public PledgeOfLoyaltyProtectionAbility copy() {
|
).stream()
|
||||||
return new PledgeOfLoyaltyProtectionAbility(this);
|
.anyMatch(permanent -> permanent.getColor(game).shares(color));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canTarget(MageObject source, Game game) {
|
|
||||||
ObjectColor color = new ObjectColor();
|
|
||||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(controllerId)) {
|
|
||||||
ObjectColor permanentColor = permanent.getColor(game);
|
|
||||||
if (permanentColor.isColorless()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (permanentColor.isBlack()) {
|
|
||||||
color.setBlack(true);
|
|
||||||
}
|
|
||||||
if (permanentColor.isBlue()) {
|
|
||||||
color.setBlue(true);
|
|
||||||
}
|
|
||||||
if (permanentColor.isGreen()) {
|
|
||||||
color.setGreen(true);
|
|
||||||
}
|
|
||||||
if (permanentColor.isRed()) {
|
|
||||||
color.setRed(true);
|
|
||||||
}
|
|
||||||
if (permanentColor.isWhite()) {
|
|
||||||
color.setWhite(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Predicate<MageObject>> colorPredicates = new ArrayList<>();
|
|
||||||
if (color.isBlack()) {
|
|
||||||
colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
|
|
||||||
}
|
|
||||||
if (color.isBlue()) {
|
|
||||||
colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
|
|
||||||
}
|
|
||||||
if (color.isGreen()) {
|
|
||||||
colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
|
|
||||||
}
|
|
||||||
if (color.isRed()) {
|
|
||||||
colorPredicates.add(new ColorPredicate(ObjectColor.RED));
|
|
||||||
}
|
|
||||||
if (color.isWhite()) {
|
|
||||||
colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
|
|
||||||
}
|
|
||||||
Filter protectionFilter = new FilterObject("the colors of permanents you control");
|
|
||||||
protectionFilter.add(Predicates.or(colorPredicates));
|
|
||||||
this.filter = protectionFilter;
|
|
||||||
return super.canTarget(source, game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "{this} has protection from the colors of permanents you control.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
|
|
||||||
package mage.cards.r;
|
package mage.cards.r;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
@ -13,28 +10,20 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.AttachmentType;
|
import mage.constants.AttachmentType;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.SubType;
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LoneFox
|
* @author LoneFox
|
||||||
*/
|
*/
|
||||||
public final class RedWard extends CardImpl {
|
public final class RedWard extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCard filter = new FilterCard("red");
|
|
||||||
|
|
||||||
static {
|
|
||||||
filter.add(new ColorPredicate(ObjectColor.RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
public RedWard(UUID ownerId, CardSetInfo setInfo) {
|
public RedWard(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||||
this.subtype.add(SubType.AURA);
|
this.subtype.add(SubType.AURA);
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
|
@ -42,12 +31,10 @@ public final class RedWard extends CardImpl {
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
||||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
// Enchanted creature has protection from red. This effect doesn't remove Red Ward.
|
|
||||||
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
|
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||||
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
|
ProtectionAbility.from(ObjectColor.RED), AttachmentType.AURA
|
||||||
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
|
).setDoesntRemoveItself(true)));
|
||||||
effect.setText("Enchanted creature has protection from red. This effect doesn't remove {this}.");
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RedWard(final RedWard card) {
|
private RedWard(final RedWard card) {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.t;
|
package mage.cards.t;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -12,31 +8,22 @@ import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.target.TargetPermanent;
|
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.AttachmentType;
|
import mage.constants.*;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
*/
|
*/
|
||||||
public final class TattooWard extends CardImpl {
|
public final class TattooWard extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCard filter = new FilterCard("enchantments");
|
|
||||||
|
|
||||||
static {
|
|
||||||
filter.add(CardType.ENCHANTMENT.getPredicate());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TattooWard(UUID ownerId, CardSetInfo setInfo) {
|
public TattooWard(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||||
|
|
||||||
|
@ -46,20 +33,22 @@ public final class TattooWard extends CardImpl {
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
this.addAbility(ability);
|
|
||||||
|
|
||||||
// Enchanted creature gets +1/+1 and has protection from enchantments. This effect doesn't remove Tattoo Ward.
|
// Enchanted creature gets +1/+1 and has protection from enchantments. This effect doesn't remove Tattoo Ward.
|
||||||
Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, 1, Duration.WhileOnBattlefield));
|
Ability ability = new SimpleStaticAbility(new BoostEnchantedEffect(
|
||||||
ProtectionAbility protectionAbility = new ProtectionAbility(filter);
|
1, 1, Duration.WhileOnBattlefield
|
||||||
protectionAbility.setAuraIdNotToBeRemoved(getId());
|
));
|
||||||
ability2.addEffect(new GainAbilityAttachedEffect(protectionAbility, AttachmentType.AURA, Duration.WhileOnBattlefield));
|
ability.addEffect(new GainAbilityAttachedEffect(
|
||||||
this.addAbility(ability2);
|
new ProtectionAbility(StaticFilters.FILTER_PERMANENT_ENCHANTMENTS),
|
||||||
|
AttachmentType.AURA, Duration.WhileOnBattlefield
|
||||||
|
).setDoesntRemoveItself(true));
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Sacrifice Tattoo Ward: Destroy target enchantment.
|
// Sacrifice Tattoo Ward: Destroy target enchantment.
|
||||||
Ability ability3 = new SimpleActivatedAbility(new DestroyTargetEffect(), new SacrificeSourceCost());
|
ability = new SimpleActivatedAbility(new DestroyTargetEffect(), new SacrificeSourceCost());
|
||||||
ability3.addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ENCHANTMENT));
|
ability.addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ENCHANTMENT));
|
||||||
this.addAbility(ability3);
|
this.addAbility(ability);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
|
|
||||||
package mage.cards.w;
|
package mage.cards.w;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
@ -13,28 +10,20 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.AttachmentType;
|
import mage.constants.AttachmentType;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.SubType;
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LoneFox
|
* @author LoneFox
|
||||||
*/
|
*/
|
||||||
public final class WhiteWard extends CardImpl {
|
public final class WhiteWard extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCard filter = new FilterCard("white");
|
|
||||||
|
|
||||||
static {
|
|
||||||
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public WhiteWard(UUID ownerId, CardSetInfo setInfo) {
|
public WhiteWard(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||||
this.subtype.add(SubType.AURA);
|
this.subtype.add(SubType.AURA);
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
|
@ -42,12 +31,11 @@ public final class WhiteWard extends CardImpl {
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
|
||||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
|
|
||||||
// Enchanted creature has protection from white. This effect doesn't remove White Ward.
|
// Enchanted creature has protection from white. This effect doesn't remove White Ward.
|
||||||
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
|
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||||
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
|
ProtectionAbility.from(ObjectColor.WHITE), AttachmentType.AURA
|
||||||
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
|
).setDoesntRemoveItself(true)));
|
||||||
effect.setText("Enchanted creature has protection from white. This effect doesn't remove {this}.");
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WhiteWard(final WhiteWard card) {
|
private WhiteWard(final WhiteWard card) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import mage.abilities.Mode;
|
||||||
import mage.abilities.TriggeredAbility;
|
import mage.abilities.TriggeredAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
@ -19,6 +20,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
protected AttachmentType attachmentType;
|
protected AttachmentType attachmentType;
|
||||||
protected boolean independentEffect;
|
protected boolean independentEffect;
|
||||||
protected String targetObjectName;
|
protected String targetObjectName;
|
||||||
|
protected boolean doesntRemoveItself = false;
|
||||||
|
|
||||||
public GainAbilityAttachedEffect(Ability ability, AttachmentType attachmentType) {
|
public GainAbilityAttachedEffect(Ability ability, AttachmentType attachmentType) {
|
||||||
this(ability, attachmentType, Duration.WhileOnBattlefield);
|
this(ability, attachmentType, Duration.WhileOnBattlefield);
|
||||||
|
@ -62,6 +64,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
this.attachmentType = effect.attachmentType;
|
this.attachmentType = effect.attachmentType;
|
||||||
this.independentEffect = effect.independentEffect;
|
this.independentEffect = effect.independentEffect;
|
||||||
this.targetObjectName = effect.targetObjectName;
|
this.targetObjectName = effect.targetObjectName;
|
||||||
|
this.doesntRemoveItself = effect.doesntRemoveItself;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,7 +85,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = null;
|
Permanent permanent;
|
||||||
if (affectedObjectsSet) {
|
if (affectedObjectsSet) {
|
||||||
permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
|
@ -93,9 +96,14 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
permanent = game.getPermanentOrLKIBattlefield(equipment.getAttachedTo());
|
permanent = game.getPermanentOrLKIBattlefield(equipment.getAttachedTo());
|
||||||
|
} else {
|
||||||
|
permanent = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
if (doesntRemoveItself && ability instanceof ProtectionAbility) {
|
||||||
|
((ProtectionAbility) ability).setAuraIdNotToBeRemoved(source.getSourceId());
|
||||||
|
}
|
||||||
permanent.addAbility(ability, source.getSourceId(), game);
|
permanent.addAbility(ability, source.getSourceId(), game);
|
||||||
afterGain(game, source, permanent, ability);
|
afterGain(game, source, permanent, ability);
|
||||||
}
|
}
|
||||||
|
@ -114,6 +122,11 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GainAbilityAttachedEffect setDoesntRemoveItself(boolean doesntRemoveItself) {
|
||||||
|
this.doesntRemoveItself = doesntRemoveItself;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
if (staticText != null && !staticText.isEmpty()) {
|
if (staticText != null && !staticText.isEmpty()) {
|
||||||
|
@ -138,6 +151,9 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
if (!duration.toString().isEmpty()) {
|
if (!duration.toString().isEmpty()) {
|
||||||
sb.append(' ').append(duration);
|
sb.append(' ').append(duration);
|
||||||
}
|
}
|
||||||
|
if (doesntRemoveItself) {
|
||||||
|
sb.append(" This effect doesn't remove {this}.");
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import mage.game.stack.StackObject;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
|
@ -1204,14 +1204,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
@Override
|
@Override
|
||||||
public boolean cantBeAttachedBy(MageObject attachment, Ability source, Game game, boolean silentMode) {
|
public boolean cantBeAttachedBy(MageObject attachment, Ability source, Game game, boolean silentMode) {
|
||||||
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
|
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
|
||||||
if (!(attachment.hasSubtype(SubType.AURA, game)
|
if ((!attachment.hasSubtype(SubType.AURA, game) || ability.removesAuras())
|
||||||
&& !ability.removesAuras())
|
&& (!attachment.hasSubtype(SubType.EQUIPMENT, game) || ability.removesEquipment())
|
||||||
&& !(attachment.hasSubtype(SubType.EQUIPMENT, game)
|
&& !attachment.getId().equals(ability.getAuraIdNotToBeRemoved())
|
||||||
&& !ability.removesEquipment())) {
|
&& !ability.canTarget(attachment, game)) {
|
||||||
if (!attachment.getId().equals(ability.getAuraIdNotToBeRemoved())
|
return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(attachment.getId()));
|
||||||
&& !ability.canTarget(attachment, game)) {
|
|
||||||
return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(attachment.getId()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return game.getContinuousEffects().preventedByRuleModification(new StayAttachedEvent(this.getId(), attachment.getId(), source), null, game, silentMode);
|
return game.getContinuousEffects().preventedByRuleModification(new StayAttachedEvent(this.getId(), attachment.getId(), source), null, game, silentMode);
|
||||||
|
|
Loading…
Reference in a new issue