"Still Twitching"
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.gempukku.lotro.cards.set19.dwarven;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAttachable;
|
||||
import com.gempukku.lotro.cards.TriggerConditions;
|
||||
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.OptionalTriggerAction;
|
||||
import com.gempukku.lotro.logic.actions.RequiredTriggerAction;
|
||||
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
|
||||
import com.gempukku.lotro.logic.modifiers.Modifier;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: Ages End
|
||||
* Side: Free
|
||||
* Culture: Dwarven
|
||||
* Twilight Cost: 1
|
||||
* Type: Condition
|
||||
* Game Text: Bearer must be a [DWARVEN] companion. Bearer gains Hunter 2. Each time bearer wins a skirmish, you may
|
||||
* transfer this condition to another [DWARVEN] companion. At the end of each turn, if bearer did not win a skirmish
|
||||
* this turn, discard this condition from play.
|
||||
*/
|
||||
public class Card19_003 extends AbstractAttachable {
|
||||
public Card19_003() {
|
||||
super(Side.FREE_PEOPLE, CardType.CONDITION, 1, Culture.DWARVEN, null, "Still Twitching");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
|
||||
return Filters.and(Culture.DWARVEN, CardType.COMPANION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Modifier getAlwaysOnModifier(PhysicalCard self) {
|
||||
return new KeywordModifier(self, Filters.hasAttached(self), Keyword.HUNTER, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
|
||||
if (TriggerConditions.winsSkirmish(game, effectResult, self.getAttachedTo())) {
|
||||
OptionalTriggerAction action = new OptionalTriggerAction(self);
|
||||
action.appendEffect(
|
||||
new ChooseAndTransferAttachableEffect(action, playerId, self, null, Filters.and(Culture.DWARVEN, CardType.COMPANION)));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
|
||||
if (effectResult.getType() == EffectResult.Type.END_OF_TURN
|
||||
&& !game.getActionsEnvironment().hasWonSkirmishThisTurn(self.getAttachedTo())) {
|
||||
RequiredTriggerAction action = new RequiredTriggerAction(self);
|
||||
action.appendEffect(
|
||||
new SelfDiscardEffect(self));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,6 @@ public interface ActionsEnvironment {
|
||||
public <T extends Action> T findTopmostActionOfType(Class<T> clazz);
|
||||
|
||||
public List<PhysicalCard> getPlayedCardsInCurrentPhase();
|
||||
|
||||
public boolean hasWonSkirmishThisTurn(PhysicalCard card);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gempukku.lotro.logic.timing.ActionStack;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsFromDiscardVisitor;
|
||||
import com.gempukku.lotro.logic.timing.results.CharacterWonSkirmishResult;
|
||||
import com.gempukku.lotro.logic.timing.results.PlayCardResult;
|
||||
import com.gempukku.lotro.logic.timing.rules.CharacterDeathRule;
|
||||
|
||||
@@ -29,6 +30,8 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
|
||||
|
||||
private Set<EffectResult> _effectResults = new HashSet<EffectResult>();
|
||||
|
||||
private Set<Integer> _wonSkirmishesInTurn = new HashSet<Integer>();
|
||||
|
||||
public DefaultActionsEnvironment(LotroGame lotroGame, ActionStack actionStack) {
|
||||
_lotroGame = lotroGame;
|
||||
_actionStack = actionStack;
|
||||
@@ -44,6 +47,17 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
addAlwaysOnActionProxy(
|
||||
new AbstractActionProxy() {
|
||||
@Override
|
||||
public List<? extends RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult) {
|
||||
if (effectResult.getType() == EffectResult.Type.CHARACTER_WON_SKIRMISH) {
|
||||
final CharacterWonSkirmishResult winResult = (CharacterWonSkirmishResult) effectResult;
|
||||
_wonSkirmishesInTurn.add(winResult.getWinner().getCardId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,6 +99,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
|
||||
public void removeEndOfTurnActionProxies() {
|
||||
_actionProxies.removeAll(_untilEndOfTurnActionProxies);
|
||||
_untilEndOfTurnActionProxies.clear();
|
||||
_wonSkirmishesInTurn.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,6 +308,11 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
|
||||
return Collections.unmodifiableList(_playedCardsInPhase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWonSkirmishThisTurn(PhysicalCard card) {
|
||||
return _wonSkirmishesInTurn.contains(card.getCardId());
|
||||
}
|
||||
|
||||
private class GatherRequiredAfterTriggers extends CompletePhysicalCardVisitor {
|
||||
private Collection<? extends EffectResult> _effectResults;
|
||||
private List<Action> _actions = new LinkedList<Action>();
|
||||
|
||||
Reference in New Issue
Block a user