[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

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