"Axe of Erebor"
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.gempukku.lotro.cards.effects;
|
||||
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
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.SubAction;
|
||||
import com.gempukku.lotro.logic.decisions.CardsSelectionDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
import com.gempukku.lotro.logic.timing.AbstractEffect;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ChooseAndDiscardStackedCardsEffect extends AbstractEffect {
|
||||
private Action _action;
|
||||
private String _playerId;
|
||||
private int _minimum;
|
||||
private int _maximum;
|
||||
private Filter _stackedOnFilter;
|
||||
private Filter _stackedCardFilter;
|
||||
|
||||
public ChooseAndDiscardStackedCardsEffect(Action action, String playerId, int minimum, int maximum, Filter stackedOnFilter, Filter stackedCardFilter) {
|
||||
_action = action;
|
||||
_playerId = playerId;
|
||||
_minimum = minimum;
|
||||
_maximum = maximum;
|
||||
_stackedOnFilter = stackedOnFilter;
|
||||
_stackedCardFilter = stackedCardFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult.Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return "Discard stacked card";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayableInFull(LotroGame game) {
|
||||
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), _stackedOnFilter, Filters.hasStacked(_stackedCardFilter)) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullEffectResult playEffectReturningResult(final LotroGame game) {
|
||||
List<PhysicalCard> discardableCards = new LinkedList<PhysicalCard>();
|
||||
|
||||
for (PhysicalCard stackedOnCard : Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), _stackedOnFilter))
|
||||
discardableCards.addAll(Filters.filter(game.getGameState().getStackedCards(stackedOnCard), game.getGameState(), game.getModifiersQuerying(), _stackedCardFilter));
|
||||
|
||||
final boolean success = discardableCards.size() >= _minimum;
|
||||
|
||||
if (discardableCards.size() <= _minimum) {
|
||||
SubAction subAction = new SubAction(_action.getActionSource(), _action.getType());
|
||||
subAction.appendEffect(new DiscardStackedCardsEffect(_action.getActionSource(), discardableCards));
|
||||
game.getActionsEnvironment().addActionToStack(subAction);
|
||||
} else {
|
||||
game.getUserFeedback().sendAwaitingDecision(_playerId,
|
||||
new CardsSelectionDecision(1, "Choose card(s) to discard", discardableCards, _minimum, _maximum) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
Set<PhysicalCard> discardableCards = getSelectedCardsByResponse(result);
|
||||
SubAction subAction = new SubAction(_action.getActionSource(), _action.getType());
|
||||
subAction.appendEffect(new DiscardStackedCardsEffect(_action.getActionSource(), discardableCards));
|
||||
game.getActionsEnvironment().addActionToStack(subAction);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return new FullEffectResult(null, success, success);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.gempukku.lotro.cards.effects;
|
||||
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
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.timing.AbstractEffect;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class DiscardStackedCardsEffect extends AbstractEffect {
|
||||
private PhysicalCard _source;
|
||||
private Collection<PhysicalCard> _cards;
|
||||
|
||||
public DiscardStackedCardsEffect(PhysicalCard source, Collection<PhysicalCard> cards) {
|
||||
_source = source;
|
||||
_cards = cards;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return "Discard stacked - " + getAppendedTextNames(_cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult.Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayableInFull(LotroGame game) {
|
||||
for (PhysicalCard card : _cards) {
|
||||
if (card.getZone() != Zone.STACKED)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullEffectResult playEffectReturningResult(LotroGame game) {
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.sendMessage(getAppendedNames(_cards) + " is/are discarded from being stacked");
|
||||
for (PhysicalCard card : _cards) {
|
||||
gameState.removeCardFromZone(card);
|
||||
gameState.addCardToZone(card, Zone.DISCARD);
|
||||
}
|
||||
|
||||
return new FullEffectResult(null, true, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.gempukku.lotro.cards.set4.dwarven;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.AddUntilEndOfPhaseModifierEffect;
|
||||
import com.gempukku.lotro.cards.effects.ChoiceEffect;
|
||||
import com.gempukku.lotro.cards.effects.ChooseAndDiscardCardsFromPlayEffect;
|
||||
import com.gempukku.lotro.cards.effects.ChooseAndDiscardStackedCardsEffect;
|
||||
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
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.ActivateCardAction;
|
||||
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 java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: The Two Towers
|
||||
* Side: Free
|
||||
* Culture: Dwarven
|
||||
* Twilight Cost: 2
|
||||
* Type: Possession • Hand Weapon
|
||||
* Strength: +2
|
||||
* Game Text: Bearer must be Gimli. He is damage +1. Skirmish: Discard a [DWARVEN] condition or a card stacked on
|
||||
* a [DWARVEN] condition to make Gimli strength +1.
|
||||
*/
|
||||
public class Card4_041 extends AbstractAttachableFPPossession {
|
||||
public Card4_041() {
|
||||
super(2, 2, 0, Culture.DWARVEN, Keyword.HAND_WEAPON, "Axe of Erebor", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
|
||||
return Filters.name("Gimli");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Modifier> getNonBasicStatsModifiers(PhysicalCard self) {
|
||||
return Collections.singletonList(
|
||||
new KeywordModifier(self, Filters.hasAttached(self), Keyword.DAMAGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Action> getExtraInPlayPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
|
||||
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self)
|
||||
&& Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.type(CardType.CONDITION), Filters.culture(Culture.DWARVEN)) > 0) {
|
||||
ActivateCardAction action = new ActivateCardAction(self, Keyword.SKIRMISH);
|
||||
|
||||
List<Effect> possibleCosts = new LinkedList<Effect>();
|
||||
possibleCosts.add(
|
||||
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Filters.type(CardType.CONDITION), Filters.culture(Culture.DWARVEN)));
|
||||
possibleCosts.add(
|
||||
new ChooseAndDiscardStackedCardsEffect(action, playerId, 1, 1, Filters.and(Filters.type(CardType.CONDITION), Filters.culture(Culture.DWARVEN)), Filters.any()));
|
||||
|
||||
action.appendCost(
|
||||
new ChoiceEffect(action, playerId, possibleCosts));
|
||||
|
||||
action.appendEffect(
|
||||
new AddUntilEndOfPhaseModifierEffect(
|
||||
new StrengthModifier(self, Filters.name("Gimli"), 1), Phase.SKIRMISH));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user