"Here Is Good Rock"

This commit is contained in:
marcins78@gmail.com
2011-10-06 17:59:08 +00:00
parent 3b74fc2238
commit 61007f33f4
3 changed files with 95 additions and 10 deletions

View File

@@ -65,9 +65,9 @@ public class ChooseAndDiscardStackedCardsEffect extends AbstractEffect {
new CardsSelectionDecision(1, "Choose card(s) to discard", discardableCards, _minimum, _maximum) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
Set<PhysicalCard> discardableCards = getSelectedCardsByResponse(result);
Set<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
SubAction subAction = new SubAction(_action.getActionSource(), _action.getType());
subAction.appendEffect(new DiscardStackedCardsEffect(_action.getActionSource(), discardableCards));
subAction.appendEffect(new DiscardStackedCardsEffect(_action.getActionSource(), selectedCards));
game.getActionsEnvironment().addActionToStack(subAction);
}
});

View File

@@ -0,0 +1,76 @@
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.Collection;
import java.util.Set;
public class ChooseAndStackCardsFromHandEffect extends AbstractEffect {
private Action _action;
private String _playerId;
private int _minimum;
private int _maximum;
private PhysicalCard _stackOn;
private Filter _filter;
public ChooseAndStackCardsFromHandEffect(Action action, String playerId, int minimum, int maximum, PhysicalCard stackOn, Filter filter) {
_action = action;
_playerId = playerId;
_minimum = minimum;
_maximum = maximum;
_stackOn = stackOn;
_filter = filter;
}
@Override
public EffectResult.Type getType() {
return null;
}
@Override
public String getText(LotroGame game) {
return "Stack card(s) from hand";
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return Filters.filter(game.getGameState().getHand(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter).size() >= _minimum;
}
@Override
protected FullEffectResult playEffectReturningResult(final LotroGame game) {
Collection<PhysicalCard> hand = Filters.filter(game.getGameState().getHand(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter);
final boolean success = hand.size() >= _minimum;
if (hand.size() <= _minimum) {
SubAction subAction = new SubAction(_action.getActionSource(), _action.getType());
for (PhysicalCard card : hand)
subAction.appendEffect(new StackCardFromHandEffect(_action.getActionSource(), card));
game.getActionsEnvironment().addActionToStack(subAction);
} else {
game.getUserFeedback().sendAwaitingDecision(_playerId,
new CardsSelectionDecision(1, "Choose card(s) to stack", hand, _minimum, _maximum) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
Set<PhysicalCard> cards = getSelectedCardsByResponse(result);
SubAction subAction = new SubAction(_action.getActionSource(), _action.getType());
for (PhysicalCard card : cards)
subAction.appendEffect(new StackCardFromHandEffect(_action.getActionSource(), card));
game.getActionsEnvironment().addActionToStack(subAction);
}
});
}
return new FullEffectResult(null, success, success);
}
}

View File

@@ -2,15 +2,18 @@ package com.gempukku.lotro.cards.set4.dwarven;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseCardsFromHandEffect;
import com.gempukku.lotro.cards.effects.AddUntilEndOfPhaseModifierEffect;
import com.gempukku.lotro.cards.effects.ChooseAndStackCardsFromHandEffect;
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.ActivateCardAction;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
@@ -29,17 +32,23 @@ public class Card4_050 extends AbstractPermanent {
}
@Override
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self)
&& Filters.filter(game.getGameState().getHand(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.side(Side.FREE_PEOPLE)).size() > 0) {
ActivateCardAction action = new ActivateCardAction(self, Keyword.SKIRMISH);
final ActivateCardAction action = new ActivateCardAction(self, Keyword.SKIRMISH);
action.appendCost(
new ChooseCardsFromHandEffect() {
new ChooseAndStackCardsFromHandEffect(action, playerId, 1, 1, self, Filters.side(Side.FREE_PEOPLE)));
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose a Dwarf", Filters.race(Race.DWARF)) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
protected void cardSelected(PhysicalCard card) {
action.insertEffect(
new AddUntilEndOfPhaseModifierEffect(
new KeywordModifier(self, Filters.sameCard(card), Keyword.DAMAGE), Phase.SKIRMISH));
}
}
);
});
return Collections.singletonList(action);
}
return null;
}
}