First preparation to fully animated UI.

This commit is contained in:
marcins78@gmail.com
2011-10-12 22:05:32 +00:00
parent efe63dafe5
commit 13cea73410
32 changed files with 265 additions and 205 deletions

View File

@@ -44,7 +44,7 @@ public class DiscardCardAtRandomFromHandEffect extends AbstractEffect {
if (hand.size() > 0) {
PhysicalCard randomCard = hand.get(new Random().nextInt(hand.size()));
gameState.sendMessage(_playerId + " randomly discards " + GameUtils.getCardLink(randomCard));
gameState.removeCardFromZone(randomCard);
gameState.removeCardsFromZone(Collections.singleton(randomCard));
gameState.addCardToZone(randomCard, Zone.DISCARD);
return new FullEffectResult(new EffectResult[]{new DiscardCardsFromHandResult(_source, Collections.singleton(randomCard))}, true, true);
}

View File

@@ -8,6 +8,8 @@ import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
public class DiscardCardFromDeckEffect extends AbstractEffect {
private PhysicalCard _card;
@@ -35,7 +37,7 @@ public class DiscardCardFromDeckEffect extends AbstractEffect {
if (isPlayableInFull(game)) {
GameState gameState = game.getGameState();
gameState.sendMessage(GameUtils.getCardLink(_card) + " gets discarded from deck");
gameState.removeCardFromZone(_card);
gameState.removeCardsFromZone(Collections.singleton(_card));
gameState.addCardToZone(_card, Zone.DISCARD);
return new FullEffectResult(null, true, true);
}

View File

@@ -41,8 +41,8 @@ public class DiscardStackedCardsEffect extends AbstractEffect {
protected FullEffectResult playEffectReturningResult(LotroGame game) {
GameState gameState = game.getGameState();
gameState.sendMessage(getAppendedNames(_cards) + " is/are discarded from being stacked");
gameState.removeCardsFromZone(_cards);
for (PhysicalCard card : _cards) {
gameState.removeCardFromZone(card);
gameState.addCardToZone(card, Zone.DISCARD);
}

View File

@@ -52,8 +52,8 @@ public class LiberateASiteEffect extends AbstractEffect {
if (siteToLiberate != null) {
List<PhysicalCard> stackedCards = game.getGameState().getStackedCards(siteToLiberate);
game.getGameState().removeCardsFromZone(stackedCards);
for (PhysicalCard stackedCard : stackedCards) {
game.getGameState().removeCardFromZone(stackedCard);
game.getGameState().addCardToZone(stackedCard, Zone.DISCARD);
}

View File

@@ -11,6 +11,7 @@ import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -67,7 +68,7 @@ public class PlaySiteEffect extends AbstractEffect {
if (gameState.getCurrentSiteNumber() == _siteNumber)
gameState.stopAffecting(card);
gameState.removeCardFromZone(card);
gameState.removeCardsFromZone(Collections.singleton(card));
gameState.addCardToZone(card, Zone.DECK);
}

View File

@@ -8,6 +8,8 @@ import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.DrawCardOrPutIntoHandResult;
import java.util.Collections;
public class PutCardFromDeckIntoHandOrDiscardEffect extends AbstractEffect {
private PhysicalCard _physicalCard;
@@ -39,12 +41,12 @@ public class PutCardFromDeckIntoHandOrDiscardEffect extends AbstractEffect {
if (_physicalCard.getZone() == Zone.DECK) {
if (game.getModifiersQuerying().canDrawCardAndIncrement(game.getGameState(), _physicalCard.getOwner())) {
game.getGameState().sendMessage(_physicalCard.getOwner() + " puts card from deck into his or her hand");
game.getGameState().removeCardFromZone(_physicalCard);
game.getGameState().removeCardsFromZone(Collections.singleton(_physicalCard));
game.getGameState().addCardToZone(_physicalCard, Zone.HAND);
return new FullEffectResult(new EffectResult[]{new DrawCardOrPutIntoHandResult(_physicalCard.getOwner(), 1)}, true, true);
} else {
game.getGameState().sendMessage(_physicalCard.getOwner() + " discards " + GameUtils.getCardLink(_physicalCard) + " from deck due to Rule of 4");
game.getGameState().removeCardFromZone(_physicalCard);
game.getGameState().removeCardsFromZone(Collections.singleton(_physicalCard));
game.getGameState().addCardToZone(_physicalCard, Zone.DISCARD);
}
}

View File

@@ -8,6 +8,8 @@ import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
public class PutCardFromDeckOnBottomOfDeckEffect extends AbstractEffect {
private PhysicalCard _source;
private PhysicalCard _physicalCard;
@@ -37,7 +39,7 @@ public class PutCardFromDeckOnBottomOfDeckEffect extends AbstractEffect {
if (isPlayableInFull(game)) {
GameState gameState = game.getGameState();
gameState.sendMessage(_physicalCard.getOwner() + " puts " + GameUtils.getCardLink(_physicalCard) + " from deck on the bottom of deck");
gameState.removeCardFromZone(_physicalCard);
gameState.removeCardsFromZone(Collections.singleton(_physicalCard));
gameState.putCardOnBottomOfDeck(_physicalCard);
return new FullEffectResult(null, true, true);
}

View File

@@ -9,6 +9,8 @@ import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.DrawCardOrPutIntoHandResult;
import java.util.Collections;
public class PutCardFromDiscardIntoHandEffect extends AbstractEffect {
private PhysicalCard _card;
@@ -37,7 +39,7 @@ public class PutCardFromDiscardIntoHandEffect extends AbstractEffect {
&& _card.getZone() == Zone.DISCARD) {
GameState gameState = game.getGameState();
gameState.sendMessage(_card.getOwner() + " puts " + GameUtils.getCardLink(_card) + " from discard into his or her hand");
gameState.removeCardFromZone(_card);
gameState.removeCardsFromZone(Collections.singleton(_card));
gameState.addCardToZone(_card, Zone.HAND);
return new FullEffectResult(new EffectResult[]{new DrawCardOrPutIntoHandResult(_card.getOwner(), 1)}, true, true);

View File

@@ -8,6 +8,8 @@ import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
public class PutCardFromDiscardOnBottomOfDeckEffect extends AbstractEffect {
private PhysicalCard _physicalCard;
@@ -25,7 +27,7 @@ public class PutCardFromDiscardOnBottomOfDeckEffect extends AbstractEffect {
if (isPlayableInFull(game)) {
GameState gameState = game.getGameState();
gameState.sendMessage(_physicalCard.getOwner() + " puts " + GameUtils.getCardLink(_physicalCard) + " from discard on the bottom of deck");
gameState.removeCardFromZone(_physicalCard);
gameState.removeCardsFromZone(Collections.singleton(_physicalCard));
gameState.putCardOnBottomOfDeck(_physicalCard);
return new FullEffectResult(null, true, true);
}

View File

@@ -7,6 +7,8 @@ import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
public class PutCardFromHandOnBottomOfDeckEffect extends AbstractEffect {
private PhysicalCard _physicalCard;
@@ -34,7 +36,7 @@ public class PutCardFromHandOnBottomOfDeckEffect extends AbstractEffect {
if (isPlayableInFull(game)) {
GameState gameState = game.getGameState();
gameState.sendMessage(_physicalCard.getOwner() + " puts a card from hand on bottom of his or her deck");
gameState.removeCardFromZone(_physicalCard);
gameState.removeCardsFromZone(Collections.singleton(_physicalCard));
gameState.putCardOnBottomOfDeck(_physicalCard);
return new FullEffectResult(null, true, true);

View File

@@ -8,6 +8,8 @@ import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
public class PutCardFromHandOnTopOfDeckEffect extends AbstractEffect {
private PhysicalCard _physicalCard;
@@ -35,7 +37,7 @@ public class PutCardFromHandOnTopOfDeckEffect extends AbstractEffect {
if (isPlayableInFull(game)) {
GameState gameState = game.getGameState();
gameState.sendMessage(_physicalCard.getOwner() + " puts a card from hand on top of his or her deck");
gameState.removeCardFromZone(_physicalCard);
gameState.removeCardsFromZone(Collections.singleton(_physicalCard));
gameState.putCardOnTopOfDeck(_physicalCard);
return new FullEffectResult(null, true, true);
}

View File

@@ -9,6 +9,8 @@ import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.DrawCardOrPutIntoHandResult;
import java.util.Collections;
public class PutCardFromStackedIntoHandEffect extends AbstractEffect {
private PhysicalCard _card;
@@ -37,7 +39,7 @@ public class PutCardFromStackedIntoHandEffect extends AbstractEffect {
&& game.getModifiersQuerying().canDrawCardAndIncrement(game.getGameState(), _card.getOwner())) {
GameState gameState = game.getGameState();
gameState.sendMessage(_card.getOwner() + " puts " + GameUtils.getCardLink(_card) + " from stacked on another card into his or her hand");
gameState.removeCardFromZone(_card);
gameState.removeCardsFromZone(Collections.singleton(_card));
gameState.addCardToZone(_card, Zone.HAND);
return new FullEffectResult(new EffectResult[]{new DrawCardOrPutIntoHandResult(_card.getOwner(), 1)}, true, true);

View File

@@ -4,6 +4,8 @@ import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
public class RemoveCardFromZoneEffect extends UnrespondableEffect {
private PhysicalCard _physicalCard;
@@ -13,6 +15,6 @@ public class RemoveCardFromZoneEffect extends UnrespondableEffect {
@Override
public void doPlayEffect(LotroGame game) {
game.getGameState().removeCardFromZone(_physicalCard);
game.getGameState().removeCardsFromZone(Collections.singleton(_physicalCard));
}
}

View File

@@ -10,10 +10,7 @@ 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.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
public class ReturnCardsToHandEffect extends AbstractEffect {
private PhysicalCard _source;
@@ -48,7 +45,7 @@ public class ReturnCardsToHandEffect extends AbstractEffect {
GameState gameState = game.getGameState();
gameState.stopAffecting(card);
gameState.removeCardFromZone(card);
gameState.removeCardsFromZone(Collections.singleton(card));
gameState.addCardToZone(card, Zone.HAND);
List<PhysicalCard> attachedCards = gameState.getAttachedCards(card);
@@ -56,13 +53,13 @@ public class ReturnCardsToHandEffect extends AbstractEffect {
discardedCards.add(attachedCard);
gameState.stopAffecting(attachedCard);
gameState.removeCardFromZone(attachedCard);
gameState.removeCardsFromZone(Collections.singleton(attachedCard));
gameState.addCardToZone(attachedCard, Zone.DISCARD);
}
List<PhysicalCard> stackedCards = gameState.getStackedCards(card);
for (PhysicalCard stackedCard : stackedCards) {
gameState.removeCardFromZone(stackedCard);
gameState.removeCardsFromZone(Collections.singleton(stackedCard));
gameState.addCardToZone(stackedCard, Zone.DISCARD);
}
}

View File

@@ -7,6 +7,8 @@ import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
public class StackCardFromDiscardEffect extends AbstractEffect {
private PhysicalCard _card;
private PhysicalCard _stackOn;
@@ -35,7 +37,7 @@ public class StackCardFromDiscardEffect extends AbstractEffect {
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (isPlayableInFull(game)) {
game.getGameState().sendMessage(_card.getOwner() + " stacks " + GameUtils.getCardLink(_card) + " from discard on " + GameUtils.getCardLink(_stackOn));
game.getGameState().removeCardFromZone(_card);
game.getGameState().removeCardsFromZone(Collections.singleton(_card));
game.getGameState().stackCard(_card, _stackOn);
return new FullEffectResult(null, true, true);
}

View File

@@ -7,6 +7,8 @@ import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
public class StackCardFromHandEffect extends AbstractEffect {
private PhysicalCard _card;
private PhysicalCard _stackOn;
@@ -20,7 +22,7 @@ public class StackCardFromHandEffect extends AbstractEffect {
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (isPlayableInFull(game)) {
game.getGameState().sendMessage(_card.getOwner() + " stacks " + GameUtils.getCardLink(_card) + " from hand on " + GameUtils.getCardLink(_stackOn));
game.getGameState().removeCardFromZone(_card);
game.getGameState().removeCardsFromZone(Collections.singleton(_card));
game.getGameState().stackCard(_card, _stackOn);
return new FullEffectResult(null, true, true);
}

View File

@@ -8,6 +8,7 @@ import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
import java.util.List;
public class StackCardFromPlayEffect extends AbstractEffect {
@@ -38,20 +39,20 @@ public class StackCardFromPlayEffect extends AbstractEffect {
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (isPlayableInFull(game)) {
game.getGameState().stopAffecting(_card);
game.getGameState().removeCardFromZone(_card);
game.getGameState().removeCardsFromZone(Collections.singleton(_card));
GameState gameState = game.getGameState();
List<PhysicalCard> attachedCards = gameState.getAttachedCards(_card);
for (PhysicalCard attachedCard : attachedCards) {
gameState.stopAffecting(attachedCard);
gameState.removeCardFromZone(attachedCard);
gameState.removeCardsFromZone(Collections.singleton(attachedCard));
gameState.addCardToZone(attachedCard, Zone.DISCARD);
}
List<PhysicalCard> stackedCards = gameState.getStackedCards(_card);
for (PhysicalCard stackedCard : stackedCards) {
gameState.removeCardFromZone(stackedCard);
gameState.removeCardsFromZone(Collections.singleton(stackedCard));
gameState.addCardToZone(stackedCard, Zone.DISCARD);
}

View File

@@ -75,10 +75,8 @@ public class Card1_018 extends AbstractEvent {
topDeckCards.removeAll(selectedCards);
}
if (topDeckCards.size() > 0) {
for (PhysicalCard topDeckCard : topDeckCards)
game.getGameState().removeCardFromZone(topDeckCard);
}
if (topDeckCards.size() > 0)
game.getGameState().removeCardsFromZone(topDeckCards);
}
});
}

View File

@@ -13,6 +13,7 @@ import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.effects.ChooseActiveCardsEffect;
import java.util.Collection;
import java.util.Collections;
/**
* Set: The Two Towers
@@ -40,11 +41,11 @@ public class Card4_054 extends AbstractEvent {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
for (PhysicalCard card : cards) {
game.getGameState().removeCardsFromZone(game.getGameState().getStackedCards(card));
for (PhysicalCard stackedCard : game.getGameState().getStackedCards(card)) {
game.getGameState().removeCardFromZone(stackedCard);
game.getGameState().putCardOnBottomOfDeck(stackedCard);
}
game.getGameState().removeCardFromZone(card);
game.getGameState().removeCardsFromZone(Collections.singleton(card));
game.getGameState().putCardOnBottomOfDeck(card);
}
action.appendEffect(

View File

@@ -11,6 +11,8 @@ import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import java.util.Collections;
/**
* Set: The Two Towers
* Side: Free
@@ -46,12 +48,12 @@ public class Card4_055 extends AbstractEvent {
@Override
protected void cardSelected(PhysicalCard card) {
int count = 0;
game.getGameState().removeCardsFromZone(game.getGameState().getStackedCards(card));
for (PhysicalCard stackedCard : game.getGameState().getStackedCards(card)) {
game.getGameState().removeCardFromZone(stackedCard);
game.getGameState().putCardOnBottomOfDeck(stackedCard);
count++;
}
game.getGameState().removeCardFromZone(card);
game.getGameState().removeCardsFromZone(Collections.singleton(card));
game.getGameState().putCardOnBottomOfDeck(card);
count++;

View File

@@ -13,7 +13,7 @@ public interface GameStateListener {
public void cardMoved(PhysicalCard card);
public void cardRemoved(PhysicalCard card);
public void cardsRemoved(Collection<PhysicalCard> cards);
public void setPlayerOrder(List<String> playerIds);

View File

@@ -106,7 +106,7 @@ public class GameState {
String owner = physicalCard.getOwner();
GameStateListener result = _gameStateListeners.get(owner);
if (result != null)
return Collections.singletonList(result);
return Collections.singleton(result);
else
return Collections.emptyList();
}
@@ -200,7 +200,7 @@ public class GameState {
public void transferCard(PhysicalCard card, PhysicalCard transferTo) {
if (card.getZone() != Zone.ATTACHED) {
removeCardFromZone(card);
removeCardsFromZone(Collections.singleton(card));
addCardToZone(card, Zone.ATTACHED);
}
((PhysicalCardImpl) card).attachTo((PhysicalCardImpl) transferTo);
@@ -267,45 +267,63 @@ public class GameState {
return _inPlay;
}
public void removeCardFromZone(PhysicalCard card) {
Zone zone = card.getZone();
public void removeCardsFromZone(Collection<PhysicalCard> cards) {
Map<GameStateListener, Set<PhysicalCard>> listenerCards = new HashMap<GameStateListener, Set<PhysicalCard>>();
List<PhysicalCardImpl> zoneCards = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone);
boolean b = zoneCards.remove(card);
if (!b)
throw new RuntimeException("Card was not found in the expected zone");
for (PhysicalCard card : cards) {
Zone zone = card.getZone();
if (zone == Zone.ATTACHED)
((PhysicalCardImpl) card).attachTo(null);
List<PhysicalCardImpl> zoneCards = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone);
boolean b = zoneCards.remove(card);
if (!b)
throw new RuntimeException("Card was not found in the expected zone");
if (zone == Zone.STACKED)
((PhysicalCardImpl) card).stackOn(null);
if (zone == Zone.ATTACHED)
((PhysicalCardImpl) card).attachTo(null);
for (Skirmish assignment : new LinkedList<Skirmish>(_assignments)) {
if (assignment.getFellowshipCharacter() == card)
removeAssignment(assignment);
if (assignment.getShadowCharacters().remove(card))
removeAssignment(assignment);
if (zone == Zone.STACKED)
((PhysicalCardImpl) card).stackOn(null);
for (Skirmish assignment : new LinkedList<Skirmish>(_assignments)) {
if (assignment.getFellowshipCharacter() == card)
removeAssignment(assignment);
if (assignment.getShadowCharacters().remove(card))
removeAssignment(assignment);
}
if (_skirmish != null) {
if (_skirmish.getFellowshipCharacter() == card)
_skirmish.setFellowshipCharacter(null);
_skirmish.getShadowCharacters().remove(card);
}
removeAllTokens(card);
if (isZonePublic(zone))
for (GameStateListener listener : getAllGameStateListeners()) {
getValue(listenerCards, listener).add(card);
}
else if (isZonePrivate(zone))
for (GameStateListener listener : getPrivateGameStateListeners(card)) {
getValue(listenerCards, listener).add(card);
}
if ((zone == Zone.DECK && card.getBlueprint().getCardType() != CardType.SITE) || zone == Zone.HAND || zone == Zone.DISCARD || zone == Zone.DEAD)
for (GameStateListener listener : getAllGameStateListeners())
listener.setZoneSize(card.getOwner(), zone, zoneCards.size());
}
if (_skirmish != null) {
if (_skirmish.getFellowshipCharacter() == card)
_skirmish.setFellowshipCharacter(null);
_skirmish.getShadowCharacters().remove(card);
for (Map.Entry<GameStateListener, Set<PhysicalCard>> gameStateListenerSetEntry : listenerCards.entrySet())
gameStateListenerSetEntry.getKey().cardsRemoved(gameStateListenerSetEntry.getValue());
}
private Set<PhysicalCard> getValue(Map<GameStateListener, Set<PhysicalCard>> map, GameStateListener listener) {
Set<PhysicalCard> result = map.get(listener);
if (result == null) {
result = new HashSet<PhysicalCard>();
map.put(listener, result);
}
removeAllTokens(card);
if (isZonePublic(zone))
for (GameStateListener listener : getAllGameStateListeners())
listener.cardRemoved(card);
else if (isZonePrivate(zone))
for (GameStateListener listener : getPrivateGameStateListeners(card))
listener.cardRemoved(card);
if ((zone == Zone.DECK && card.getBlueprint().getCardType() != CardType.SITE) || zone == Zone.HAND || zone == Zone.DISCARD || zone == Zone.DEAD)
for (GameStateListener listener : getAllGameStateListeners())
listener.setZoneSize(card.getOwner(), zone, zoneCards.size());
return result;
}
public void addCardToZone(PhysicalCard card, Zone zone) {
@@ -724,7 +742,7 @@ public class GameState {
List<PhysicalCardImpl> deck = _decks.get(player);
if (deck.size() > 0) {
PhysicalCard card = deck.get(0);
removeCardFromZone(card);
removeCardsFromZone(Collections.singleton(card));
addCardToZone(card, Zone.HAND);
}
}

View File

@@ -42,8 +42,8 @@ public class DiscardCardsFromHandEffect extends AbstractEffect {
protected FullEffectResult playEffectReturningResult(LotroGame game) {
GameState gameState = game.getGameState();
gameState.sendMessage(getAppendedNames(_cards) + " is/are discarded from hand");
gameState.removeCardsFromZone(_cards);
for (PhysicalCard card : _cards) {
gameState.removeCardFromZone(card);
gameState.addCardToZone(card, Zone.DISCARD);
}

View File

@@ -10,10 +10,7 @@ import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
public class DiscardCardsFromPlayEffect extends AbstractPreventableCardEffect {
private PhysicalCard _source;
@@ -62,7 +59,7 @@ public class DiscardCardsFromPlayEffect extends AbstractPreventableCardEffect {
GameState gameState = game.getGameState();
gameState.stopAffecting(card);
gameState.removeCardFromZone(card);
gameState.removeCardsFromZone(Collections.singleton(card));
gameState.addCardToZone(card, Zone.DISCARD);
List<PhysicalCard> attachedCards = gameState.getAttachedCards(card);
@@ -70,13 +67,13 @@ public class DiscardCardsFromPlayEffect extends AbstractPreventableCardEffect {
discardedCards.add(attachedCard);
gameState.stopAffecting(attachedCard);
gameState.removeCardFromZone(attachedCard);
gameState.removeCardsFromZone(Collections.singleton(attachedCard));
gameState.addCardToZone(attachedCard, Zone.DISCARD);
}
List<PhysicalCard> stackedCards = gameState.getStackedCards(card);
for (PhysicalCard stackedCard : stackedCards) {
gameState.removeCardFromZone(stackedCard);
gameState.removeCardsFromZone(Collections.singleton(stackedCard));
gameState.addCardToZone(stackedCard, Zone.DISCARD);
}
}

View File

@@ -11,6 +11,7 @@ import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult;
import com.gempukku.lotro.logic.timing.results.KillResult;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -42,11 +43,12 @@ public class KillEffect extends AbstractSuccessfulEffect {
Set<PhysicalCard> discardedCards = new HashSet<PhysicalCard>();
Set<PhysicalCard> killedCards = new HashSet<PhysicalCard>();
GameState gameState = game.getGameState();
for (PhysicalCard card : _cards) {
GameState gameState = game.getGameState();
gameState.sendMessage(GameUtils.getCardLink(card) + " gets killed");
gameState.stopAffecting(card);
gameState.removeCardFromZone(card);
gameState.removeCardsFromZone(Collections.singleton(card));
if (card.getBlueprint().getSide() == Side.FREE_PEOPLE) {
killedCards.add(card);
gameState.addCardToZone(card, Zone.DEAD);
@@ -61,13 +63,13 @@ public class KillEffect extends AbstractSuccessfulEffect {
discardedCards.add(attachedCard);
gameState.stopAffecting(attachedCard);
gameState.removeCardFromZone(attachedCard);
gameState.removeCardsFromZone(Collections.singleton(attachedCard));
gameState.addCardToZone(attachedCard, Zone.DISCARD);
}
List<PhysicalCard> stackedCards = gameState.getStackedCards(card);
for (PhysicalCard stackedCard : stackedCards) {
gameState.removeCardFromZone(stackedCard);
gameState.removeCardsFromZone(Collections.singleton(stackedCard));
gameState.addCardToZone(stackedCard, Zone.DISCARD);
}
}

View File

@@ -7,6 +7,7 @@ import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
import java.util.Collections;
import java.util.Map;
public class FirstPlayerPlaysSiteGameProcess implements GameProcess {
@@ -24,7 +25,7 @@ public class FirstPlayerPlaysSiteGameProcess implements GameProcess {
public void process() {
GameState gameState = _game.getGameState();
PhysicalCard firstSite = Filters.filter(gameState.getAdventureDeck(_firstPlayer), gameState, _game.getModifiersQuerying(), Filters.siteNumber(1)).iterator().next();
gameState.removeCardFromZone(firstSite);
gameState.removeCardsFromZone(Collections.singleton(firstSite));
gameState.addCardToZone(firstSite, Zone.ADVENTURE_PATH);
for (String playerId : gameState.getPlayerOrder().getAllPlayers())

View File

@@ -9,6 +9,7 @@ import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
import java.util.Collections;
import java.util.Map;
public class PlayRingBearerRingAndAddBurdersGameProcess implements GameProcess {
@@ -27,12 +28,12 @@ public class PlayRingBearerRingAndAddBurdersGameProcess implements GameProcess {
GameState gameState = _game.getGameState();
for (String playerId : gameState.getPlayerOrder().getAllPlayers()) {
PhysicalCard ringBearer = Filters.filter(gameState.getDeck(playerId), gameState, _game.getModifiersQuerying(), Filters.keyword(Keyword.RING_BEARER)).iterator().next();
gameState.removeCardFromZone(ringBearer);
gameState.removeCardsFromZone(Collections.singleton(ringBearer));
gameState.addCardToZone(ringBearer, Zone.FREE_CHARACTERS);
gameState.setRingBearer(ringBearer);
PhysicalCard ring = Filters.filter(gameState.getDeck(playerId), gameState, _game.getModifiersQuerying(), Filters.type(CardType.THE_ONE_RING)).iterator().next();
gameState.removeCardFromZone(ring);
gameState.removeCardsFromZone(Collections.singleton(ring));
gameState.attachCard(ring, ringBearer);
gameState.startPlayerTurn(playerId);

View File

@@ -15,6 +15,8 @@ import com.gempukku.lotro.logic.timing.results.WhenMoveFromResult;
import com.gempukku.lotro.logic.timing.results.WhenMoveToResult;
import com.gempukku.lotro.logic.timing.results.WhenMovesResult;
import java.util.Collections;
public class PlayerPlaysNextSiteIfNotThereGameProcess implements GameProcess {
private LotroGame _game;
private GameProcess _afterMoveGameProcess;
@@ -49,7 +51,7 @@ public class PlayerPlaysNextSiteIfNotThereGameProcess implements GameProcess {
nextSite = Filters.filter(gameState.getAdventureDeck(playerToPlaySite), gameState, _game.getModifiersQuerying(),
Filters.siteNumber(nextSiteNumber)).iterator().next();
gameState.removeCardFromZone(nextSite);
gameState.removeCardsFromZone(Collections.singleton(nextSite));
gameState.addCardToZone(nextSite, Zone.ADVENTURE_PATH);
final PhysicalCard site = nextSite;

View File

@@ -4,14 +4,13 @@ import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Token;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.communication.GameStateListener;
import static com.gempukku.lotro.game.GameEvent.Type.*;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import static com.gempukku.lotro.game.GameEvent.Type.*;
public class GatheringParticipantCommunicationChannel implements GameStateListener {
private List<GameEvent> _events = new LinkedList<GameEvent>();
private String _self;
@@ -78,8 +77,8 @@ public class GatheringParticipantCommunicationChannel implements GameStateListen
}
@Override
public void cardRemoved(PhysicalCard card) {
_events.add(new GameEvent(REMOVE_CARD_FROM_PLAY).card(card));
public void cardsRemoved(Collection<PhysicalCard> cards) {
_events.add(new GameEvent(REMOVE_CARD_FROM_PLAY).otherCardIds(getCardIds(cards)));
}
@Override

View File

@@ -177,10 +177,10 @@
ui = new GempLotrGameUI("/gemp-lotr/server");
$(window).resize(function() {
ui.layoutUI();
ui.windowResized();
});
ui.layoutUI();
ui.layoutUI(true);
ui.startGameSession();
});

View File

@@ -30,40 +30,40 @@ var GameAnimations = Class.extend({
var cardWidth = card.getWidthForHeight(cardHeight);
$(cardDiv).css(
{
position: "absolute",
left: (gameWidth / 2 - cardWidth / 4),
top: gameHeight * (3 / 8),
width: cardWidth / 2,
height: cardHeight / 2,
"z-index": 100,
opacity: 0});
{
position: "absolute",
left: (gameWidth / 2 - cardWidth / 4),
top: gameHeight * (3 / 8),
width: cardWidth / 2,
height: cardHeight / 2,
"z-index": 100,
opacity: 0});
$(cardDiv).animate(
{
left: "-=" + cardWidth / 4,
top: "-=" + (gameHeight / 8),
width: "+=" + (cardWidth / 2),
height: "+=" + (cardHeight / 2),
opacity: 1},
{
duration: that.playEventDuration / 8,
easing: "linear",
queue: false,
complete: next});
{
left: "-=" + cardWidth / 4,
top: "-=" + (gameHeight / 8),
width: "+=" + (cardWidth / 2),
height: "+=" + (cardHeight / 2),
opacity: 1},
{
duration: that.playEventDuration / 8,
easing: "linear",
queue: false,
complete: next});
}).queue(
function(next) {
setTimeout(next, that.playEventDuration * (5 / 8));
}).queue(
function(next) {
$(cardDiv).animate(
{
opacity: 0},
{
duration: that.playEventDuration / 4,
easing: "easeOutQuart",
queue: false,
complete: next});
{
opacity: 0},
{
duration: that.playEventDuration / 4,
easing: "easeOutQuart",
queue: false,
complete: next});
}).queue(
function(next) {
$(cardDiv).remove();
@@ -99,26 +99,26 @@ var GameAnimations = Class.extend({
var targetCardHeight = $(targetCard).height();
$(cardDiv).css(
{
position: "absolute",
left: $(targetCard).position().left,
top: $(targetCard).position().top,
width: targetCardWidth,
height: targetCardHeight,
"z-index": 100,
opacity: 1});
{
position: "absolute",
left: $(targetCard).position().left,
top: $(targetCard).position().top,
width: targetCardWidth,
height: targetCardHeight,
"z-index": 100,
opacity: 1});
$(cardDiv).animate(
{
opacity: 0,
left: "-=" + (targetCardWidth / 2),
top: "-=" + (targetCardHeight / 2),
width: "+=" + targetCardWidth,
height: "+=" + targetCardHeight},
{
duration: that.cardAffectsCardDuration,
easing: "easeInQuart",
queue: false,
complete: null});
{
opacity: 0,
left: "-=" + (targetCardWidth / 2),
top: "-=" + (targetCardHeight / 2),
width: "+=" + targetCardWidth,
height: "+=" + targetCardHeight},
{
duration: that.cardAffectsCardDuration,
easing: "easeInQuart",
queue: false,
complete: null});
}
setTimeout(next, that.cardAffectsCardDuration);
@@ -132,9 +132,18 @@ var GameAnimations = Class.extend({
$(this).remove();
}
}
);
);
next();
});
}
},
windowResized: function() {
var that = this;
$("#main").queue(
function(next) {
that.game.layoutUI(true);
next();
});
}
});

View File

@@ -273,21 +273,21 @@ var GempLotrGameUI = Class.extend({
initializeDialogs: function() {
this.smallDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: false,
resizable: false,
width: 400,
height: 200
});
autoOpen: false,
closeOnEscape: false,
resizable: false,
width: 400,
height: 200
});
this.cardActionDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: false,
resizable: true,
width: 600,
height: 300
});
autoOpen: false,
closeOnEscape: false,
resizable: true,
width: 600,
height: 300
});
var that = this;
@@ -302,15 +302,15 @@ var GempLotrGameUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: true,
title: "Card information",
minHeight: 80,
minWidth: 200,
width: Math.max(600, width * 0.75),
height: Math.max(300, height * 0.75)
});
autoOpen: false,
closeOnEscape: true,
resizable: true,
title: "Card information",
minHeight: 80,
minWidth: 200,
width: Math.max(600, width * 0.75),
height: Math.max(300, height * 0.75)
});
var swipeOptions = {
threshold: 20,
@@ -326,16 +326,20 @@ var GempLotrGameUI = Class.extend({
this.infoDialog.swipe(swipeOptions);
},
layoutUI: function(sizeNotChanged) {
windowResized: function() {
this.animations.windowResized();
},
layoutUI: function(sizeChanged) {
var padding = this.padding;
var width = $(window).width();
var height = $(window).height();
if (sizeNotChanged) {
width = this.windowWidth;
height = this.windowHeight;
} else {
if (sizeChanged) {
this.windowWidth = width;
this.windowHeight = height;
} else {
width = this.windowWidth;
height = this.windowHeight;
}
var heightScales;
@@ -521,7 +525,7 @@ var GempLotrGameUI = Class.extend({
}
if (gameEvents.length > 0)
this.layoutUI(true);
this.layoutUI(false);
// Then the strictly animation events
for (var i = 0; i < gameEvents.length; i++) {
@@ -603,9 +607,9 @@ var GempLotrGameUI = Class.extend({
else if (zone == "DISCARD")
$("#discard" + this.getPlayerIndex(playerId)).text("Discard: " + count);
else if (zone == "DEAD")
$("#deadPile" + this.getPlayerIndex(playerId)).text("Dead pile: " + count);
else if (zone == "DECK")
$("#deck" + this.getPlayerIndex(playerId)).text("Deck: " + count);
$("#deadPile" + this.getPlayerIndex(playerId)).text("Dead pile: " + count);
else if (zone == "DECK")
$("#deck" + this.getPlayerIndex(playerId)).text("Deck: " + count);
},
playerPosition: function(element) {
@@ -773,7 +777,7 @@ var GempLotrGameUI = Class.extend({
if (index != -1)
cardData.attachedCards.splice(index, 1);
}
);
);
var card = $(".card:cardId(" + cardId + ")");
var cardData = card.data("card");
@@ -873,32 +877,37 @@ var GempLotrGameUI = Class.extend({
}
this.initializeGameUI();
this.layoutUI();
this.layoutUI(true);
},
removeCardFromPlay: function(element) {
var cardId = element.getAttribute("cardId");
var zone = element.getAttribute("zone");
var cardRemovedIds = element.getAttribute("otherCardIds").split(",");
var card = $(".card:cardId(" + cardId + ")");
for (var i = 0; i < cardRemovedIds.length; i++) {
var cardId = cardRemovedIds[i];
var card = $(".card:cardId(" + cardId + ")");
if (zone == "ATTACHED" || zone == "STACKED") {
$(".card").each(
function() {
var cardData = $(this).data("card");
var index = -1;
for (var i = 0; i < cardData.attachedCards.length; i++)
if (cardData.attachedCards[i].data("card").cardId == cardId) {
index = i;
break;
if (card != null) {
var cardData = card.data("card");
if (cardData.zone == "ATTACHED" || cardData.zone == "STACKED") {
$(".card").each(
function() {
var cardData = $(this).data("card");
var index = -1;
for (var i = 0; i < cardData.attachedCards.length; i++)
if (cardData.attachedCards[i].data("card").cardId == cardId) {
index = i;
break;
}
if (index != -1)
cardData.attachedCards.splice(index, 1);
}
if (index != -1)
cardData.attachedCards.splice(index, 1);
}
);
}
);
}
card.remove();
card.remove();
}
}
},
gamePhaseChange: function(element) {
@@ -967,13 +976,13 @@ var GempLotrGameUI = Class.extend({
this.smallDialog
.html(text + "<br /><input id='integerDecision' type='text' value='0'>")
.dialog("option", "buttons",
{
"OK": function() {
$(this).dialog("close");
that.decisionFunction(id, $("#integerDecision").val());
}
}
);
{
"OK": function() {
$(this).dialog("close");
that.decisionFunction(id, $("#integerDecision").val());
}
}
);
$("#integerDecision").SpinnerControl({ type: 'range',
typedata: {
@@ -1005,13 +1014,13 @@ var GempLotrGameUI = Class.extend({
this.smallDialog
.html(html)
.dialog("option", "buttons",
{
"OK": function() {
$(this).dialog("close");
that.decisionFunction(id, $("#multipleChoiceDecision").val());
}
}
);
{
"OK": function() {
$(this).dialog("close");
that.decisionFunction(id, $("#multipleChoiceDecision").val());
}
}
);
this.smallDialog.dialog("open");
},
@@ -1260,8 +1269,8 @@ var GempLotrGameUI = Class.extend({
$(div).find('LI.hover').removeClass('hover');
$(this).parent().addClass('hover');
}).mouseout(function() {
$(div).find('LI.hover').removeClass('hover');
});
$(div).find('LI.hover').removeClass('hover');
});
var getRidOfContextMenu = function() {
$(div).remove();
@@ -1530,7 +1539,7 @@ var GempLotrGameUI = Class.extend({
} else {
that.unassignMinion(cardId);
}
that.layoutUI(true);
that.layoutUI(false);
that.doAssignments(freeCharacters, minions);
};