Cards discarded because of killed character are also triggering discard_from_play effects.

This commit is contained in:
marcins78@gmail.com
2011-09-12 13:26:54 +00:00
parent 2b101d9b8c
commit 830d93f0c9
2 changed files with 30 additions and 4 deletions

View File

@@ -4,11 +4,14 @@ import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult;
import java.util.LinkedList;
import java.util.List;
public class DiscardAttachedCardsEffect extends UnrespondableEffect {
public class DiscardAttachedCardsEffect extends AbstractEffect {
private PhysicalCard _card;
public DiscardAttachedCardsEffect(PhysicalCard card) {
@@ -16,13 +19,32 @@ public class DiscardAttachedCardsEffect extends UnrespondableEffect {
}
@Override
public void doPlayEffect(LotroGame game) {
public boolean canPlayEffect(LotroGame game) {
return true;
}
@Override
public EffectResult.Type getType() {
return EffectResult.Type.DISCARD_FROM_PLAY;
}
@Override
public String getText() {
return "Discard attached cards";
}
@Override
public EffectResult playEffect(LotroGame game) {
List<PhysicalCard> discardedCards = new LinkedList<PhysicalCard>();
GameState gameState = game.getGameState();
List<PhysicalCard> attachedCards = gameState.getAttachedCards(_card);
for (PhysicalCard attachedCard : attachedCards) {
gameState.stopAffecting(attachedCard);
gameState.removeCardFromZone(attachedCard);
gameState.addCardToZone(attachedCard, Zone.DISCARD);
discardedCards.add(attachedCard);
}
return new DiscardCardsFromPlayResult(discardedCards);
}
}

View File

@@ -1,5 +1,6 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
@@ -40,7 +41,10 @@ public class KillEffect extends AbstractEffect {
GameState gameState = game.getGameState();
gameState.stopAffecting(_card);
gameState.removeCardFromZone(_card);
gameState.addCardToZone(_card, Zone.DEAD);
if (_card.getBlueprint().getSide() == Side.FREE_PEOPLE)
gameState.addCardToZone(_card, Zone.DEAD);
else
gameState.addCardToZone(_card, Zone.DISCARD);
return new KillResult(_card);
}