* Fixed that player enchnatments were not correctly removed as they left the battlefield causing problems if they were cast again later in the game (fixes #1006).

This commit is contained in:
LevelX2 2015-06-05 00:50:31 +02:00
parent a50447c84d
commit 36eebfa317
4 changed files with 71 additions and 5 deletions

View file

@ -2058,6 +2058,11 @@ public abstract class GameImpl implements Game, Serializable {
Permanent attachedTo = getPermanent(perm.getAttachedTo());
if (attachedTo != null) {
attachedTo.removeAttachment(perm.getId(), this);
} else {
Player attachedToPlayer = getPlayer(perm.getAttachedTo());
if (attachedToPlayer != null) {
attachedToPlayer.removeAttachment(perm.getId(), this);
}
}
}
// check if it's a creature and must be removed from combat

View file

@ -789,12 +789,17 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public boolean removeFromBattlefield(Permanent permanent, Game game) {
permanent.removeFromCombat(game, false);
game.getBattlefield().removePermanent(permanent.getId());
if (permanent.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
if (attachedTo != null) {
attachedTo.removeAttachment(permanent.getId(), game);
} else {
Player attachedToPlayer = game.getPlayer(permanent.getAttachedTo());
if (attachedToPlayer != null) {
attachedToPlayer.removeAttachment(permanent.getId(), game);
}
}
}
if (permanent.getPairedCard() != null) {
Permanent pairedCard = game.getPermanent(permanent.getPairedCard());
@ -802,6 +807,7 @@ public abstract class PlayerImpl implements Player, Serializable {
pairedCard.clearPairedCard();
}
}
game.getBattlefield().removePermanent(permanent.getId());
return true;
}