check that attach is legal before proceeding
parent
4695a45140
commit
bdecf6770f
|
@ -697,18 +697,14 @@ public class MagicPermanent extends MagicObjectImpl implements MagicSource,Magic
|
|||
}
|
||||
|
||||
if (isAura()) {
|
||||
final MagicPlayAuraEvent auraEvent = cardDefinition.isAura() ?
|
||||
(MagicPlayAuraEvent)cardDefinition.getCardEvent() :
|
||||
MagicBestowActivation.BestowEvent;
|
||||
|
||||
//not targeting since Aura is already attached
|
||||
final MagicTargetChoice tchoice = new MagicTargetChoice(auraEvent.getTargetChoice(), false);
|
||||
final MagicTargetChoice tchoice = new MagicTargetChoice(getAuraTargetChoice(), false);
|
||||
if (!enchantedCreature.isValid() ||
|
||||
!game.isLegalTarget(getController(),this,tchoice,enchantedCreature) ||
|
||||
enchantedCreature.hasProtectionFrom(this)) {
|
||||
// 702.102e If an Aura with bestow is attached to an illegal object or player, it becomes unattached.
|
||||
// This is an exception to rule 704.5n.
|
||||
if (auraEvent == MagicBestowActivation.BestowEvent) {
|
||||
if (hasAbility(MagicAbility.Bestow)) {
|
||||
game.logAppendMessage(getController(),getName()+" becomes unattached.");
|
||||
game.addDelayedAction(new MagicAttachAction(this, MagicPermanent.NONE));
|
||||
} else {
|
||||
|
@ -1070,6 +1066,17 @@ public class MagicPermanent extends MagicObjectImpl implements MagicSource,Magic
|
|||
public boolean isAura() {
|
||||
return isEnchantment() && hasSubType(MagicSubType.Aura);
|
||||
}
|
||||
|
||||
public MagicTargetChoice getAuraTargetChoice() {
|
||||
if (isAura()) {
|
||||
final MagicPlayAuraEvent auraEvent = cardDefinition.isAura() ?
|
||||
(MagicPlayAuraEvent)cardDefinition.getCardEvent() :
|
||||
MagicBestowActivation.BestowEvent;
|
||||
return auraEvent.getTargetChoice();
|
||||
} else {
|
||||
return MagicTargetChoice.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpell() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package magic.model.action;
|
|||
import magic.ai.ArtificialScoringSystem;
|
||||
import magic.model.MagicGame;
|
||||
import magic.model.MagicPermanent;
|
||||
import magic.model.choice.MagicTargetChoice;
|
||||
import magic.model.mstatic.MagicPermanentStatic;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -56,6 +57,20 @@ public class MagicAttachAction extends MagicAction {
|
|||
if (!validAttachable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attachable.isEquipment() && creature.isValid() && !creature.isCreature()) {
|
||||
validAttachable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (attachable.isAura() && creature.isValid()) {
|
||||
final MagicTargetChoice tchoice = new MagicTargetChoice(attachable.getAuraTargetChoice(), false);
|
||||
if (game.isLegalTarget(attachable.getController(),attachable,tchoice,creature) == false) {
|
||||
validAttachable = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int score = ArtificialScoringSystem.getTurnScore(game);
|
||||
|
||||
oldAttachedCreature = getAttached();
|
||||
|
|
Loading…
Reference in New Issue