Restructuring how GameState and modifiers work.
This commit is contained in:
@@ -42,6 +42,8 @@ public class AttachPermanentAction extends AbstractCostToEffectAction {
|
||||
public AttachPermanentAction(final LotroGame game, final PhysicalCard card, Filter filter, final Map<Filter, Integer> attachCostModifiers, final int twilightModifier) {
|
||||
_cardToAttach = card;
|
||||
|
||||
final Zone zone = card.getZone();
|
||||
|
||||
_chooseTargetEffect =
|
||||
new ChooseActiveCardEffect(null, card.getOwner(), "Attach " + card.getBlueprint().getName() + ". Choose target to attach to", filter) {
|
||||
@Override
|
||||
@@ -60,8 +62,8 @@ public class AttachPermanentAction extends AbstractCostToEffectAction {
|
||||
modifier += filterIntegerEntry.getValue();
|
||||
|
||||
List<Effect> preCostEffects = new LinkedList<Effect>();
|
||||
preCostEffects.add(new SendMessageEffect(card.getOwner() + " plays " + GameUtils.getCardLink(card) + " from " + card.getZone().getHumanReadable() + " on " + GameUtils.getCardLink(target)));
|
||||
if (card.getZone() == Zone.DECK)
|
||||
preCostEffects.add(new SendMessageEffect(card.getOwner() + " plays " + GameUtils.getCardLink(card) + " from " + zone.getHumanReadable() + " on " + GameUtils.getCardLink(target)));
|
||||
if (zone == Zone.DECK)
|
||||
preCostEffects.add(new ShuffleDeckEffect(card.getOwner()));
|
||||
appendCost(new PayPlayOnTwilightCostEffect(card, target, modifier));
|
||||
|
||||
|
||||
@@ -20,9 +20,7 @@ import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.Condition;
|
||||
import com.gempukku.lotro.logic.modifiers.Modifier;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
import com.gempukku.lotro.logic.timing.AbstractSuccessfulEffect;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -56,7 +54,7 @@ public class Card6_011 extends AbstractEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
|
||||
public PlayEventAction getPlayCardAction(final String playerId, final LotroGame game, final PhysicalCard self, int twilightModifier) {
|
||||
final PlayEventAction action = new PlayEventAction(self);
|
||||
List<Effect> possibleEffects = new LinkedList<Effect>();
|
||||
possibleEffects.add(
|
||||
@@ -66,43 +64,9 @@ public class Card6_011 extends AbstractEvent {
|
||||
protected void validDecisionMade(int index, String result) {
|
||||
action.skipDiscardPart();
|
||||
if (index == 0)
|
||||
action.insertEffect(
|
||||
new AbstractSuccessfulEffect() {
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult.Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult[] playEffect(LotroGame game) {
|
||||
game.getGameState().putCardOnTopOfDeck(self);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
game.getGameState().putCardOnTopOfDeck(self);
|
||||
else
|
||||
action.insertEffect(
|
||||
new AbstractSuccessfulEffect() {
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult.Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult[] playEffect(LotroGame game) {
|
||||
game.getGameState().putCardOnBottomOfDeck(self);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
game.getGameState().putCardOnBottomOfDeck(self);
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
@@ -124,7 +88,6 @@ public class Card6_011 extends AbstractEvent {
|
||||
new MultipleChoiceAwaitingDecision(1, "Where to put selected card?", new String[]{"Top of deck", "Bottom of deck"}) {
|
||||
@Override
|
||||
protected void validDecisionMade(int index, String result) {
|
||||
|
||||
if (index == 0)
|
||||
for (PhysicalCard selectedCard : selectedCards)
|
||||
action.insertEffect(
|
||||
|
||||
@@ -398,6 +398,8 @@ public class GameState {
|
||||
for (GameStateListener listener : getPrivateGameStateListeners(card)) {
|
||||
getValue(listenerCards, listener).add(card);
|
||||
}
|
||||
|
||||
((PhysicalCardImpl) card).setZone(null);
|
||||
}
|
||||
|
||||
for (Map.Entry<GameStateListener, Set<PhysicalCard>> gameStateListenerSetEntry : listenerCards.entrySet())
|
||||
@@ -424,6 +426,9 @@ public class GameState {
|
||||
else
|
||||
zoneCards.add(0, (PhysicalCardImpl) card);
|
||||
|
||||
if (card.getZone() != null)
|
||||
throw new RuntimeException("Card was in " + card.getZone() + " when tried to add to zone: " + zone);
|
||||
|
||||
((PhysicalCardImpl) card).setZone(zone);
|
||||
|
||||
if (zone == Zone.ADVENTURE_PATH) {
|
||||
@@ -860,7 +865,7 @@ public class GameState {
|
||||
public PhysicalCard removeTopDeckCard(String player) {
|
||||
List<PhysicalCardImpl> deck = _decks.get(player);
|
||||
if (deck.size() > 0) {
|
||||
final PhysicalCard topDeckCard = deck.remove(0);
|
||||
final PhysicalCard topDeckCard = deck.get(0);
|
||||
removeCardsFromZone(Collections.singleton(topDeckCard));
|
||||
return topDeckCard;
|
||||
} else {
|
||||
@@ -871,7 +876,7 @@ public class GameState {
|
||||
public PhysicalCard removeBottomDeckCard(String player) {
|
||||
List<PhysicalCardImpl> deck = _decks.get(player);
|
||||
if (deck.size() > 0) {
|
||||
final PhysicalCard topDeckCard = deck.remove(deck.size() - 1);
|
||||
final PhysicalCard topDeckCard = deck.get(deck.size() - 1);
|
||||
removeCardsFromZone(Collections.singleton(topDeckCard));
|
||||
return topDeckCard;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user