mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
* Fixed a bug that attach effects were not stopped during resolution if the object to attach doe sno longer exist.
This commit is contained in:
parent
167bf8be3c
commit
1e7f82bb3c
3 changed files with 74 additions and 9 deletions
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -61,14 +62,17 @@ public class AttachEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
return permanent.addAttachment(source.getSourceId(), game);
|
||||
}
|
||||
else {
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
return player.addAttachment(source.getSourceId(), game);
|
||||
Permanent sourcePermanent = (Permanent)source.getSourceObjectIfItStillExists(game);
|
||||
if (sourcePermanent != null) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
return permanent.addAttachment(source.getSourceId(), game);
|
||||
}
|
||||
else {
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
return player.addAttachment(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue