From 9f4ec75c3baca3c164a2565aef6b51cdb8f3dbca Mon Sep 17 00:00:00 2001 From: Cameron Merkel <44722506+Cguy7777@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:47:58 -0600 Subject: [PATCH] [CLU] Implement Rope (#11709) * [CLU] Implement Rope * Use ClueAbility * Move CantBeBlockedByMoreThanOneAttachedEffect to common class with minor changes --- .../src/mage/cards/a/AlphaAuthority.java | 62 +----------------- Mage.Sets/src/mage/cards/r/Rope.java | 52 +++++++++++++++ .../src/mage/cards/v/VorracBattlehorns.java | 65 +------------------ .../src/mage/cards/w/WolfridersSaddle.java | 6 +- .../src/mage/sets/RavnicaClueEdition.java | 1 + ...tBeBlockedByMoreThanOneAttachedEffect.java | 56 ++++++++++++++++ 6 files changed, 115 insertions(+), 127 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/r/Rope.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAttachedEffect.java diff --git a/Mage.Sets/src/mage/cards/a/AlphaAuthority.java b/Mage.Sets/src/mage/cards/a/AlphaAuthority.java index 0b52b679c5a..4d38e6629b4 100644 --- a/Mage.Sets/src/mage/cards/a/AlphaAuthority.java +++ b/Mage.Sets/src/mage/cards/a/AlphaAuthority.java @@ -4,20 +4,17 @@ package mage.cards.a; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.combat.CantBeBlockedByMoreThanOneAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.HexproofAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; -import mage.util.CardUtil; /** * @author LevelX2 @@ -38,7 +35,7 @@ public final class AlphaAuthority extends CardImpl { // Enchanted creature has hexproof and can't be blocked by more than one creature. ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(HexproofAbility.getInstance(), AttachmentType.AURA, Duration.WhileOnBattlefield)); - Effect effect = new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.AURA, 1); + Effect effect = new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.AURA); effect.setText("and can't be blocked by more than one creature"); ability.addEffect(effect); this.addAbility(ability); @@ -53,58 +50,3 @@ public final class AlphaAuthority extends CardImpl { return new AlphaAuthority(this); } } - -class CantBeBlockedByMoreThanOneAttachedEffect extends ContinuousEffectImpl { - - protected int amount; - protected AttachmentType attachmentType; - - public CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType attachmentType, int amount) { - this(attachmentType, amount, Duration.WhileOnBattlefield); - } - - public CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType attachmentType, int amount, Duration duration) { - super(duration, Outcome.Benefit); - this.amount = amount; - this.attachmentType = attachmentType; - staticText = attachmentType.verb() + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount == 1 ? "" : "s"); - } - - private CantBeBlockedByMoreThanOneAttachedEffect(final CantBeBlockedByMoreThanOneAttachedEffect effect) { - super(effect); - this.amount = effect.amount; - this.attachmentType = effect.attachmentType; - } - - @Override - public CantBeBlockedByMoreThanOneAttachedEffect copy() { - return new CantBeBlockedByMoreThanOneAttachedEffect(this); - } - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - switch (layer) { - case RulesEffects: - Permanent attachment = game.getPermanent(source.getSourceId()); - if (attachment != null && attachment.getAttachedTo() != null) { - Permanent perm = game.getPermanent(attachment.getAttachedTo()); - if (perm != null) { - perm.setMaxBlockedBy(amount); - return true; - } - } - break; - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.RulesEffects; - } -} diff --git a/Mage.Sets/src/mage/cards/r/Rope.java b/Mage.Sets/src/mage/cards/r/Rope.java new file mode 100644 index 00000000000..e87557138ff --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/Rope.java @@ -0,0 +1,52 @@ +package mage.cards.r; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.combat.CantBeBlockedByMoreThanOneAttachedEffect; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.keyword.EquipAbility; +import mage.abilities.keyword.ReachAbility; +import mage.abilities.token.ClueAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; + +import java.util.UUID; + +/** + * @author Cguy7777 + */ +public final class Rope extends CardImpl { + + public Rope(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{G}"); + + this.subtype.add(SubType.CLUE); + this.subtype.add(SubType.EQUIPMENT); + + // Equipped creature gets +1/+2, has reach, and can't be blocked by more than one creature. + Ability boostAbility = new SimpleStaticAbility(new BoostEquippedEffect(1, 2)); + boostAbility.addEffect(new GainAbilityAttachedEffect(ReachAbility.getInstance(), AttachmentType.EQUIPMENT) + .setText(", has reach")); + boostAbility.addEffect(new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.EQUIPMENT) + .setText(", and can't be blocked by more than one creature")); + this.addAbility(boostAbility); + + // {2}, Sacrifice Rope: Draw a card. + this.addAbility(new ClueAbility(true)); + + // Equip {3} + this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(3), false)); + } + + private Rope(final Rope card) { + super(card); + } + + @Override + public Rope copy() { + return new Rope(this); + } +} diff --git a/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java b/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java index 63dbd0bdabf..48ea60709af 100644 --- a/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java +++ b/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java @@ -5,8 +5,8 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.GenericManaCost; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; +import mage.abilities.effects.common.combat.CantBeBlockedByMoreThanOneAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EquipAbility; import mage.abilities.keyword.TrampleAbility; @@ -15,14 +15,8 @@ import mage.cards.CardSetInfo; import mage.constants.AttachmentType; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.Layer; import mage.constants.Outcome; -import mage.constants.SubLayer; import mage.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.util.CardUtil; /** * @@ -36,7 +30,7 @@ public final class VorracBattlehorns extends CardImpl { // Equipped creature has trample and can't be blocked by more than one creature. Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(TrampleAbility.getInstance(), AttachmentType.EQUIPMENT)); - Effect effect = new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.EQUIPMENT, 1); + Effect effect = new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.EQUIPMENT); effect.setText("and can't be blocked by more than one creature"); ability.addEffect(effect); this.addAbility(ability); @@ -54,58 +48,3 @@ public final class VorracBattlehorns extends CardImpl { return new VorracBattlehorns(this); } } - -class CantBeBlockedByMoreThanOneAttachedEffect extends ContinuousEffectImpl { - - protected int amount; - protected AttachmentType attachmentType; - - public CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType attachmentType, int amount) { - this(attachmentType, amount, Duration.WhileOnBattlefield); - } - - public CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType attachmentType, int amount, Duration duration) { - super(duration, Outcome.Benefit); - this.amount = amount; - this.attachmentType = attachmentType; - staticText = attachmentType.verb() + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount==1 ?"":"s"); - } - - private CantBeBlockedByMoreThanOneAttachedEffect(final CantBeBlockedByMoreThanOneAttachedEffect effect) { - super(effect); - this.amount = effect.amount; - this.attachmentType = effect.attachmentType; - } - - @Override - public CantBeBlockedByMoreThanOneAttachedEffect copy() { - return new CantBeBlockedByMoreThanOneAttachedEffect(this); - } - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - switch (layer) { - case RulesEffects: - Permanent attachment = game.getPermanent(source.getSourceId()); - if (attachment != null && attachment.getAttachedTo() != null) { - Permanent perm = game.getPermanent(attachment.getAttachedTo()); - if (perm != null) { - perm.setMaxBlockedBy(amount); - return true; - } - } - break; - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.RulesEffects; - } -} diff --git a/Mage.Sets/src/mage/cards/w/WolfridersSaddle.java b/Mage.Sets/src/mage/cards/w/WolfridersSaddle.java index 75d0963b17c..35cda7f0bd2 100644 --- a/Mage.Sets/src/mage/cards/w/WolfridersSaddle.java +++ b/Mage.Sets/src/mage/cards/w/WolfridersSaddle.java @@ -4,9 +4,8 @@ import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.CreateTokenAttachSourceEffect; -import mage.abilities.effects.common.combat.CantBeBlockedByMoreThanOneSourceEffect; +import mage.abilities.effects.common.combat.CantBeBlockedByMoreThanOneAttachedEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect; -import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EquipAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -32,8 +31,7 @@ public final class WolfridersSaddle extends CardImpl { // Equipped creature gets +1/+1 and can't be blocked by more than one creature. Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(1, 1)); - ability.addEffect(new GainAbilityAttachedEffect( - new SimpleStaticAbility(new CantBeBlockedByMoreThanOneSourceEffect()), AttachmentType.EQUIPMENT + ability.addEffect(new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.EQUIPMENT ).setText("and can't be blocked by more than one creature")); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/RavnicaClueEdition.java b/Mage.Sets/src/mage/sets/RavnicaClueEdition.java index cf548d05c12..064c76c924e 100644 --- a/Mage.Sets/src/mage/sets/RavnicaClueEdition.java +++ b/Mage.Sets/src/mage/sets/RavnicaClueEdition.java @@ -186,6 +186,7 @@ public final class RavnicaClueEdition extends ExpansionSet { cards.add(new SetCardInfo("Roc Charger", 70, Rarity.UNCOMMON, mage.cards.r.RocCharger.class)); cards.add(new SetCardInfo("Roofstalker Wight", 121, Rarity.COMMON, mage.cards.r.RoofstalkerWight.class)); cards.add(new SetCardInfo("Rootborn Defenses", 71, Rarity.COMMON, mage.cards.r.RootbornDefenses.class)); + cards.add(new SetCardInfo("Rope", 11, Rarity.UNCOMMON, mage.cards.r.Rope.class)); cards.add(new SetCardInfo("Sacred Foundry", 279, Rarity.RARE, mage.cards.s.SacredFoundry.class)); cards.add(new SetCardInfo("Sage's Row Savant", 97, Rarity.COMMON, mage.cards.s.SagesRowSavant.class)); cards.add(new SetCardInfo("Sauroform Hybrid", 173, Rarity.COMMON, mage.cards.s.SauroformHybrid.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAttachedEffect.java new file mode 100644 index 00000000000..ba33d007780 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAttachedEffect.java @@ -0,0 +1,56 @@ +package mage.abilities.effects.common.combat; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; + +/** + * @author LevelX2, edited by Cguy7777 + */ +public class CantBeBlockedByMoreThanOneAttachedEffect extends ContinuousEffectImpl { + + protected final int amount; + protected final AttachmentType attachmentType; + + public CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType attachmentType) { + this(attachmentType, 1); + } + + public CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType attachmentType, int amount) { + this(attachmentType, amount, Duration.WhileOnBattlefield); + } + + public CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType attachmentType, int amount, Duration duration) { + super(duration, Layer.RulesEffects, SubLayer.NA, Outcome.Benefit); + this.amount = amount; + this.attachmentType = attachmentType; + staticText = attachmentType.verb() + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount == 1 ? "" : "s"); + } + + private CantBeBlockedByMoreThanOneAttachedEffect(final CantBeBlockedByMoreThanOneAttachedEffect effect) { + super(effect); + this.amount = effect.amount; + this.attachmentType = effect.attachmentType; + } + + @Override + public CantBeBlockedByMoreThanOneAttachedEffect copy() { + return new CantBeBlockedByMoreThanOneAttachedEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent attachment = game.getPermanent(source.getSourceId()); + if (attachment != null && attachment.getAttachedTo() != null) { + Permanent perm = game.getPermanent(attachment.getAttachedTo()); + if (perm != null) { + perm.setMaxBlockedBy(amount); + return true; + } + } + return false; + } +}