fix additional test failures

This commit is contained in:
theelk801 2025-05-23 18:30:23 -04:00
parent 19bb4e7cd3
commit 501b7e882b
5 changed files with 45 additions and 40 deletions

View file

@ -132,16 +132,6 @@ public interface Permanent extends Card, Controllable {
boolean hasProtectionFrom(MageObject source, Game game);
/**
* @param attachment can be any object: card, permanent, token
* @param source can be null for default checks like state base
* @param game
* @param silentMode - use it to ignore warning message for users (e.g. for
* checking only)
* @return
*/
boolean cantBeAttachedBy(MageObject attachment, Ability source, Game game, boolean silentMode);
boolean wasControlledFromStartOfControllerTurn();
boolean hasSummoningSickness();

View file

@ -1363,32 +1363,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return false;
}
@Override
public boolean cantBeAttachedBy(MageObject attachment, Ability source, Game game, boolean silentMode) {
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
if ((!attachment.hasSubtype(SubType.AURA, game) || ability.removesAuras())
&& (!attachment.hasSubtype(SubType.EQUIPMENT, game) || ability.removesEquipment())
&& !attachment.getId().equals(ability.getAuraIdNotToBeRemoved())
&& !ability.canTarget(attachment, game)) {
return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(attachment.getId()));
}
}
boolean canAttach = true;
Permanent attachmentPermanent = game.getPermanent(attachment.getId());
// If attachment is an aura, ensures this permanent can still be legally enchanted, according to the enchantment's Enchant ability
if (attachment.hasSubtype(SubType.AURA, game)
&& attachmentPermanent != null
&& attachmentPermanent.getSpellAbility() != null
&& !attachmentPermanent.getSpellAbility().getTargets().isEmpty()) {
// Line of code below functionally gets the target of the aura's Enchant ability, then compares to this permanent. Enchant improperly implemented in XMage, see #9583
// Note: stillLegalTarget used exclusively to account for Dream Leash. Can be made canTarget in the event that that card is rewritten (and "stillLegalTarget" removed from TargetImpl).
canAttach = attachmentPermanent.getSpellAbility().getTargets().get(0).copy().withNotTarget(true).stillLegalTarget(attachmentPermanent.getControllerId(), this.getId(), source, game);
}
return !canAttach || game.getContinuousEffects().preventedByRuleModification(new StayAttachedEvent(this.getId(), attachment.getId(), source), null, game, silentMode);
}
@Override
public boolean destroy(Ability source, Game game) {
return destroy(source, game, false);

View file

@ -1204,6 +1204,11 @@ public class Spell extends StackObjectImpl implements Card {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public boolean cantBeAttachedBy(MageObject attachment, Ability source, Game game, boolean silentMode) {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public boolean addAttachment(UUID permanentId, Ability source, Game game) {
throw new UnsupportedOperationException("Not supported.");