"Armory"
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.gempukku.lotro.cards.effects.choose;
|
||||
|
||||
import com.gempukku.lotro.cards.effects.PutCardFromDiscardIntoHandEffect;
|
||||
import com.gempukku.lotro.common.Filterable;
|
||||
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.timing.Action;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class ChooseAndPutCardFromDiscardIntoHandEffect extends ChooseCardsFromDiscardEffect {
|
||||
private Action _action;
|
||||
|
||||
public ChooseAndPutCardFromDiscardIntoHandEffect(Action action, String playerId, int minimum, int maximum, Filterable... filters) {
|
||||
super(playerId, minimum, maximum, filters);
|
||||
_action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
|
||||
if (cards.size() > 0) {
|
||||
SubAction subAction = new SubAction(_action);
|
||||
for (PhysicalCard card : cards)
|
||||
subAction.appendEffect(new PutCardFromDiscardIntoHandEffect(card));
|
||||
game.getActionsEnvironment().addActionToStack(subAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,22 @@ public class ChooseAndRemoveTokensFromCardEffect extends ChooseActiveCardEffect
|
||||
|
||||
@Override
|
||||
protected Filter getExtraFilter() {
|
||||
return Filters.hasToken(_token, _count);
|
||||
if (_token != null)
|
||||
return Filters.hasToken(_token, _count);
|
||||
else
|
||||
return Filters.hasAnyTokens(_count);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cardSelected(LotroGame game, PhysicalCard card) {
|
||||
game.getGameState().removeTokens(card, _token, _count);
|
||||
if (_token != null)
|
||||
game.getGameState().removeTokens(card, _token, _count);
|
||||
else
|
||||
for (Token token : Token.values()) {
|
||||
if (game.getGameState().getTokenCount(card, token) > 0) {
|
||||
game.getGameState().removeTokens(card, token, _count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gempukku.lotro.cards.effects.choose;
|
||||
|
||||
import com.gempukku.lotro.common.Filterable;
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
@@ -18,7 +19,7 @@ public abstract class ChooseCardsFromDiscardEffect extends AbstractEffect {
|
||||
private int _maximum;
|
||||
private Filter _filter;
|
||||
|
||||
public ChooseCardsFromDiscardEffect(String playerId, int minimum, int maximum, Filter... filters) {
|
||||
public ChooseCardsFromDiscardEffect(String playerId, int minimum, int maximum, Filterable... filters) {
|
||||
_playerId = playerId;
|
||||
_minimum = minimum;
|
||||
_maximum = maximum;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gempukku.lotro.cards.set5.rohan;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractPermanent;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.ChoiceEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseAndPutCardFromDiscardIntoHandEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveTokensFromCardEffect;
|
||||
import com.gempukku.lotro.common.*;
|
||||
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.DiscardCardsFromPlayEffect;
|
||||
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: Battle of Helm's Deep
|
||||
* Side: Free
|
||||
* Culture: Rohan
|
||||
* Twilight Cost: 1
|
||||
* Type: Condition
|
||||
* Game Text: Fortification. Plays to your support area. Maneuver: Spot 2 [ROHAN] Men to remove 2 tokens from a machine
|
||||
* or to take a [ROHAN] possession into hand from your discard pile. Discard this condition.
|
||||
*/
|
||||
public class Card5_079 extends AbstractPermanent {
|
||||
public Card5_079() {
|
||||
super(Side.FREE_PEOPLE, 1, CardType.CONDITION, Culture.ROHAN, Zone.SUPPORT, "Armory", true);
|
||||
addKeyword(Keyword.FORTIFICATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
|
||||
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.MANEUVER, self)
|
||||
&& PlayConditions.canSpot(game, 2, Culture.ROHAN, Race.MAN)) {
|
||||
ActivateCardAction action = new ActivateCardAction(self);
|
||||
List<Effect> possibleEffects = new LinkedList<Effect>();
|
||||
possibleEffects.add(
|
||||
new ChooseAndRemoveTokensFromCardEffect(self, playerId, null, 2, Keyword.MACHINE) {
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return "Remove 2 tokens from a machine";
|
||||
}
|
||||
});
|
||||
possibleEffects.add(
|
||||
new ChooseAndPutCardFromDiscardIntoHandEffect(action, playerId, 1, 1, Culture.ROHAN, CardType.POSSESSION));
|
||||
action.appendEffect(
|
||||
new ChoiceEffect(action, playerId, possibleEffects));
|
||||
action.appendEffect(
|
||||
new DiscardCardsFromPlayEffect(self, self));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,19 @@ public class Filters {
|
||||
};
|
||||
}
|
||||
|
||||
public static Filter hasAnyTokens(final int count) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
for (Token token : Token.values()) {
|
||||
if (gameState.getTokenCount(physicalCard, token) >= count)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Filter hasToken(final Token token) {
|
||||
return hasToken(token, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user