[CLU] Implement Rope (#11709)

* [CLU] Implement Rope

* Use ClueAbility

* Move CantBeBlockedByMoreThanOneAttachedEffect to common class with minor changes
This commit is contained in:
Cameron Merkel 2024-01-26 18:47:58 -06:00 committed by GitHub
parent 91312228d7
commit 9f4ec75c3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 115 additions and 127 deletions

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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));

View file

@ -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;
}
}