Reducing number of Anonymous classes for cards.

This commit is contained in:
marcins78@gmail.com
2011-09-11 08:49:15 +00:00
parent 4e7ce7a5f3
commit 270d57b5dd
15 changed files with 75 additions and 91 deletions

View File

@@ -27,6 +27,11 @@ public class ChooseAndDiscardCardsFromHandEffect extends UnrespondableEffect {
this(action, playerId, cost, 1);
}
@Override
public String getText() {
return "Discard " + _count + " card(s) from hand";
}
@Override
public boolean canPlayEffect(LotroGame game) {
return (game.getGameState().getHand(_playerId).size() >= _count);

View File

@@ -0,0 +1,27 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.LinkedList;
import java.util.List;
public abstract class RevealTopCardsOfDrawDeckEffect extends UnrespondableEffect {
private String _playerId;
private int _count;
public RevealTopCardsOfDrawDeckEffect(String playerId, int count) {
_playerId = playerId;
_count = count;
}
@Override
public void playEffect(LotroGame game) {
List<? extends PhysicalCard> deck = game.getGameState().getDeck(_playerId);
int count = Math.min(deck.size(), _count);
cardsRevealed(new LinkedList<PhysicalCard>(deck.subList(0, count)));
}
protected abstract void cardsRevealed(List<PhysicalCard> cards);
}

View File

@@ -4,6 +4,7 @@ import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.DiscardCardFromDeckEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDeckIntoHandOrDiscardEffect;
import com.gempukku.lotro.cards.effects.RevealTopCardsOfDrawDeckEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Race;
@@ -11,9 +12,7 @@ import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.LinkedList;
import java.util.List;
/**
@@ -45,13 +44,9 @@ public class Card1_028 extends AbstractEvent {
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
action.addEffect(
new UnrespondableEffect() {
new RevealTopCardsOfDrawDeckEffect(playerId, 3) {
@Override
public void playEffect(LotroGame game) {
List<? extends PhysicalCard> deck = game.getGameState().getDeck(playerId);
int cardCount = Math.min(deck.size(), 3);
List<? extends PhysicalCard> cards = new LinkedList<PhysicalCard>(deck.subList(0, cardCount));
protected void cardsRevealed(List<PhysicalCard> cards) {
for (PhysicalCard card : cards) {
if (card.getBlueprint().getSide() == Side.FREE_PEOPLE)
action.addEffect(new PutCardFromDeckIntoHandOrDiscardEffect(card));

View File

@@ -20,7 +20,6 @@ import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.LinkedList;
@@ -57,23 +56,7 @@ public class Card1_047 extends AbstractAttachableFPPossession {
possibleCosts.add(
new ExertCharacterEffect(self.getAttachedTo()));
possibleCosts.add(
new UnrespondableEffect() {
@Override
public String getText() {
return "Discard 2 cards";
}
@Override
public boolean canPlayEffect(LotroGame game) {
return game.getGameState().getHand(playerId).size() >= 2;
}
@Override
public void playEffect(LotroGame game) {
action.addCost(new ChooseAndDiscardCardsFromHandEffect(action, playerId, true));
action.addCost(new ChooseAndDiscardCardsFromHandEffect(action, playerId, true));
}
});
new ChooseAndDiscardCardsFromHandEffect(action, playerId, true, 2));
action.addCost(
new ChoiceEffect(action, playerId, possibleCosts, true));

View File

@@ -56,8 +56,7 @@ public class Card1_173 extends AbstractPermanent {
new UnrespondableEffect() {
@Override
public void playEffect(LotroGame game) {
WoundCharacterEffect woundEffect = (WoundCharacterEffect) effect;
woundEffect.prevent();
((WoundCharacterEffect) effect).prevent();
}
});
return Collections.singletonList(action);

View File

@@ -2,17 +2,13 @@ package com.gempukku.lotro.cards.set1.sauron;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseAndDiscardCardsFromHandEffect;
import com.gempukku.lotro.cards.effects.DiscardCardFromDeckEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDeckIntoHandOrDiscardEffect;
import com.gempukku.lotro.cards.effects.RemoveTwilightEffect;
import com.gempukku.lotro.cards.effects.*;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.List;
@@ -47,12 +43,14 @@ public class Card1_242 extends AbstractPermanent {
"and one other card from hand.");
action.addCost(new RemoveTwilightEffect(3));
action.addEffect(
new UnrespondableEffect() {
new RevealTopCardsOfDrawDeckEffect(playerId, 1) {
@Override
public void playEffect(LotroGame game) {
List<? extends PhysicalCard> deck = game.getGameState().getDeck(playerId);
if (deck.size() > 0) {
PhysicalCard topCard = deck.get(0);
protected void cardsRevealed(List<PhysicalCard> cards) {
if (cards.size() == 0) {
action.addEffect(
new ChooseAndDiscardCardsFromHandEffect(action, playerId, false));
} else {
PhysicalCard topCard = cards.get(0);
if (topCard.getBlueprint().getCulture() == Culture.SAURON)
action.addEffect(
new PutCardFromDeckIntoHandOrDiscardEffect(topCard));

View File

@@ -6,7 +6,7 @@ import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import com.gempukku.lotro.logic.effects.CorruptRingBearerEffect;
/**
* Set: The Fellowship of the Ring
@@ -33,12 +33,7 @@ public class Card1_243 extends AbstractEvent {
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
PlayEventAction action = new PlayEventAction(self);
action.addEffect(
new UnrespondableEffect() {
@Override
public void playEffect(LotroGame game) {
game.getGameState().setLoserPlayerId(game.getGameState().getCurrentPlayerId());
}
});
new CorruptRingBearerEffect());
return action;
}

View File

@@ -8,9 +8,9 @@ import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.effects.CorruptRingBearerEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.List;
@@ -49,12 +49,7 @@ public class Card1_252 extends AbstractPermanent {
&& game.getGameState().getDeck(game.getGameState().getCurrentPlayerId()).size() == 0) {
DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, null, "Corrupt Ring-Bearer");
action.addEffect(
new UnrespondableEffect() {
@Override
public void playEffect(LotroGame game) {
game.getGameState().setLoserPlayerId(game.getGameState().getCurrentPlayerId());
}
});
new CorruptRingBearerEffect());
return Collections.singletonList(action);
}
return null;

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.AddTwilightEffect;
import com.gempukku.lotro.cards.effects.DiscardCardFromDeckEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDeckIntoHandOrDiscardEffect;
import com.gempukku.lotro.cards.effects.RevealTopCardsOfDrawDeckEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
@@ -13,10 +14,8 @@ import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
@@ -43,13 +42,9 @@ public class Card1_301 extends AbstractAlly {
final DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, Keyword.FELLOWSHIP, "Add (2) to reveal the top 3 cards of your draw deck. Take all SHIRE cards revealed into hand and discard the rest.");
action.addCost(new AddTwilightEffect(2));
action.addEffect(
new UnrespondableEffect() {
new RevealTopCardsOfDrawDeckEffect(playerId, 3) {
@Override
public void playEffect(LotroGame game) {
List<? extends PhysicalCard> deck = game.getGameState().getDeck(playerId);
int cardCount = Math.min(deck.size(), 3);
List<? extends PhysicalCard> cards = new LinkedList<PhysicalCard>(deck.subList(0, cardCount));
protected void cardsRevealed(List<PhysicalCard> cards) {
for (PhysicalCard card : cards) {
if (card.getBlueprint().getCulture() == Culture.SHIRE)
action.addEffect(new PutCardFromDeckIntoHandOrDiscardEffect(card));
@@ -58,7 +53,6 @@ public class Card1_301 extends AbstractAlly {
}
}
});
return Collections.singletonList(action);
}
return null;

View File

@@ -3,6 +3,7 @@ package com.gempukku.lotro.cards.set1.wraith;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.CancelEffect;
import com.gempukku.lotro.cards.effects.TransferPermanentEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
@@ -16,7 +17,6 @@ import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.List;
@@ -43,13 +43,7 @@ public class Card1_207 extends AbstractPermanent {
&& game.getGameState().getSkirmish().getFellowshipCharacter() != null) {
DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, Keyword.SKIRMISH, "Transfer this condition to character skirmishing a Nazgul");
action.addEffect(
new UnrespondableEffect() {
@Override
public void playEffect(LotroGame game) {
PhysicalCard fpCharacter = game.getGameState().getSkirmish().getFellowshipCharacter();
game.getGameState().attachCard(self, fpCharacter);
}
});
new TransferPermanentEffect(self, game.getGameState().getSkirmish().getFellowshipCharacter()));
return Collections.singletonList(action);
}
return null;

View File

@@ -3,6 +3,7 @@ package com.gempukku.lotro.cards.set1.wraith;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.AddBurdenEffect;
import com.gempukku.lotro.cards.effects.TransferPermanentEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
@@ -11,7 +12,6 @@ import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.effects.WoundCharacterEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.List;
@@ -39,14 +39,7 @@ public class Card1_209 extends AbstractPermanent {
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.sameCard(game.getGameState().getSkirmish().getFellowshipCharacter()), Filters.not(Filters.hasAttached(Filters.name("Blade Tip"))))) {
DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, null, "Transfer condition to losing character");
action.addEffect(
new UnrespondableEffect() {
@Override
public void playEffect(LotroGame game) {
PhysicalCard fpCharacter = game.getGameState().getSkirmish().getFellowshipCharacter();
game.getGameState().attachCard(self, fpCharacter);
}
});
new TransferPermanentEffect(self, game.getGameState().getSkirmish().getFellowshipCharacter()));
return Collections.singletonList(action);
}
return null;

View File

@@ -2,6 +2,7 @@ package com.gempukku.lotro.cards.set1.wraith;
import com.gempukku.lotro.cards.AbstractAttachable;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.TransferPermanentEffect;
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filter;
@@ -13,7 +14,6 @@ import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.effects.DiscardCardFromPlayEffect;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.List;
@@ -62,12 +62,7 @@ public class Card1_216 extends AbstractAttachable {
final PhysicalCard bladeTip = Filters.findFirstActive(game.getGameState(), game.getModifiersQuerying(), Filters.name("Blade Tip"), Filters.owner(playerId), Filters.zone(Zone.SHADOW_SUPPORT));
if (bladeTip != null)
action.addEffect(
new UnrespondableEffect() {
@Override
public void playEffect(LotroGame game) {
game.getGameState().attachCard(bladeTip, fpChar);
}
});
new TransferPermanentEffect(bladeTip, fpChar));
}
}
return Collections.singletonList(action);

View File

@@ -173,6 +173,10 @@ public class GameState {
}
public void transferCard(PhysicalCard card, PhysicalCard transferTo) {
if (card.getZone() != Zone.ATTACHED) {
removeCardFromZone(card);
addCardToZone(card, Zone.ATTACHED);
}
((PhysicalCardImpl) card).attachTo((PhysicalCardImpl) transferTo);
}

View File

@@ -0,0 +1,11 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
public class CorruptRingBearerEffect extends UnrespondableEffect {
@Override
public void playEffect(LotroGame game) {
game.getGameState().setLoserPlayerId(game.getGameState().getCurrentPlayerId());
}
}

View File

@@ -7,6 +7,7 @@ import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.game.state.actions.DefaultActionsEnvironment;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.effects.CorruptRingBearerEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
@@ -42,12 +43,7 @@ public class LoseConditionsRule {
if (game.getGameState().getBurdens() >= ringBearerResistance) {
DefaultCostToEffectAction action = new DefaultCostToEffectAction(null, null, "Losing the game due to Ring-Bearer corruption");
action.addEffect(
new UnrespondableEffect() {
@Override
public void playEffect(LotroGame game) {
game.playerLost(game.getGameState().getCurrentPlayerId());
}
});
new CorruptRingBearerEffect());
return Collections.singletonList(action);
}
return null;