Cleaning up the floating-attached fix from phallen and applying it to PutCardsFromPlayOnTopOfDeck as well.

This commit is contained in:
Christian 'ketura' McCarty
2025-04-01 21:34:53 -05:00
parent 436a9d97b5
commit 5c793e2943
2 changed files with 35 additions and 13 deletions

View File

@@ -9,12 +9,13 @@ import com.gempukku.lotro.cards.build.field.effect.EffectAppender;
import com.gempukku.lotro.cards.build.field.effect.EffectAppenderProducer;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.CardResolver;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.ValueResolver;
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.GameUtils;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.logic.effects.DiscardUtils;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult;
import org.json.simple.JSONObject;
@@ -46,32 +47,34 @@ public class PutCardsFromPlayOnBottomOfDeck implements EffectAppenderProducer {
"Choose card to put beneath draw deck", cards, 1, 1) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
PhysicalCard card = selectedCards.iterator().next();
var card = selectedCards.iterator().next();
// Removed from remaining
for(var effect : result) {
((ChooseArbitraryCardsEffect)effect).removeCard(card);
}
GameState gameState = game.getGameState();
var gameState = game.getGameState();
Set<PhysicalCard> discardedFromPlayCards = new HashSet<>();
Set<PhysicalCard> toMoveToDiscardCards = new HashSet<>();
var discardedFromPlayCards = new HashSet<PhysicalCard>();
var toMoveToDiscardCards = new HashSet<PhysicalCard>();
DiscardUtils.cardsToChangeZones(game, Collections.singleton(card), discardedFromPlayCards, toMoveToDiscardCards);
Set<PhysicalCard> removeFromPlay = new HashSet<>(toMoveToDiscardCards);
var removeFromPlay = new HashSet<>(toMoveToDiscardCards);
removeFromPlay.add(card);
gameState.removeCardsFromZone(card.getOwner(), removeFromPlay);
for (PhysicalCard attachedCard : toMoveToDiscardCards)
for (PhysicalCard attachedCard : toMoveToDiscardCards) {
gameState.addCardToZone(game, attachedCard, Zone.DISCARD);
}
gameState.sendMessage(card.getOwner() + " puts " + GameUtils.getCardLink(card) + " from play on the bottom of deck");
gameState.putCardOnBottomOfDeck(card);
for (PhysicalCard discardedCard : discardedFromPlayCards)
for (PhysicalCard discardedCard : discardedFromPlayCards) {
game.getActionsEnvironment().emitEffectResult(new DiscardCardsFromPlayResult(null, null, discardedCard));
}
}
});
}

View File

@@ -9,13 +9,15 @@ import com.gempukku.lotro.cards.build.field.effect.EffectAppender;
import com.gempukku.lotro.cards.build.field.effect.EffectAppenderProducer;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.CardResolver;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.ValueResolver;
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.GameUtils;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.logic.effects.DiscardUtils;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult;
import org.json.simple.JSONObject;
import java.util.*;
@@ -45,17 +47,34 @@ public class PutCardsFromPlayOnTopOfDeck implements EffectAppenderProducer {
"Choose card to put on top of deck", cards, 1, 1) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
PhysicalCard card = selectedCards.iterator().next();
var card = selectedCards.iterator().next();
// Removed from remaining
for(var effect : result) {
((ChooseArbitraryCardsEffect)effect).removeCard(card);
}
GameState gameState = game.getGameState();
gameState.sendMessage(card.getOwner() + " puts " + GameUtils.getCardLink(card) + " from play on the top of deck");
var gameState = game.getGameState();
gameState.removeCardsFromZone(card.getOwner(), Collections.singleton(card));
var discardedFromPlayCards = new HashSet<PhysicalCard>();
var toMoveToDiscardCards = new HashSet<PhysicalCard>();
DiscardUtils.cardsToChangeZones(game, Collections.singleton(card), discardedFromPlayCards, toMoveToDiscardCards);
var removeFromPlay = new HashSet<>(toMoveToDiscardCards);
removeFromPlay.add(card);
gameState.removeCardsFromZone(card.getOwner(), removeFromPlay);
for (PhysicalCard attachedCard : toMoveToDiscardCards) {
gameState.addCardToZone(game, attachedCard, Zone.DISCARD);
}
gameState.sendMessage(card.getOwner() + " puts " + GameUtils.getCardLink(card) + " from play on the top of deck");
gameState.putCardOnTopOfDeck(card);
for (PhysicalCard discardedCard : discardedFromPlayCards) {
game.getActionsEnvironment().emitEffectResult(new DiscardCardsFromPlayResult(null, null, discardedCard));
}
}
});
}