Merge pull request #5276 from magefree/FixBestowTest

Fix bestow test
This commit is contained in:
LevelX2 2018-09-14 14:26:39 +02:00 committed by GitHub
commit 68dc82342c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 5 deletions

View file

@ -1987,7 +1987,8 @@ public abstract class GameImpl implements Game, Serializable {
if (card != null && card.isCreature()) {
UUID wasAttachedTo = perm.getAttachedTo();
perm.attachTo(null, this);
BestowAbility.becomeCreature(perm, this);
//moved to mage.game.permanent.PermanentImpl::detachAllAttachments
//BestowAbility.becomeCreature(perm, this);
fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId()));
} else if (movePermanentToGraveyardWithInfo(perm)) {
somethingHappened = true;

View file

@ -1437,6 +1437,24 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return color;
}
//20180810 - 701.3d
//If an object leaves the zone it's in, all attached permanents become unattached
//note that this code doesn't actually detach anything, and is a bit of a bandaid
public void detachAllAttachments(Game game) {
for(UUID attachmentId : getAttachments()) {
Permanent attachment = game.getPermanent(attachmentId);
Card attachmentCard = game.getCard(attachmentId);
if(attachment != null && attachmentCard != null) {
//make bestow cards and licids into creatures
//aura test to stop bludgeon brawl shenanigans from using this code
//consider adding code to handle that case?
if(attachment.hasSubtype(SubType.AURA, game) && attachmentCard.isCreature()) {
BestowAbility.becomeCreature(attachment, game);
}
}
}
}
@Override
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List<UUID> appliedEffects) {
Zone fromZone = game.getState().getZone(objectId);
@ -1449,7 +1467,10 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
} else {
zoneChangeInfo = new ZoneChangeInfo(event);
}
return ZonesHandler.moveCard(zoneChangeInfo, game);
boolean successfullyMoved = ZonesHandler.moveCard(zoneChangeInfo, game);
//20180810 - 701.3d
detachAllAttachments(game);
return successfullyMoved;
}
return false;
}
@ -1459,7 +1480,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
Zone fromZone = game.getState().getZone(objectId);
ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, ownerId, fromZone, Zone.EXILED, appliedEffects);
ZoneChangeInfo.Exile info = new ZoneChangeInfo.Exile(event, exileId, name);
return ZonesHandler.moveCard(info, game);
boolean successfullyMoved = ZonesHandler.moveCard(info, game);
//20180810 - 701.3d
detachAllAttachments(game);
return successfullyMoved;
}
}