"Theoden"

This commit is contained in:
marcins78@gmail.com
2011-10-16 22:19:31 +00:00
parent 92c2720a59
commit b503b566ae
2 changed files with 109 additions and 0 deletions

View File

@@ -37,6 +37,8 @@ public class AttachPermanentAction extends AbstractCostToEffectAction {
private boolean _exertTarget;
private PhysicalCard _target;
public AttachPermanentAction(final LotroGame game, final PhysicalCard card, Filter filter, final Map<Filter, Integer> attachCostModifiers, final int twilightModifier) {
_cardToAttach = card;
@@ -44,6 +46,7 @@ public class AttachPermanentAction extends AbstractCostToEffectAction {
new ChooseActiveCardEffect(null, card.getOwner(), "Attach " + card.getBlueprint().getName() + ". Choose target to attach to", filter) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard target) {
_target = target;
if (_exertTarget) {
appendCost(
new ExertCharactersEffect(target, target));
@@ -69,6 +72,10 @@ public class AttachPermanentAction extends AbstractCostToEffectAction {
};
}
public PhysicalCard getTarget() {
return _target;
}
public void setExertTarget(boolean exertTarget) {
_exertTarget = exertTarget;
}

View File

@@ -0,0 +1,102 @@
package com.gempukku.lotro.cards.set4.rohan;
import com.gempukku.lotro.cards.AbstractAttachable;
import com.gempukku.lotro.cards.AbstractCompanion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.AttachPermanentAction;
import com.gempukku.lotro.cards.effects.CheckLimitEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.common.*;
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.ActivateCardAction;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.effects.HealCharactersEffect;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Set: The Two Towers
* Side: Free
* Culture: Rohan
* Twilight Cost: 2
* Type: Companion • Man
* Strength: 6
* Vitality: 2
* Resistance: 6
* Signet: Theoden
* Game Text: Fellowship: Play a [ROHAN] possession on a [ROHAN] companion to heal that companion (limit once per turn).
*/
public class Card4_365 extends AbstractCompanion {
public Card4_365() {
super(2, 6, 2, Culture.ROHAN, Race.MAN, Signet.THÉODEN, "Theoden", true);
}
@Override
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, final LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.FELLOWSHIP, self)) {
final Filter additionalAttachmentFilter = Filters.and(Culture.ROHAN, CardType.COMPANION);
if (Filters.filter(game.getGameState().getDiscard(playerId), game.getGameState(), game.getModifiersQuerying(), CardType.POSSESSION,
new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
AbstractAttachable possession = (AbstractAttachable) physicalCard.getBlueprint();
return possession.checkPlayRequirements(playerId, game, physicalCard, additionalAttachmentFilter, 0);
}
}, Filters.playable(game)).size() > 0) {
final ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new CheckLimitEffect(action, self, 1, Phase.FELLOWSHIP,
new ChooseArbitraryCardsEffect(playerId, "Choose card to play", game.getGameState().getDiscard(playerId),
Filters.and(
CardType.POSSESSION,
new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
AbstractAttachable possession = (AbstractAttachable) physicalCard.getBlueprint();
return possession.checkPlayRequirements(playerId, game, physicalCard, additionalAttachmentFilter, 0);
}
})
, 1, 1) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
if (selectedCards.size() > 0) {
PhysicalCard selectedCard = selectedCards.iterator().next();
AttachPermanentAction attachPermanentAction = ((AbstractAttachable) selectedCard.getBlueprint()).getPlayCardAction(playerId, game, selectedCard, additionalAttachmentFilter, 0);
game.getActionsEnvironment().addActionToStack(attachPermanentAction);
action.appendEffect(
new AppendHealTargetEffect(action, attachPermanentAction));
}
}
}));
return Collections.singletonList(action);
}
}
return null;
}
private static class AppendHealTargetEffect extends UnrespondableEffect {
private CostToEffectAction _action;
private AttachPermanentAction _attachPermanentAction;
private AppendHealTargetEffect(CostToEffectAction action, AttachPermanentAction attachPermanentAction) {
_action = action;
_attachPermanentAction = attachPermanentAction;
}
@Override
protected void doPlayEffect(LotroGame game) {
_action.appendEffect(
new HealCharactersEffect(_action.getActionSource().getOwner(), _attachPermanentAction.getTarget()));
}
}
}