forked from External/mage
Improve attachment to permanent logic; implement [PIP] Codsworth, Handy Helper (#12098)
* [PIP] Implement Codsworth, Handy Helper * Fix Codsworth and Halvar * Write tests for attachments * Fix auras going to graveyard when attaching to illegal targets * Fix Captured by the Consulate interaction * Fix failing tests, add additional test * Add source name to log message * Implement requested changes * Revert removed null check * Remove filter check, clean up code * Add additional test * Fix failing roles test * Account for all current attachment edge cases * Implement rule 303.4g * Apply requested changes
This commit is contained in:
parent
9fcbfdeac6
commit
8d249aa691
10 changed files with 580 additions and 20 deletions
|
|
@ -21,7 +21,7 @@ import mage.constants.*;
|
|||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.counters.Counters;
|
||||
import mage.filter.FilterOpponent;
|
||||
import mage.filter.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameState;
|
||||
import mage.game.ZoneChangeInfo;
|
||||
|
|
@ -1355,7 +1355,20 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(attachment.getId()));
|
||||
}
|
||||
}
|
||||
return game.getContinuousEffects().preventedByRuleModification(new StayAttachedEvent(this.getId(), attachment.getId(), source), null, game, silentMode);
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue