Changing how exhaustion works.

This commit is contained in:
marcins78@gmail.com
2011-10-24 09:53:34 +00:00
parent 7076daaeb5
commit 2a77f92000
21 changed files with 117 additions and 56 deletions

View File

@@ -1,31 +1,31 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.results.ExertResult;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
import java.util.Collection;
public class ExhaustCharacterEffect extends AbstractEffect {
private String _playerId;
private CostToEffectAction _action;
private PhysicalCard _physicalCard;
private boolean _sendMessage;
private PhysicalCard _source;
private Action _action;
private Filterable[] _filters;
public ExhaustCharacterEffect(String playerId, CostToEffectAction action, PhysicalCard physicalCard) {
this(playerId, action, physicalCard, true);
public ExhaustCharacterEffect(PhysicalCard source, Action action, PhysicalCard physicalCard) {
this(source, action, Filters.sameCard(physicalCard));
}
private ExhaustCharacterEffect(String playerId, CostToEffectAction action, PhysicalCard physicalCard, boolean sendMessage) {
_playerId = playerId;
public ExhaustCharacterEffect(PhysicalCard source, Action action, Filterable... filters) {
_source = source;
_action = action;
_physicalCard = physicalCard;
_sendMessage = sendMessage;
_filters = filters;
}
@Override
@@ -35,24 +35,40 @@ public class ExhaustCharacterEffect extends AbstractEffect {
@Override
public String getText(LotroGame game) {
return "Exhaust " + _physicalCard.getBlueprint().getName();
return "Exhaust " + getAppendedNames(Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), _filters));
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return PlayConditions.canExert(_action.getActionSource(), game.getGameState(), game.getModifiersQuerying(), _physicalCard);
return Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), _filters).size() > 0;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
boolean canExert = PlayConditions.canExert(_action.getActionSource(), game.getGameState(), game.getModifiersQuerying(), _physicalCard);
if (canExert) {
if (_sendMessage)
game.getGameState().sendMessage(_playerId + " exhausts " + GameUtils.getCardLink(_physicalCard));
game.getGameState().addWound(_physicalCard);
_action.appendEffect(new ExhaustCharacterEffect(_playerId, _action, _physicalCard, false));
return new FullEffectResult(Collections.singleton(new ExertResult(Collections.singleton(_physicalCard))), true, true);
}
SubAction subAction = new SubAction(_action);
subAction.appendEffect(new InfiniteExertionEffect(_source, subAction, _filters));
game.getActionsEnvironment().addActionToStack(subAction);
final Collection<PhysicalCard> cards = Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), _filters);
if (cards.size() > 0)
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " exhausts " + getAppendedNames(cards));
return new FullEffectResult(null, false, false);
}
private class InfiniteExertionEffect extends ExertCharactersEffect {
private SubAction _subAction;
private InfiniteExertionEffect(PhysicalCard source, SubAction subAction, Filterable[] filters) {
super(source, filters);
_subAction = subAction;
}
@Override
protected Collection<? extends EffectResult> playoutEffectOn(LotroGame game, Collection<PhysicalCard> cards) {
final Collection<? extends EffectResult> effectResults = super.playoutEffectOn(game, cards);
if (getAffectedCards(game).size() > 0)
_subAction.appendEffect(new InfiniteExertionEffect(_source, _subAction, _filters));
return effectResults;
}
}
}

View File

@@ -0,0 +1,42 @@
package com.gempukku.lotro.cards.effects.choose;
import com.gempukku.lotro.cards.effects.ExhaustCharacterEffect;
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.filters.Filter;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.effects.ChooseActiveCardsEffect;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collection;
public class ChooseAndExhaustCharactersEffect extends ChooseActiveCardsEffect {
private Action _action;
public ChooseAndExhaustCharactersEffect(Action action, String playerId, int minimum, int maximum, Filterable... filters) {
super(action.getActionSource(), playerId, "Choose characters to exert", minimum, maximum, filters);
_action = action;
}
@Override
protected Filter getExtraFilter() {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canBeExerted(gameState, _action.getActionSource(), physicalCard)
&& modifiersQuerying.getVitality(gameState, physicalCard) > 1;
}
};
}
@Override
protected final void cardsSelected(LotroGame game, Collection<PhysicalCard> characters) {
SubAction subAction = new SubAction(_action);
subAction.appendEffect(new ExhaustCharacterEffect(_action.getActionSource(), subAction, Filters.in(characters)));
game.getActionsEnvironment().addActionToStack(subAction);
}
}

View File

@@ -33,7 +33,7 @@ public class Card1_113 extends AbstractOldEvent {
new ChooseActiveCardEffect(self, playerId, "Choose a minion", Filters.type(CardType.MINION)) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard minion) {
action.appendEffect(new ExhaustCharacterEffect(playerId, action, minion));
action.appendEffect(new ExhaustCharacterEffect(self, action, minion));
}
});
return action;

View File

@@ -42,7 +42,7 @@ public class Card1_175 extends AbstractPermanent {
PlayCardResult playCardResult = (PlayCardResult) effectResult;
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(
new ExhaustCharacterEffect(playCardResult.getPlayedCard().getOwner(), action, playCardResult.getPlayedCard()));
new ExhaustCharacterEffect(self, action, playCardResult.getPlayedCard()));
return Collections.singletonList(action);
}
return null;

View File

@@ -5,13 +5,12 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.PreventableEffect;
import com.gempukku.lotro.cards.effects.RemoveTwilightEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndDiscardCardsFromPlayEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseOpponentEffect;
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.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.effects.DiscardCardsFromPlayEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
@@ -48,11 +47,10 @@ public class Card2_017 extends AbstractResponseOldEvent {
protected void opponentChosen(String opponentId) {
action.appendEffect(
new PreventableEffect(action,
new ChooseActiveCardEffect(self, opponentId, "Choose minion to discard", Filters.type(CardType.MINION)) {
new ChooseAndDiscardCardsFromPlayEffect(action, opponentId, 1, 1, CardType.MINION) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new DiscardCardsFromPlayEffect(self, card));
public String getText(LotroGame game) {
return "Choose minion to discard";
}
},
Collections.singletonList(opponentId),

View File

@@ -48,6 +48,11 @@ public class Card2_028 extends AbstractOldEvent {
new AddUntilStartOfPhaseModifierEffect(
new KeywordModifier(self, Filters.sameCard(card), Keyword.DEFENDER), Phase.REGROUP));
}
@Override
public String getText(LotroGame game) {
return "Make a companion Defender +1";
}
},
Arrays.asList(GameUtils.getOpponents(game, playerId)),
new RemoveTwilightEffect(3)));

View File

@@ -50,7 +50,7 @@ public class Card2_031 extends AbstractPermanent {
if (PlayConditions.played(game.getGameState(), game.getModifiersQuerying(), effectResult, Filters.and(Filters.culture(Culture.SAURON), Filters.type(CardType.MINION)))) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(
new ExhaustCharacterEffect(self.getOwner(), action, ((PlayCardResult) effectResult).getPlayedCard()));
new ExhaustCharacterEffect(self, action, ((PlayCardResult) effectResult).getPlayedCard()));
return Collections.singletonList(action);
}
if (effectResult.getType() == EffectResult.Type.START_OF_PHASE

View File

@@ -44,7 +44,7 @@ public class Card2_033 extends AbstractResponseOldEvent {
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose a minion", Filters.exhausted, Filters.race(Race.ORC)) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard orc) {
protected void cardSelected(LotroGame game, final PhysicalCard orc) {
action.insertEffect(
new PreventableEffect(action,
new DiscardCardsFromPlayEffect(self, orc),

View File

@@ -50,7 +50,7 @@ public class Card3_050 extends AbstractOldEvent {
protected void cardSelected(LotroGame game, PhysicalCard aragorn) {
action.appendEffect(
new PreventableEffect(action,
new ExhaustCharacterEffect(playerId, action, aragorn),
new ExhaustCharacterEffect(self, action, aragorn),
Collections.singletonList(game.getGameState().getCurrentPlayerId()),
new AddBurdenEffect(self, 2)));
}

View File

@@ -32,7 +32,7 @@ public class Card3_065 extends AbstractMinion {
}
@Override
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.REGROUP, self, 0)
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), 2, Filters.sameCard(self))) {
final ActivateCardAction action = new ActivateCardAction(self);
@@ -45,7 +45,7 @@ public class Card3_065 extends AbstractMinion {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new ExhaustCharacterEffect(playerId, action, card));
new ExhaustCharacterEffect(self, action, card));
}
});
return Collections.singletonList(action);

View File

@@ -34,7 +34,7 @@ public class Card3_066 extends AbstractMinion {
}
@Override
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.MANEUVER, self, 0)
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), 2, Filters.sameCard(self))
&& game.getGameState().getBurdens() >= 5) {
@@ -48,7 +48,7 @@ public class Card3_066 extends AbstractMinion {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new ExhaustCharacterEffect(playerId, action, card));
new ExhaustCharacterEffect(self, action, card));
}
});
return Collections.singletonList(action);

View File

@@ -38,7 +38,7 @@ public class Card4_114 extends AbstractCompanion {
}
@Override
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self)
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), self)) {
final ActivateCardAction action = new ActivateCardAction(self);
@@ -49,7 +49,7 @@ public class Card4_114 extends AbstractCompanion {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new ExhaustCharacterEffect(playerId, action, card));
new ExhaustCharacterEffect(self, action, card));
}
});
return Collections.singletonList(action);

View File

@@ -41,7 +41,7 @@ public class Card4_127 extends AbstractCompanion {
}
@Override
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self)
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), self)) {
final ActivateCardAction action = new ActivateCardAction(self);
@@ -52,7 +52,7 @@ public class Card4_127 extends AbstractCompanion {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new ExhaustCharacterEffect(playerId, action, card));
new ExhaustCharacterEffect(self, action, card));
}
});
return Collections.singletonList(action);

View File

@@ -47,7 +47,7 @@ public class Card4_188 extends AbstractMinion {
}
@Override
public List<? extends ActivateCardAction> getOptionalInPlayAfterActions(final String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
public List<? extends ActivateCardAction> getOptionalInPlayAfterActions(final String playerId, LotroGame game, EffectResult effectResult, final PhysicalCard self) {
if (effectResult.getType() == EffectResult.Type.KILL
&& PlayConditions.canExert(self, game, 2, Filters.sameCard(self))) {
@@ -63,7 +63,7 @@ public class Card4_188 extends AbstractMinion {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new ExhaustCharacterEffect(playerId, action, card));
new ExhaustCharacterEffect(self, action, card));
}
});
return Collections.singletonList(action);

View File

@@ -33,7 +33,7 @@ public class Card4_209 extends AbstractOldEvent {
}
@Override
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
action.appendCost(
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 2, 2, Filters.culture(Culture.ISENGARD), Filters.keyword(Keyword.ARCHER)));
@@ -42,7 +42,7 @@ public class Card4_209 extends AbstractOldEvent {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new ExhaustCharacterEffect(playerId, action, card));
new ExhaustCharacterEffect(self, action, card));
}
});
return action;

View File

@@ -36,7 +36,7 @@ public class Card6_070 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActionsFromStacked(final String playerId, LotroGame game, PhysicalCard self) {
public List<? extends Action> getPhaseActionsFromStacked(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseStackedShadowCardDuringPhase(game.getGameState(), Phase.REGROUP, self, 2)
&& self.getStackedOn().getBlueprint().getCulture() == Culture.ISENGARD) {
final ActivateCardAction action = new ActivateCardAction(self);
@@ -49,7 +49,7 @@ public class Card6_070 extends AbstractMinion {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new ExhaustCharacterEffect(playerId, action, card));
new ExhaustCharacterEffect(self, action, card));
}
});
return Collections.singletonList(action);

View File

@@ -30,7 +30,7 @@ public class Card6_105 extends AbstractPermanent {
}
@Override
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.REGROUP, self, 0)
&& PlayConditions.canExert(self, game, Culture.SAURON, Race.ORC)
&& PlayConditions.canPlayFromHand(playerId, game, -4, CardType.MINION, Filters.or(Race.NAZGUL, Culture.SAURON))) {
@@ -42,7 +42,7 @@ public class Card6_105 extends AbstractPermanent {
@Override
protected void cardChosenCallback(PhysicalCard cardChosenToPlay) {
action.appendEffect(
new ExhaustCharacterEffect(playerId, action, cardChosenToPlay));
new ExhaustCharacterEffect(self, action, cardChosenToPlay));
}
});
return Collections.singletonList(action);

View File

@@ -30,7 +30,7 @@ public class Card6_084 extends AbstractPermanent {
}
@Override
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.REGROUP, self, 0)
&& PlayConditions.canExert(self, game, 2, Race.NAZGUL)
&& PlayConditions.canPlayFromHand(playerId, game, -8, CardType.MINION, Filters.or(Culture.WRAITH, Culture.SAURON))) {
@@ -42,7 +42,7 @@ public class Card6_084 extends AbstractPermanent {
@Override
protected void cardChosenCallback(PhysicalCard cardChosenToPlay) {
action.appendEffect(
new ExhaustCharacterEffect(playerId, action, cardChosenToPlay));
new ExhaustCharacterEffect(self, action, cardChosenToPlay));
}
});
return Collections.singletonList(action);

View File

@@ -50,7 +50,7 @@ public class DiscardCardsFromPlayEffect extends AbstractPreventableCardEffect {
@Override
public String getText(LotroGame game) {
Collection<PhysicalCard> cards = getAffectedCardsMinusPrevented(game);
return "Discard - " + getAppendedTextNames(cards);
return "Discard " + getAppendedTextNames(cards);
}
@Override

View File

@@ -18,7 +18,7 @@ public class DrawCardEffect extends AbstractEffect {
@Override
public String getText(LotroGame game) {
return "Draw " + _count + " card(s)";
return "Draw " + _count + " card" + ((_count > 1) ? "s" : "");
}
@Override

View File

@@ -56,7 +56,7 @@ public class WoundCharactersEffect extends AbstractPreventableCardEffect {
@Override
public String getText(LotroGame game) {
Collection<PhysicalCard> cards = getAffectedCardsMinusPrevented(game);
return "Wound - " + getAppendedTextNames(cards);
return "Wound " + getAppendedTextNames(cards);
}
@Override