Affecting cards is managed by the GameState only.
This commit is contained in:
@@ -93,6 +93,11 @@ public abstract class AbstractLotroCardBlueprint implements LotroCardBlueprint {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Modifier> getStackedOnModifiers(LotroGame game, PhysicalCard self) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Modifier getAlwaysOnModifier(PhysicalCard self) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -127,13 +127,13 @@ public class AttachPermanentAction extends AbstractCostToEffectAction {
|
||||
} else {
|
||||
if (!_cardDiscarded) {
|
||||
_cardDiscarded = true;
|
||||
game.getGameState().addCardToZone(_cardToAttach, Zone.DISCARD);
|
||||
game.getGameState().addCardToZone(game, _cardToAttach, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!_cardDiscarded) {
|
||||
_cardDiscarded = true;
|
||||
game.getGameState().addCardToZone(_cardToAttach, Zone.DISCARD);
|
||||
game.getGameState().addCardToZone(game, _cardToAttach, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,9 @@ public class PlayEventAction extends AbstractCostToEffectAction {
|
||||
|
||||
if (!_cardDiscarded) {
|
||||
_cardDiscarded = true;
|
||||
game.getGameState().addCardToZone(_eventPlayed, _playCardEffect.getTargetZone());
|
||||
final Zone targetZone = _playCardEffect.getTargetZone();
|
||||
if (targetZone != null)
|
||||
game.getGameState().addCardToZone(game, _eventPlayed, targetZone);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -73,8 +73,7 @@ public class PlayPermanentAction extends AbstractCostToEffectAction {
|
||||
|
||||
if (!_cardPutIntoPlay) {
|
||||
_cardPutIntoPlay = true;
|
||||
game.getGameState().addCardToZone(_permanentPlayed, _zone);
|
||||
game.getGameState().startAffecting(game, _permanentPlayed, game.getModifiersEnvironment());
|
||||
game.getGameState().addCardToZone(game, _permanentPlayed, _zone);
|
||||
}
|
||||
|
||||
if (!_cardPlayed) {
|
||||
@@ -88,7 +87,7 @@ public class PlayPermanentAction extends AbstractCostToEffectAction {
|
||||
} else {
|
||||
if (!_cardDiscarded) {
|
||||
_cardDiscarded = true;
|
||||
game.getGameState().addCardToZone(_permanentPlayed, Zone.DISCARD);
|
||||
game.getGameState().addCardToZone(game, _permanentPlayed, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ public class AttachCardEffect extends AbstractEffect {
|
||||
protected FullEffectResult playEffectReturningResult(LotroGame game) {
|
||||
if (isPlayableInFull(game)) {
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.attachCard(_physicalCard, _targetCard);
|
||||
gameState.startAffecting(game, _physicalCard, game.getModifiersEnvironment());
|
||||
gameState.attachCard(game, _physicalCard, _targetCard);
|
||||
return new FullEffectResult(null, true, true);
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DiscardBottomCardFromDeckEffect extends AbstractEffect {
|
||||
GameState gameState = game.getGameState();
|
||||
PhysicalCard card = gameState.removeBottomDeckCard(_playerId);
|
||||
gameState.sendMessage(_playerId + " discards bottom card from his or her deck - " + GameUtils.getCardLink(card));
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
|
||||
discardedCardCallback(card);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DiscardCardAtRandomFromHandEffect extends AbstractEffect {
|
||||
PhysicalCard randomCard = hand.get(new Random().nextInt(hand.size()));
|
||||
gameState.sendMessage(_playerId + " randomly discards " + GameUtils.getCardLink(randomCard));
|
||||
gameState.removeCardsFromZone(Collections.singleton(randomCard));
|
||||
gameState.addCardToZone(randomCard, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, randomCard, Zone.DISCARD);
|
||||
return new FullEffectResult(new EffectResult[]{new DiscardCardsFromHandResult(_source, Collections.singleton(randomCard), _forced)}, true, true);
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class DiscardCardFromDeckEffect extends AbstractEffect {
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.sendMessage(GameUtils.getCardLink(_card) + " gets discarded from deck");
|
||||
gameState.removeCardsFromZone(Collections.singleton(_card));
|
||||
gameState.addCardToZone(_card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, _card, Zone.DISCARD);
|
||||
return new FullEffectResult(null, true, true);
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DiscardStackedCardsEffect extends AbstractEffect {
|
||||
gameState.sendMessage(getAppendedNames(toDiscard) + " " + GameUtils.be(toDiscard) + " discarded from being stacked");
|
||||
gameState.removeCardsFromZone(toDiscard);
|
||||
for (PhysicalCard card : toDiscard)
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
|
||||
return new FullEffectResult(null, toDiscard.size() == _cards.size(), toDiscard.size() == _cards.size());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DiscardTopCardFromDeckEffect extends AbstractEffect {
|
||||
GameState gameState = game.getGameState();
|
||||
PhysicalCard card = gameState.removeTopDeckCard(_playerId);
|
||||
gameState.sendMessage(_playerId + " discards top card from his or her deck - " + GameUtils.getCardLink(card));
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
|
||||
return new FullEffectResult(null, true, true);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class LiberateASiteEffect extends AbstractEffect {
|
||||
List<PhysicalCard> stackedCards = game.getGameState().getStackedCards(siteToLiberate);
|
||||
game.getGameState().removeCardsFromZone(stackedCards);
|
||||
for (PhysicalCard stackedCard : stackedCards)
|
||||
game.getGameState().addCardToZone(stackedCard, Zone.DISCARD);
|
||||
game.getGameState().addCardToZone(game, stackedCard, Zone.DISCARD);
|
||||
|
||||
game.getGameState().loseControlOfCard(siteToLiberate, Zone.ADVENTURE_PATH);
|
||||
|
||||
|
||||
@@ -71,21 +71,17 @@ public class PlaySiteEffect extends AbstractEffect {
|
||||
zone = card.getZone();
|
||||
stacked = new LinkedList<PhysicalCard>(gameState.getStackedCards(card));
|
||||
|
||||
if (gameState.getCurrentSiteNumber() == _siteNumber)
|
||||
gameState.stopAffecting(card);
|
||||
gameState.removeCardsFromZone(Collections.singleton(card));
|
||||
gameState.addCardToZone(card, Zone.DECK);
|
||||
gameState.addCardToZone(game, card, Zone.DECK);
|
||||
}
|
||||
|
||||
gameState.sendMessage(newSite.getOwner() + " plays " + GameUtils.getCardLink(newSite));
|
||||
gameState.addCardToZone(newSite, Zone.ADVENTURE_PATH);
|
||||
if (gameState.getCurrentSiteNumber() == _siteNumber)
|
||||
gameState.startAffecting(game, newSite, game.getModifiersEnvironment());
|
||||
gameState.addCardToZone(game, newSite, Zone.ADVENTURE_PATH);
|
||||
|
||||
if (controlled != null) {
|
||||
gameState.takeControlOfCard(controlled, newSite, zone);
|
||||
for (PhysicalCard physicalCard : stacked)
|
||||
gameState.stackCard(physicalCard, newSite);
|
||||
gameState.stackCard(game, physicalCard, newSite);
|
||||
}
|
||||
|
||||
sitePlayedCallback(newSite);
|
||||
|
||||
@@ -42,12 +42,12 @@ public class PutCardFromDeckIntoHandOrDiscardEffect extends AbstractEffect {
|
||||
if (game.getModifiersQuerying().canDrawCardAndIncrement(game.getGameState(), _physicalCard.getOwner())) {
|
||||
game.getGameState().sendMessage(_physicalCard.getOwner() + " puts card from deck into his or her hand");
|
||||
game.getGameState().removeCardsFromZone(Collections.singleton(_physicalCard));
|
||||
game.getGameState().addCardToZone(_physicalCard, Zone.HAND);
|
||||
game.getGameState().addCardToZone(game, _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().removeCardsFromZone(Collections.singleton(_physicalCard));
|
||||
game.getGameState().addCardToZone(_physicalCard, Zone.DISCARD);
|
||||
game.getGameState().addCardToZone(game, _physicalCard, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PutCardFromDiscardIntoHandEffect extends AbstractEffect {
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.sendMessage(_card.getOwner() + " puts " + GameUtils.getCardLink(_card) + " from discard into his or her hand");
|
||||
gameState.removeCardsFromZone(Collections.singleton(_card));
|
||||
gameState.addCardToZone(_card, Zone.HAND);
|
||||
gameState.addCardToZone(game, _card, Zone.HAND);
|
||||
|
||||
return new FullEffectResult(new EffectResult[]{new DrawCardOrPutIntoHandResult(_card.getOwner(), 1)}, true, true);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PutCardFromStackedIntoHandEffect extends AbstractEffect {
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.sendMessage(_card.getOwner() + " puts " + GameUtils.getCardLink(_card) + " from stacked on another card into his or her hand");
|
||||
gameState.removeCardsFromZone(Collections.singleton(_card));
|
||||
gameState.addCardToZone(_card, Zone.HAND);
|
||||
gameState.addCardToZone(game, _card, Zone.HAND);
|
||||
|
||||
return new FullEffectResult(new EffectResult[]{new DrawCardOrPutIntoHandResult(_card.getOwner(), 1)}, true, true);
|
||||
}
|
||||
|
||||
@@ -66,20 +66,17 @@ public class ReturnCardsToHandEffect extends AbstractEffect {
|
||||
|
||||
// Now do the actual things
|
||||
GameState gameState = game.getGameState();
|
||||
// Stop affecting
|
||||
for (PhysicalCard card : stoppedAffecting)
|
||||
gameState.stopAffecting(card);
|
||||
|
||||
// Remove from their zone
|
||||
gameState.removeCardsFromZone(removedFromZone);
|
||||
|
||||
// Add cards to hand
|
||||
for (PhysicalCard card : cardsToReturnToHand)
|
||||
gameState.addCardToZone(card, Zone.HAND);
|
||||
gameState.addCardToZone(game, card, Zone.HAND);
|
||||
|
||||
// Add discarded to discard
|
||||
for (PhysicalCard card : discardedFromPlay)
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
|
||||
if (discardedFromPlay.size() > 0)
|
||||
return new FullEffectResult(new EffectResult[]{new DiscardCardsFromPlayResult(discardedFromPlay)}, true, true);
|
||||
|
||||
@@ -55,9 +55,6 @@ public class ShuffleCardsFromPlayAndStackedOnItIntoDeckEffect extends AbstractEf
|
||||
}
|
||||
}
|
||||
|
||||
for (PhysicalCard physicalCard : inPlay)
|
||||
game.getGameState().stopAffecting(physicalCard);
|
||||
|
||||
if (toShuffleIn.size() > 0) {
|
||||
game.getGameState().removeCardsFromZone(toShuffleIn);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class StackCardFromDiscardEffect extends AbstractEffect {
|
||||
if (isPlayableInFull(game)) {
|
||||
game.getGameState().sendMessage(_card.getOwner() + " stacks " + GameUtils.getCardLink(_card) + " from discard on " + GameUtils.getCardLink(_stackOn));
|
||||
game.getGameState().removeCardsFromZone(Collections.singleton(_card));
|
||||
game.getGameState().stackCard(_card, _stackOn);
|
||||
game.getGameState().stackCard(game, _card, _stackOn);
|
||||
return new FullEffectResult(null, true, true);
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class StackCardFromHandEffect extends AbstractEffect {
|
||||
if (isPlayableInFull(game)) {
|
||||
game.getGameState().sendMessage(_card.getOwner() + " stacks " + GameUtils.getCardLink(_card) + " from hand on " + GameUtils.getCardLink(_stackOn));
|
||||
game.getGameState().removeCardsFromZone(Collections.singleton(_card));
|
||||
game.getGameState().stackCard(_card, _stackOn);
|
||||
game.getGameState().stackCard(game, _card, _stackOn);
|
||||
return new FullEffectResult(null, true, true);
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
|
||||
@@ -45,12 +45,6 @@ public class StackCardFromPlayEffect extends AbstractEffect {
|
||||
List<PhysicalCard> attachedCards = gameState.getAttachedCards(_card);
|
||||
List<PhysicalCard> stackedCards = gameState.getStackedCards(_card);
|
||||
|
||||
// First stop affecting (card and all attached to it)
|
||||
game.getGameState().stopAffecting(_card);
|
||||
|
||||
for (PhysicalCard attachedCard : attachedCards)
|
||||
gameState.stopAffecting(attachedCard);
|
||||
|
||||
// Then remove from zones (card, attached and stacked on it)
|
||||
Set<PhysicalCard> discardedCards = new HashSet<PhysicalCard>();
|
||||
Set<PhysicalCard> cardsToRemove = new HashSet<PhysicalCard>();
|
||||
@@ -63,13 +57,13 @@ public class StackCardFromPlayEffect extends AbstractEffect {
|
||||
|
||||
// And put them in new zones (attached and stacked to discard, the card gets stacked on)
|
||||
for (PhysicalCard attachedCard : attachedCards)
|
||||
gameState.addCardToZone(attachedCard, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, attachedCard, Zone.DISCARD);
|
||||
|
||||
for (PhysicalCard stackedCard : stackedCards)
|
||||
gameState.addCardToZone(stackedCard, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, stackedCard, Zone.DISCARD);
|
||||
|
||||
game.getGameState().sendMessage(GameUtils.getCardLink(_card) + " is stacked on " + GameUtils.getCardLink(_stackOn));
|
||||
game.getGameState().stackCard(_card, _stackOn);
|
||||
game.getGameState().stackCard(game, _card, _stackOn);
|
||||
|
||||
// Send the result (attached cards get discarded)
|
||||
if (discardedCards.size() > 0)
|
||||
|
||||
@@ -41,7 +41,7 @@ public class StackTopCardsFromDeckEffect extends AbstractEffect {
|
||||
for (int i = 0; i < _count; i++) {
|
||||
final PhysicalCard card = game.getGameState().removeTopDeckCard(_playerId);
|
||||
if (card != null) {
|
||||
game.getGameState().stackCard(card, _target);
|
||||
game.getGameState().stackCard(game, card, _target);
|
||||
stacked++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TransferToSupportEffect extends AbstractEffect {
|
||||
protected FullEffectResult playEffectReturningResult(LotroGame game) {
|
||||
if (isPlayableInFull(game)) {
|
||||
game.getGameState().removeCardsFromZone(Collections.singleton(_card));
|
||||
game.getGameState().addCardToZone(_card, Zone.SUPPORT);
|
||||
game.getGameState().addCardToZone(game, _card, Zone.SUPPORT);
|
||||
return new FullEffectResult(null, true, true);
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
|
||||
@@ -26,6 +26,11 @@ public class SimpleLotroCardBlueprint implements LotroCardBlueprint {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Modifier> getStackedOnModifiers(LotroGame game, PhysicalCard self) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardType getCardType() {
|
||||
return null;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Card1_022 extends AbstractOldEvent {
|
||||
final GameState gameState = game.getGameState();
|
||||
PhysicalCard card = gameState.removeTopDeckCard(_player);
|
||||
if (card != null) {
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
gameState.addTwilight(1);
|
||||
_lastCard = card;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ public interface LotroCardBlueprint {
|
||||
|
||||
public List<? extends Modifier> getAlwaysOnModifiers(LotroGame game, PhysicalCard self);
|
||||
|
||||
public List<? extends Modifier> getStackedOnModifiers(LotroGame game, PhysicalCard self);
|
||||
|
||||
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier);
|
||||
|
||||
public Action getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier);
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.modifiers.Modifier;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifierHook;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersEnvironment;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -21,6 +20,7 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
private PhysicalCardImpl _stackedOn;
|
||||
|
||||
private List<ModifierHook> _modifierHooks;
|
||||
private List<ModifierHook> _modifierHooksStacked;
|
||||
|
||||
private Object _data;
|
||||
|
||||
@@ -60,12 +60,12 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
return _cardController;
|
||||
}
|
||||
|
||||
public void startAffectingGame(LotroGame game, ModifiersEnvironment modifiersEnvironment) {
|
||||
public void startAffectingGame(LotroGame game) {
|
||||
List<? extends Modifier> modifiers = _blueprint.getAlwaysOnModifiers(game, this);
|
||||
if (modifiers != null) {
|
||||
_modifierHooks = new LinkedList<ModifierHook>();
|
||||
for (Modifier modifier : modifiers)
|
||||
_modifierHooks.add(modifiersEnvironment.addAlwaysOnModifier(modifier));
|
||||
_modifierHooks.add(game.getModifiersEnvironment().addAlwaysOnModifier(modifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,23 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
}
|
||||
}
|
||||
|
||||
public void startAffectingGameStacked(LotroGame game) {
|
||||
List<? extends Modifier> modifiers = _blueprint.getStackedOnModifiers(game, this);
|
||||
if (modifiers != null) {
|
||||
_modifierHooksStacked = new LinkedList<ModifierHook>();
|
||||
for (Modifier modifier : modifiers)
|
||||
_modifierHooksStacked.add(game.getModifiersEnvironment().addAlwaysOnModifier(modifier));
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAffectingGameStacked() {
|
||||
if (_modifierHooksStacked != null) {
|
||||
for (ModifierHook modifierHook : _modifierHooksStacked)
|
||||
modifierHook.stop();
|
||||
_modifierHooksStacked = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardId() {
|
||||
return _cardId;
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.communication.GameStateListener;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.logic.PlayerOrder;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersEnvironment;
|
||||
import com.gempukku.lotro.logic.timing.GameStats;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -300,9 +299,9 @@ public class GameState {
|
||||
listener.cardMoved(card);
|
||||
}
|
||||
|
||||
public void attachCard(PhysicalCard card, PhysicalCard attachTo) {
|
||||
public void attachCard(LotroGame game, PhysicalCard card, PhysicalCard attachTo) {
|
||||
((PhysicalCardImpl) card).attachTo((PhysicalCardImpl) attachTo);
|
||||
addCardToZone(card, Zone.ATTACHED);
|
||||
addCardToZone(game, card, Zone.ATTACHED);
|
||||
}
|
||||
|
||||
public void cardAffectsCard(String playerPerforming, PhysicalCard card, Collection<PhysicalCard> affectedCards) {
|
||||
@@ -315,9 +314,9 @@ public class GameState {
|
||||
listener.eventPlayed(card);
|
||||
}
|
||||
|
||||
public void stackCard(PhysicalCard card, PhysicalCard stackOn) {
|
||||
public void stackCard(LotroGame game, PhysicalCard card, PhysicalCard stackOn) {
|
||||
((PhysicalCardImpl) card).stackOn((PhysicalCardImpl) stackOn);
|
||||
addCardToZone(card, Zone.STACKED);
|
||||
addCardToZone(game, card, Zone.STACKED);
|
||||
}
|
||||
|
||||
public void setRingBearer(PhysicalCard card) {
|
||||
@@ -363,6 +362,11 @@ public class GameState {
|
||||
for (PhysicalCard card : cards) {
|
||||
Zone zone = card.getZone();
|
||||
|
||||
if (zone.isInPlay())
|
||||
stopAffecting(card);
|
||||
else if (zone == Zone.STACKED)
|
||||
stopAffectingStacked(card);
|
||||
|
||||
List<PhysicalCardImpl> zoneCards = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone);
|
||||
boolean b = zoneCards.remove(card);
|
||||
if (!b)
|
||||
@@ -409,9 +413,16 @@ public class GameState {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addCardToZone(PhysicalCard card, Zone zone) {
|
||||
public void addCardToZone(LotroGame game, PhysicalCard card, Zone zone) {
|
||||
addCardToZone(game, card, zone, true);
|
||||
}
|
||||
|
||||
private void addCardToZone(LotroGame game, PhysicalCard card, Zone zone, boolean end) {
|
||||
List<PhysicalCardImpl> zoneCards = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone);
|
||||
zoneCards.add((PhysicalCardImpl) card);
|
||||
if (end)
|
||||
zoneCards.add((PhysicalCardImpl) card);
|
||||
else
|
||||
zoneCards.add(0, (PhysicalCardImpl) card);
|
||||
|
||||
((PhysicalCardImpl) card).setZone(zone);
|
||||
|
||||
@@ -426,6 +437,12 @@ public class GameState {
|
||||
for (GameStateListener listener : getPrivateGameStateListeners(card))
|
||||
listener.cardCreated(card);
|
||||
}
|
||||
|
||||
if (zone.isInPlay()) {
|
||||
if (zone != Zone.ADVENTURE_PATH || _currentPhase != Phase.GAME_SETUP)
|
||||
startAffecting(game, card);
|
||||
} else if (zone == Zone.STACKED)
|
||||
startAffectingStacked(game, card);
|
||||
}
|
||||
|
||||
private void removeAllTokens(PhysicalCard card) {
|
||||
@@ -453,11 +470,11 @@ public class GameState {
|
||||
}
|
||||
|
||||
public void putCardOnBottomOfDeck(PhysicalCard card) {
|
||||
addCardToZone(card, Zone.DECK);
|
||||
addCardToZone(null, card, Zone.DECK, true);
|
||||
}
|
||||
|
||||
public void putCardOnTopOfDeck(PhysicalCard card) {
|
||||
_decks.get(card.getOwner()).add(0, (PhysicalCardImpl) card);
|
||||
addCardToZone(null, card, Zone.DECK, false);
|
||||
}
|
||||
|
||||
public boolean iterateActiveCards(PhysicalCardVisitor physicalCardVisitor) {
|
||||
@@ -561,6 +578,15 @@ public class GameState {
|
||||
listener.setPlayerPosition(playerId, i);
|
||||
}
|
||||
|
||||
public void movePlayerToNextSite(LotroGame game) {
|
||||
final String currentPlayerId = getCurrentPlayerId();
|
||||
final int oldPlayerPosition = getPlayerPosition(currentPlayerId);
|
||||
stopAffecting(getCurrentSite());
|
||||
setPlayerPosition(currentPlayerId, oldPlayerPosition + 1);
|
||||
increaseMoveCount();
|
||||
startAffecting(game, getCurrentSite());
|
||||
}
|
||||
|
||||
public int getPlayerPosition(String playerId) {
|
||||
return _playerPosition.get(playerId);
|
||||
}
|
||||
@@ -694,12 +720,21 @@ public class GameState {
|
||||
card.getAttachedTo() != null && isCardInPlayActive(card.getAttachedTo()));
|
||||
}
|
||||
|
||||
public void startAffectingCardsForCurrentPlayer(LotroGame game, ModifiersEnvironment modifiersEnvironment) {
|
||||
public void startAffectingCardsForCurrentPlayer(LotroGame game) {
|
||||
// Active non-sites are affecting
|
||||
for (PhysicalCardImpl physicalCard : _inPlay) {
|
||||
if (isCardInPlayActive(physicalCard) && physicalCard.getBlueprint().getSide() != Side.SITE)
|
||||
startAffecting(game, physicalCard, modifiersEnvironment);
|
||||
startAffecting(game, physicalCard);
|
||||
}
|
||||
startAffecting(game, getCurrentSite(), modifiersEnvironment);
|
||||
|
||||
// Current site is affecting
|
||||
startAffecting(game, getCurrentSite());
|
||||
|
||||
// Stacked cards on active cards are stack-affecting
|
||||
for (List<PhysicalCardImpl> stackedCards : _stacked.values())
|
||||
for (PhysicalCardImpl stackedCard : stackedCards)
|
||||
if (isCardInPlayActive(stackedCard.getStackedOn()))
|
||||
startAffectingStacked(game, stackedCard);
|
||||
}
|
||||
|
||||
public void stopAffectingCardsForCurrentPlayer() {
|
||||
@@ -707,18 +742,32 @@ public class GameState {
|
||||
if (isCardInPlayActive(physicalCard) && physicalCard.getBlueprint().getSide() != Side.SITE)
|
||||
stopAffecting(physicalCard);
|
||||
}
|
||||
|
||||
stopAffecting(getCurrentSite());
|
||||
|
||||
for (List<PhysicalCardImpl> stackedCards : _stacked.values())
|
||||
for (PhysicalCardImpl stackedCard : stackedCards)
|
||||
if (isCardInPlayActive(stackedCard.getStackedOn()))
|
||||
stopAffectingStacked(stackedCard);
|
||||
}
|
||||
|
||||
public void startAffecting(LotroGame game, PhysicalCard card, ModifiersEnvironment modifiersEnvironment) {
|
||||
((PhysicalCardImpl) card).startAffectingGame(game, modifiersEnvironment);
|
||||
private void startAffecting(LotroGame game, PhysicalCard card) {
|
||||
((PhysicalCardImpl) card).startAffectingGame(game);
|
||||
}
|
||||
|
||||
public void stopAffecting(PhysicalCard card) {
|
||||
private void startAffectingStacked(LotroGame game, PhysicalCard card) {
|
||||
((PhysicalCardImpl) card).startAffectingGameStacked(game);
|
||||
}
|
||||
|
||||
private void stopAffecting(PhysicalCard card) {
|
||||
card.removeData();
|
||||
((PhysicalCardImpl) card).stopAffectingGame();
|
||||
}
|
||||
|
||||
private void stopAffectingStacked(PhysicalCard card) {
|
||||
((PhysicalCardImpl) card).stopAffectingGameStacked();
|
||||
}
|
||||
|
||||
public void setCurrentPhase(Phase phase) {
|
||||
_currentPhase = phase;
|
||||
for (GameStateListener listener : getAllGameStateListeners())
|
||||
@@ -811,7 +860,9 @@ public class GameState {
|
||||
public PhysicalCard removeTopDeckCard(String player) {
|
||||
List<PhysicalCardImpl> deck = _decks.get(player);
|
||||
if (deck.size() > 0) {
|
||||
return deck.remove(0);
|
||||
final PhysicalCard topDeckCard = deck.remove(0);
|
||||
removeCardsFromZone(Collections.singleton(topDeckCard));
|
||||
return topDeckCard;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -820,7 +871,9 @@ public class GameState {
|
||||
public PhysicalCard removeBottomDeckCard(String player) {
|
||||
List<PhysicalCardImpl> deck = _decks.get(player);
|
||||
if (deck.size() > 0) {
|
||||
return deck.remove(deck.size() - 1);
|
||||
final PhysicalCard topDeckCard = deck.remove(deck.size() - 1);
|
||||
removeCardsFromZone(Collections.singleton(topDeckCard));
|
||||
return topDeckCard;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -831,7 +884,7 @@ public class GameState {
|
||||
if (deck.size() > 0) {
|
||||
PhysicalCard card = deck.get(0);
|
||||
removeCardsFromZone(Collections.singleton(card));
|
||||
addCardToZone(card, Zone.HAND);
|
||||
addCardToZone(null, card, Zone.HAND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class DiscardCardsFromHandEffect extends AbstractEffect {
|
||||
gameState.sendMessage(getAppendedNames(discardedCards) + " " + GameUtils.be(discardedCards) + " discarded from hand");
|
||||
gameState.removeCardsFromZone(discardedCards);
|
||||
for (PhysicalCard card : discardedCards)
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
|
||||
return new FullEffectResult(new EffectResult[]{new DiscardCardsFromHandResult(_source, discardedCards, _forced)}, discardedCards.size() == _cards.size(), discardedCards.size() == _cards.size());
|
||||
}
|
||||
|
||||
@@ -59,23 +59,21 @@ public class DiscardCardsFromPlayEffect extends AbstractPreventableCardEffect {
|
||||
discardedCards.add(card);
|
||||
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.stopAffecting(card);
|
||||
gameState.removeCardsFromZone(Collections.singleton(card));
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
|
||||
List<PhysicalCard> attachedCards = gameState.getAttachedCards(card);
|
||||
for (PhysicalCard attachedCard : attachedCards) {
|
||||
discardedCards.add(attachedCard);
|
||||
|
||||
gameState.stopAffecting(attachedCard);
|
||||
gameState.removeCardsFromZone(Collections.singleton(attachedCard));
|
||||
gameState.addCardToZone(attachedCard, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, attachedCard, Zone.DISCARD);
|
||||
}
|
||||
|
||||
List<PhysicalCard> stackedCards = gameState.getStackedCards(card);
|
||||
for (PhysicalCard stackedCard : stackedCards) {
|
||||
gameState.removeCardsFromZone(Collections.singleton(stackedCard));
|
||||
gameState.addCardToZone(stackedCard, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, stackedCard, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,30 +47,28 @@ public class KillEffect extends AbstractSuccessfulEffect {
|
||||
|
||||
for (PhysicalCard card : _cards) {
|
||||
gameState.sendMessage(GameUtils.getCardLink(card) + " gets killed");
|
||||
gameState.stopAffecting(card);
|
||||
gameState.removeCardsFromZone(Collections.singleton(card));
|
||||
if (card.getBlueprint().getSide() == Side.FREE_PEOPLE) {
|
||||
killedCards.add(card);
|
||||
gameState.addCardToZone(card, Zone.DEAD);
|
||||
gameState.addCardToZone(game, card, Zone.DEAD);
|
||||
} else {
|
||||
killedCards.add(card);
|
||||
discardedCards.add(card);
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, card, Zone.DISCARD);
|
||||
}
|
||||
|
||||
List<PhysicalCard> attachedCards = gameState.getAttachedCards(card);
|
||||
for (PhysicalCard attachedCard : attachedCards) {
|
||||
discardedCards.add(attachedCard);
|
||||
|
||||
gameState.stopAffecting(attachedCard);
|
||||
gameState.removeCardsFromZone(Collections.singleton(attachedCard));
|
||||
gameState.addCardToZone(attachedCard, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, attachedCard, Zone.DISCARD);
|
||||
}
|
||||
|
||||
List<PhysicalCard> stackedCards = gameState.getStackedCards(card);
|
||||
for (PhysicalCard stackedCard : stackedCards) {
|
||||
gameState.removeCardsFromZone(Collections.singleton(stackedCard));
|
||||
gameState.addCardToZone(stackedCard, Zone.DISCARD);
|
||||
gameState.addCardToZone(game, stackedCard, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class FirstPlayerPlaysSiteGameProcess implements GameProcess {
|
||||
GameState gameState = _game.getGameState();
|
||||
PhysicalCard firstSite = Filters.filter(gameState.getAdventureDeck(_firstPlayer), gameState, _game.getModifiersQuerying(), Filters.siteNumber(1)).iterator().next();
|
||||
gameState.removeCardsFromZone(Collections.singleton(firstSite));
|
||||
gameState.addCardToZone(firstSite, Zone.ADVENTURE_PATH);
|
||||
gameState.addCardToZone(_game, firstSite, Zone.ADVENTURE_PATH);
|
||||
|
||||
for (String playerId : gameState.getPlayerOrder().getAllPlayers())
|
||||
gameState.setPlayerPosition(playerId, 1);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MulliganProcess implements GameProcess {
|
||||
Set<PhysicalCard> hand = new HashSet<PhysicalCard>(gameState.getHand(nextPlayer));
|
||||
gameState.removeCardsFromZone(hand);
|
||||
for (PhysicalCard card : hand)
|
||||
gameState.addCardToZone(card, Zone.DECK);
|
||||
gameState.addCardToZone(_game, card, Zone.DECK);
|
||||
|
||||
gameState.shuffleDeck(nextPlayer);
|
||||
for (int i = 0; i < 6; i++)
|
||||
|
||||
@@ -29,12 +29,12 @@ public class PlayRingBearerRingAndAddBurdersGameProcess implements GameProcess {
|
||||
for (String playerId : gameState.getPlayerOrder().getAllPlayers()) {
|
||||
PhysicalCard ringBearer = Filters.filter(gameState.getDeck(playerId), gameState, _game.getModifiersQuerying(), Filters.keyword(Keyword.RING_BEARER)).iterator().next();
|
||||
gameState.removeCardsFromZone(Collections.singleton(ringBearer));
|
||||
gameState.addCardToZone(ringBearer, Zone.FREE_CHARACTERS);
|
||||
gameState.addCardToZone(_game, 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.removeCardsFromZone(Collections.singleton(ring));
|
||||
gameState.attachCard(ring, ringBearer);
|
||||
gameState.attachCard(_game, ring, ringBearer);
|
||||
|
||||
gameState.startPlayerTurn(playerId);
|
||||
gameState.addBurdens(_bids.get(playerId));
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.gempukku.lotro.logic.timing.processes.pregame;
|
||||
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.PlayOrder;
|
||||
import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayStartingFellowshipGameProcess implements GameProcess {
|
||||
private LotroGame _game;
|
||||
private PlayOrder _playOrder;
|
||||
@@ -29,13 +26,6 @@ public class PlayStartingFellowshipGameProcess implements GameProcess {
|
||||
if (nextPlayer != null) {
|
||||
_game.getGameState().startPlayerTurn(nextPlayer);
|
||||
|
||||
PhysicalCard ringBearer = _game.getGameState().getRingBearer(nextPlayer);
|
||||
_game.getGameState().startAffecting(_game, ringBearer, _game.getModifiersEnvironment());
|
||||
|
||||
List<PhysicalCard> attachedToRingBearer = _game.getGameState().getAttachedCards(ringBearer);
|
||||
for (PhysicalCard physicalCard : attachedToRingBearer)
|
||||
_game.getGameState().startAffecting(_game, physicalCard, _game.getModifiersEnvironment());
|
||||
|
||||
_nextProcess = new PlayerPlaysStartingFellowshipGameProcess(_game, nextPlayer, new PlayStartingFellowshipGameProcess(_game, _playOrder, _firstPlayer));
|
||||
} else {
|
||||
_nextProcess = new PlayersDrawEightCardsGameProcess(_game, _firstPlayer);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class StartOfTurnGameProcess implements GameProcess {
|
||||
|
||||
String nextPlayer = playOrder.getNextPlayer();
|
||||
_game.getGameState().startPlayerTurn(nextPlayer);
|
||||
_game.getGameState().startAffectingCardsForCurrentPlayer(_game, _game.getModifiersEnvironment());
|
||||
_game.getGameState().startAffectingCardsForCurrentPlayer(_game);
|
||||
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new StartOfTurnResult(), "Start of turn"), "Start of turn"));
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ public class MovePlayerTokenToNextSiteGameProcess implements GameProcess {
|
||||
@Override
|
||||
public void process() {
|
||||
GameState gameState = _game.getGameState();
|
||||
gameState.stopAffecting(gameState.getCurrentSite());
|
||||
gameState.setPlayerPosition(gameState.getCurrentPlayerId(), gameState.getCurrentSiteNumber() + 1);
|
||||
gameState.startAffecting(_game, gameState.getCurrentSite(), _game.getModifiersEnvironment());
|
||||
gameState.increaseMoveCount();
|
||||
gameState.movePlayerToNextSite(_game);
|
||||
|
||||
int siteTwilightCost = _game.getModifiersQuerying().getTwilightCost(gameState, gameState.getCurrentSite());
|
||||
int companionCount = Filters.countActive(gameState, _game.getModifiersQuerying(), Filters.type(CardType.COMPANION));
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PlayerPlaysNextSiteIfNotThereGameProcess implements GameProcess {
|
||||
Filters.siteNumber(nextSiteNumber)).iterator().next();
|
||||
|
||||
gameState.removeCardsFromZone(Collections.singleton(nextSite));
|
||||
gameState.addCardToZone(nextSite, Zone.ADVENTURE_PATH);
|
||||
gameState.addCardToZone(_game, nextSite, Zone.ADVENTURE_PATH);
|
||||
|
||||
final PhysicalCard site = nextSite;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user