Cards attached to cards, what is this world coming to...

This commit is contained in:
marcins78@gmail.com
2012-04-13 10:18:32 +00:00
parent 9b24d415e1
commit 98bbc808e9
2 changed files with 29 additions and 6 deletions

View File

@@ -7,7 +7,9 @@ import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.results.CardTransferredResult;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class TransferToSupportEffect extends AbstractEffect {
private PhysicalCard _card;
@@ -35,8 +37,16 @@ public class TransferToSupportEffect extends AbstractEffect {
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (isPlayableInFull(game)) {
PhysicalCard transferredFrom = _card.getAttachedTo();
game.getGameState().removeCardsFromZone(_card.getOwner(), Collections.singleton(_card));
Set<PhysicalCard> transferredCards = new HashSet<PhysicalCard>();
transferredCards.add(_card);
final List<PhysicalCard> attachedCards = game.getGameState().getAttachedCards(_card);
transferredCards.addAll(attachedCards);
game.getGameState().removeCardsFromZone(_card.getOwner(), transferredCards);
game.getGameState().addCardToZone(game, _card, Zone.SUPPORT);
for (PhysicalCard attachedCard : attachedCards)
game.getGameState().attachCard(game, attachedCard, _card);
game.getActionsEnvironment().emitEffectResult(
new CardTransferredResult(_card, transferredFrom, null));

View File

@@ -166,16 +166,29 @@ public class GameState {
for (Map.Entry<String, Integer> stringIntegerEntry : _playerPosition.entrySet())
listener.setPlayerPosition(stringIntegerEntry.getKey(), stringIntegerEntry.getValue());
Set<PhysicalCard> sentCardsFromPlay = new HashSet<PhysicalCard>();
Set<PhysicalCard> attachedCardsToSend = new HashSet<PhysicalCard>();
// First non-attached cards
for (PhysicalCardImpl physicalCard : _inPlay) {
if (physicalCard.getZone() != Zone.ATTACHED)
if (physicalCard.getZone() != Zone.ATTACHED) {
listener.cardCreated(physicalCard);
sentCardsFromPlay.add(physicalCard);
} else
attachedCardsToSend.add(physicalCard);
}
// Now the attached ones
for (PhysicalCardImpl physicalCard : _inPlay) {
if (physicalCard.getZone() == Zone.ATTACHED)
listener.cardCreated(physicalCard);
while (!attachedCardsToSend.isEmpty()) {
Iterator<PhysicalCard> iter = attachedCardsToSend.iterator();
while (iter.hasNext()) {
PhysicalCard attachedCard = iter.next();
if (sentCardsFromPlay.contains(attachedCard.getAttachedTo())) {
listener.cardCreated(attachedCard);
sentCardsFromPlay.add(attachedCard);
iter.remove();
}
}
}
// Finally the stacked ones