"Belt of Erebor"
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.gempukku.lotro.cards.effects.choose;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAttachable;
|
||||
import com.gempukku.lotro.cards.effects.TransferPermanentEffect;
|
||||
import com.gempukku.lotro.common.Filterable;
|
||||
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.SubAction;
|
||||
import com.gempukku.lotro.logic.decisions.CardsSelectionDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
import com.gempukku.lotro.logic.timing.AbstractEffect;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
public class ChooseAndTransferAttachableEffect extends AbstractEffect {
|
||||
private Action _action;
|
||||
private String _playerId;
|
||||
private Filterable _attachedTo;
|
||||
private Filterable _attachedCard;
|
||||
private Filterable _transferTo;
|
||||
|
||||
public ChooseAndTransferAttachableEffect(Action action, String playerId, Filterable attachedCard, Filterable attachedTo, Filterable transferTo) {
|
||||
_action = action;
|
||||
_playerId = playerId;
|
||||
_attachedCard = attachedCard;
|
||||
_attachedTo = attachedTo;
|
||||
_transferTo = transferTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Filterable getValidTargetFilter(LotroGame game, final PhysicalCard attachment, AbstractAttachable attachable) {
|
||||
return Filters.and(
|
||||
_transferTo,
|
||||
attachable.getFullValidTargetFilter(attachment.getOwner(), game, attachment),
|
||||
Filters.not(attachment.getAttachedTo()),
|
||||
new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard target) {
|
||||
return modifiersQuerying.canHaveTransferredOn(gameState, attachment, target);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected Collection<PhysicalCard> getPossibleAttachmentsToTransfer(final LotroGame game) {
|
||||
return Filters.filterActive(game.getGameState(), game.getModifiersQuerying(),
|
||||
_attachedCard,
|
||||
Filters.attachedTo(_attachedTo),
|
||||
new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, final PhysicalCard transferredCard) {
|
||||
if (!(transferredCard.getBlueprint() instanceof AbstractAttachable))
|
||||
return false;
|
||||
|
||||
AbstractAttachable attachable = (AbstractAttachable) transferredCard.getBlueprint();
|
||||
return Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), getValidTargetFilter(game, transferredCard, attachable));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayableInFull(LotroGame game) {
|
||||
return getPossibleAttachmentsToTransfer(game).size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullEffectResult playEffectReturningResult(final LotroGame game) {
|
||||
final Collection<PhysicalCard> possibleAttachmentsToTransfer = getPossibleAttachmentsToTransfer(game);
|
||||
if (possibleAttachmentsToTransfer.size() > 0) {
|
||||
game.getUserFeedback().sendAwaitingDecision(_playerId,
|
||||
new CardsSelectionDecision(1, "Choose card to transfer", possibleAttachmentsToTransfer, 1, 1) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
final Set<PhysicalCard> selectedAttachments = getSelectedCardsByResponse(result);
|
||||
if (selectedAttachments.size() == 1) {
|
||||
final PhysicalCard attachment = selectedAttachments.iterator().next();
|
||||
AbstractAttachable attachable = (AbstractAttachable) attachment.getBlueprint();
|
||||
final Collection<PhysicalCard> validTargets = Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), getValidTargetFilter(game, attachment, attachable));
|
||||
game.getUserFeedback().sendAwaitingDecision(
|
||||
_playerId,
|
||||
new CardsSelectionDecision(1, "Choose transfer target", validTargets, 1, 1) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
final Set<PhysicalCard> selectedTargets = getSelectedCardsByResponse(result);
|
||||
if (selectedTargets.size() == 1) {
|
||||
PhysicalCard selectedTarget = selectedTargets.iterator().next();
|
||||
SubAction subAction = new SubAction(_action);
|
||||
subAction.appendEffect(
|
||||
new TransferPermanentEffect(attachment, selectedTarget));
|
||||
game.getActionsEnvironment().addActionToStack(subAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return new FullEffectResult(false, false);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,17 @@
|
||||
package com.gempukku.lotro.cards.set11.men;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAttachable;
|
||||
import com.gempukku.lotro.cards.AbstractMinion;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.SelfExertEffect;
|
||||
import com.gempukku.lotro.cards.effects.TransferPermanentEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseAndTransferAttachableEffect;
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.common.Race;
|
||||
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.effects.ChooseActiveCardEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -47,30 +42,7 @@ public class Card11_100 extends AbstractMinion {
|
||||
action.appendCost(
|
||||
new SelfExertEffect(self));
|
||||
action.appendEffect(
|
||||
new ChooseActiveCardEffect(self, playerId, "Choose a possession or condition", Filters.or(CardType.POSSESSION, CardType.CONDITION), Filters.attachedTo(Filters.character),
|
||||
new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
if (!(physicalCard.getBlueprint() instanceof AbstractAttachable))
|
||||
return false;
|
||||
|
||||
AbstractAttachable attachable = (AbstractAttachable) physicalCard.getBlueprint();
|
||||
return Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), attachable.getFullValidTargetFilter(physicalCard.getOwner(), game, physicalCard), Filters.not(physicalCard.getAttachedTo()));
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected void cardSelected(LotroGame game, final PhysicalCard attachment) {
|
||||
AbstractAttachable attachable = (AbstractAttachable) attachment.getBlueprint();
|
||||
action.insertEffect(
|
||||
new ChooseActiveCardEffect(self, playerId, "Choose new eligible bearer", attachable.getFullValidTargetFilter(attachment.getOwner(), game, attachment), Filters.not(attachment.getAttachedTo())) {
|
||||
@Override
|
||||
protected void cardSelected(LotroGame game, PhysicalCard newBearer) {
|
||||
action.insertEffect(
|
||||
new TransferPermanentEffect(attachment, newBearer));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
new ChooseAndTransferAttachableEffect(action, playerId, Filters.or(CardType.POSSESSION, CardType.CONDITION), Filters.character, Filters.any));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
package com.gempukku.lotro.cards.set11.men;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAttachable;
|
||||
import com.gempukku.lotro.cards.AbstractMinion;
|
||||
import com.gempukku.lotro.cards.TriggerConditions;
|
||||
import com.gempukku.lotro.cards.effects.RemoveTwilightEffect;
|
||||
import com.gempukku.lotro.cards.effects.TransferPermanentEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseAndTransferAttachableEffect;
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.common.Race;
|
||||
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.OptionalTriggerAction;
|
||||
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -47,30 +42,7 @@ public class Card11_101 extends AbstractMinion {
|
||||
action.appendCost(
|
||||
new RemoveTwilightEffect(2));
|
||||
action.appendEffect(
|
||||
new ChooseActiveCardEffect(self, playerId, "Choose a condition", CardType.CONDITION, Filters.attachedTo(Filters.character),
|
||||
new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
if (!(physicalCard.getBlueprint() instanceof AbstractAttachable))
|
||||
return false;
|
||||
|
||||
AbstractAttachable attachable = (AbstractAttachable) physicalCard.getBlueprint();
|
||||
return Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), attachable.getFullValidTargetFilter(physicalCard.getOwner(), game, physicalCard), Filters.not(physicalCard.getAttachedTo()));
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected void cardSelected(LotroGame game, final PhysicalCard attachment) {
|
||||
AbstractAttachable attachable = (AbstractAttachable) attachment.getBlueprint();
|
||||
action.insertEffect(
|
||||
new ChooseActiveCardEffect(self, playerId, "Choose new eligible bearer", attachable.getFullValidTargetFilter(attachment.getOwner(), game, attachment), Filters.not(attachment.getAttachedTo())) {
|
||||
@Override
|
||||
protected void cardSelected(LotroGame game, PhysicalCard newBearer) {
|
||||
action.insertEffect(
|
||||
new TransferPermanentEffect(attachment, newBearer));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
new ChooseAndTransferAttachableEffect(action, playerId, CardType.CONDITION, Filters.character, Filters.any));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gempukku.lotro.cards.set12.dwarven;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.SelfDiscardEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseAndTransferAttachableEffect;
|
||||
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.modifiers.Modifier;
|
||||
import com.gempukku.lotro.logic.modifiers.RemoveKeywordModifier;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: Black Rider
|
||||
* Side: Free
|
||||
* Culture: Dwarven
|
||||
* Twilight Cost: 0
|
||||
* Type: Possession • Armor
|
||||
* Game Text: Bearer must be a Dwarf. Each minion skirmishing bearer loses all damage bonus. Skirmish: Discard this
|
||||
* possession to transfer one of bearer's possessions to another eligible bearer.
|
||||
*/
|
||||
public class Card12_002 extends AbstractAttachableFPPossession {
|
||||
public Card12_002() {
|
||||
super(0, 0, 0, Culture.DWARVEN, PossessionClass.ARMOR, "Belt of Erebor");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
|
||||
return Race.DWARF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Modifier> getNonBasicStatsModifiers(PhysicalCard self) {
|
||||
return Collections.singletonList(
|
||||
new RemoveKeywordModifier(self, Filters.inSkirmishAgainst(Filters.hasAttached(self)), Keyword.DAMAGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Action> getExtraInPlayPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
|
||||
if (PlayConditions.canUseFPCardDuringPhase(game, Phase.SKIRMISH, self)
|
||||
&& PlayConditions.canSelfDiscard(self, game)) {
|
||||
ActivateCardAction action = new ActivateCardAction(self);
|
||||
action.appendCost(
|
||||
new SelfDiscardEffect(self));
|
||||
action.appendEffect(
|
||||
new ChooseAndTransferAttachableEffect(action, playerId, CardType.POSSESSION, self.getAttachedTo(), Filters.any));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user