fixed emblems not being removed when a player leaves a multiplayer game

This commit is contained in:
Evan Kranzler 2017-09-28 19:41:31 -04:00
parent f177ce14d2
commit 851b729b0e
2 changed files with 15 additions and 1 deletions

View file

@ -2361,7 +2361,9 @@ public abstract class GameImpl implements Game, Serializable {
//Remove all emblems the player controls
for (Iterator<CommandObject> it = this.getState().getCommand().iterator(); it.hasNext();) {
if (it.next().getControllerId().equals(playerId)) {
CommandObject obj = it.next();
if (obj instanceof Emblem && obj.getControllerId().equals(playerId)) {
((Emblem) obj).discardEffects();// This may not be the best fix but it works
it.remove();
}
}

View file

@ -40,6 +40,8 @@ import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.text.TextPart;
import mage.cards.Card;
import mage.cards.FrameStyle;
@ -275,6 +277,16 @@ public class Emblem implements CommandObject {
public void setIsAllCreatureTypes(boolean value) {
}
public void discardEffects() {
for (Ability ability : abilites) {
for (Effect effect : ability.getEffects()) {
if (effect instanceof ContinuousEffect) {
((ContinuousEffect) effect).discard();
}
}
}
}
@Override
public List<TextPart> getTextParts() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.