diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractFollower.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractFollower.java new file mode 100644 index 000000000..522a85032 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractFollower.java @@ -0,0 +1,57 @@ +package com.gempukku.lotro.cards; + +import com.gempukku.lotro.cards.effects.TransferPermanentEffect; +import com.gempukku.lotro.common.*; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.actions.OptionalTriggerAction; +import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect; +import com.gempukku.lotro.logic.timing.Effect; +import com.gempukku.lotro.logic.timing.EffectResult; + +import java.util.Collections; +import java.util.List; + +public abstract class AbstractFollower extends AbstractPermanent { + public AbstractFollower(Side side, int twilightCost, Culture culture, String name) { + this(side, twilightCost, culture, name, false); + } + + public AbstractFollower(Side side, int twilightCost, Culture culture, String name, boolean unique) { + super(side, twilightCost, CardType.FOLLOWER, culture, Zone.SUPPORT, name, unique); + } + + protected abstract boolean canPayAidCost(LotroGame game, PhysicalCard self); + + protected abstract Effect getAidCost(LotroGame game, PhysicalCard self); + + protected Filterable getFollowerTarget(LotroGame game, PhysicalCard self) { + return CardType.COMPANION; + } + + @Override + public final List getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, final PhysicalCard self) { + if (TriggerConditions.startOfPhase(game, effectResult, Phase.MANEUVER) + && self.getZone() == Zone.SUPPORT + && canPayAidCost(game, self) + && PlayConditions.canSpot(game, getFollowerTarget(game, self))) { + final OptionalTriggerAction action = new OptionalTriggerAction(self); + action.appendCost( + getAidCost(game, self)); + action.appendCost( + new ChooseActiveCardEffect(self, playerId, "Choose character to transfer follower to", getFollowerTarget(game, self)) { + @Override + protected void cardSelected(LotroGame game, PhysicalCard card) { + action.appendEffect( + new TransferPermanentEffect(self, card)); + } + }); + return Collections.singletonList(action); + } + return getExtraOptionalAfterTriggers(playerId, game, effectResult, self); + } + + protected List getExtraOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, final PhysicalCard self) { + return null; + } +} diff --git a/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/CardType.java b/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/CardType.java index ec4301126..9d825131f 100644 --- a/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/CardType.java +++ b/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/CardType.java @@ -1,5 +1,5 @@ package com.gempukku.lotro.common; public enum CardType implements Filterable { - THE_ONE_RING, SITE, COMPANION, ALLY, MINION, POSSESSION, ARTIFACT, EVENT, CONDITION + THE_ONE_RING, SITE, COMPANION, ALLY, MINION, POSSESSION, ARTIFACT, EVENT, CONDITION, FOLLOWER }