"Mordor Assassin" - stupid card introducing an extra place in time, when effects can be played.

This commit is contained in:
marcins78@gmail.com
2011-11-09 01:39:21 +00:00
parent e478dc1174
commit 8337fc2219
13 changed files with 177 additions and 13 deletions

View File

@@ -47,7 +47,7 @@ public class Card7_152 extends AbstractMinion {
SkirmishResult skirmishResult = (SkirmishResult) effectResult;
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(
new KillEffect(skirmishResult.getLosers()));
new KillEffect(skirmishResult.getLosers(), KillEffect.Cause.CARD_EFFECT));
return Collections.singletonList(action);
}
return null;

View File

@@ -0,0 +1,62 @@
package com.gempukku.lotro.cards.set7.sauron;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Race;
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.effects.AssignmentEffect;
import com.gempukku.lotro.logic.effects.KillEffect;
import com.gempukku.lotro.logic.effects.RemoveThreatsEffect;
import com.gempukku.lotro.logic.effects.ThreatWoundsEffect;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.results.KillResult;
import java.util.Collections;
import java.util.List;
/**
* Set: The Return of the King
* Side: Shadow
* Culture: Sauron
* Twilight Cost: 3
* Type: Minion • Orc
* Strength: 9
* Vitality: 3
* Site: 6
* Game Text: Response: If a companion is overwhelmed during a skirmish involving a [SAURON] Orc and threat wounds are
* about to be placed, remove a threat to assign this minion to the Ring-bearer (even if the Ring-bearer is already
* assigned).
*/
public class Card7_284 extends AbstractMinion {
public Card7_284() {
super(3, 9, 3, 6, Race.ORC, Culture.SAURON, "Mordor Assassin");
}
@Override
public List<? extends ActivateCardAction> getOptionalInPlayBeforeActions(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
if (effect.getType() == Effect.Type.BEFORE_THREAT_WOUNDS
&& PlayConditions.canRemoveThreat(game, self, 1)) {
ThreatWoundsEffect threatWoundsEffect = (ThreatWoundsEffect) effect;
KillResult killResult = threatWoundsEffect.getKillResult();
if (killResult.getCause() == KillEffect.Cause.OVERWHELM
&& Filters.filter(killResult.getKilledCards(), game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION).size() > 0
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.inSkirmish, Culture.SAURON, Race.ORC)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new RemoveThreatsEffect(self, 1));
PhysicalCard ringBearer = Filters.findFirstActive(game.getGameState(), game.getModifiersQuerying(), Keyword.RING_BEARER);
AssignmentEffect assignmentEffect = new AssignmentEffect(playerId, ringBearer, self);
assignmentEffect.setIgnoreSingleMinionRestriction(true);
action.appendEffect(assignmentEffect);
return Collections.singletonList(action);
}
}
return null;
}
}

View File

@@ -44,7 +44,7 @@ public class Filters {
return result;
}
public static PhysicalCard findFirstActive(GameState gameState, ModifiersQuerying modifiersQuerying, Filter... filters) {
public static PhysicalCard findFirstActive(GameState gameState, ModifiersQuerying modifiersQuerying, Filterable... filters) {
SpotFilterCardInPlayVisitor visitor = new SpotFilterCardInPlayVisitor(gameState, modifiersQuerying, Filters.and(filters));
gameState.iterateActiveCards(visitor);
return visitor.getCard();
@@ -132,6 +132,25 @@ public class Filters {
});
}
public static Filter canBeAssignedToSkirmishByEffectIgnoreNotAssigned(final Side sidePlayer) {
return Filters.and(
Filters.or(
Filters.not(CardType.MINION),
Filters.or(
new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return !gameState.isFierceSkirmishes();
}
}, Keyword.FIERCE)),
new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canBeAssignedToSkirmish(gameState, sidePlayer, physicalCard);
}
});
}
public static Filter canBeAssignedToSkirmish(final Side sidePlayer) {
return new Filter() {
@Override

View File

@@ -15,6 +15,7 @@ import java.util.Map;
public class AssignmentEffect extends AbstractEffect {
private String _playerId;
private boolean _ignoreSingleMinionRestriction;
private PhysicalCard _fpChar;
private PhysicalCard _minion;
@@ -24,6 +25,10 @@ public class AssignmentEffect extends AbstractEffect {
_minion = minion;
}
public void setIgnoreSingleMinionRestriction(boolean ignoreSingleMinionRestriction) {
_ignoreSingleMinionRestriction = ignoreSingleMinionRestriction;
}
@Override
public Effect.Type getType() {
return null;
@@ -37,7 +42,9 @@ public class AssignmentEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
Side side = _playerId.equals(game.getGameState().getCurrentPlayerId()) ? Side.FREE_PEOPLE : Side.SHADOW;
return Filters.canBeAssignedToSkirmishByEffect(side).accepts(game.getGameState(), game.getModifiersQuerying(), _fpChar)
return (
(_ignoreSingleMinionRestriction && Filters.canBeAssignedToSkirmishByEffectIgnoreNotAssigned(side).accepts(game.getGameState(), game.getModifiersQuerying(), _fpChar))
|| Filters.canBeAssignedToSkirmishByEffect(side).accepts(game.getGameState(), game.getModifiersQuerying(), _fpChar))
&& Filters.canBeAssignedToSkirmishByEffect(side).accepts(game.getGameState(), game.getModifiersQuerying(), _minion)
&& game.getModifiersQuerying().isValidAssignments(game.getGameState(), side, Collections.singletonMap(_fpChar, Collections.singletonList(_minion)));
}

View File

@@ -16,9 +16,19 @@ import java.util.*;
public class KillEffect extends AbstractSuccessfulEffect {
private List<PhysicalCard> _cards;
private Cause _cause;
public KillEffect(List<PhysicalCard> cards) {
public enum Cause {
WOUNDS, OVERWHELM, CARD_EFFECT
}
public KillEffect(List<PhysicalCard> cards, Cause cause) {
_cards = cards;
_cause = cause;
}
public Cause getCause() {
return _cause;
}
@Override
@@ -91,9 +101,9 @@ public class KillEffect extends AbstractSuccessfulEffect {
gameState.addCardToZone(game, discardedCard, Zone.DISCARD);
if (killedCards.size() > 0 && discardedCards.size() > 0) {
return Arrays.asList(new KillResult(killedCards), new DiscardCardsFromPlayResult(discardedCards));
return Arrays.asList(new KillResult(killedCards, _cause), new DiscardCardsFromPlayResult(discardedCards));
} else if (killedCards.size() > 0) {
return Arrays.asList(new KillResult(killedCards));
return Arrays.asList(new KillResult(killedCards, _cause));
} else if (discardedCards.size() > 0) {
return Arrays.asList(new DiscardCardsFromPlayResult(discardedCards));
} else {

View File

@@ -0,0 +1,40 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.results.KillResult;
import com.gempukku.lotro.logic.timing.results.ThreatWoundTriggerResult;
import java.util.Collections;
public class ThreatWoundsEffect extends AbstractEffect {
private KillResult _killResult;
public ThreatWoundsEffect(KillResult killResult) {
_killResult = killResult;
}
public KillResult getKillResult() {
return _killResult;
}
@Override
public String getText(LotroGame game) {
return "Before threat wounds are placed";
}
@Override
public Type getType() {
return Type.BEFORE_THREAT_WOUNDS;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
return new FullEffectResult(Collections.singleton(new ThreatWoundTriggerResult()), true, true);
}
}

View File

@@ -9,7 +9,8 @@ public interface Effect {
BEFORE_WOUND, BEFORE_EXERT, BEFORE_ADD_BURDENS, BEFORE_DISCARD_FROM_PLAY,
BEFORE_ADD_TWILIGHT, BEFORE_KILLED, BEFORE_HEALED,
BEFORE_TAKE_CONTROL_OF_A_SITE,
BEFORE_SKIRMISH_RESOLVED
BEFORE_SKIRMISH_RESOLVED,
BEFORE_THREAT_WOUNDS
}
/**

View File

@@ -22,7 +22,8 @@ public abstract class EffectResult {
WHEN_MOVE_FROM, WHEN_FELLOWSHIP_MOVES, WHEN_MOVE_TO,
REVEAL_CARDS_FROM_HAND,
INITIATIVE_CHANGE
INITIATIVE_CHANGE,
THREAT_WOUND_TRIGGER
}
private Type _type;

View File

@@ -1,19 +1,26 @@
package com.gempukku.lotro.logic.timing.results;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.logic.effects.KillEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Set;
public class KillResult extends EffectResult {
private Set<PhysicalCard> _killedCards;
private KillEffect.Cause _cause;
public KillResult(Set<PhysicalCard> killedCards) {
public KillResult(Set<PhysicalCard> killedCards, KillEffect.Cause cause) {
super(EffectResult.Type.KILL);
_killedCards = killedCards;
_cause = cause;
}
public Set<PhysicalCard> getKilledCards() {
return _killedCards;
}
public KillEffect.Cause getCause() {
return _cause;
}
}

View File

@@ -0,0 +1,9 @@
package com.gempukku.lotro.logic.timing.results;
import com.gempukku.lotro.logic.timing.EffectResult;
public class ThreatWoundTriggerResult extends EffectResult {
public ThreatWoundTriggerResult() {
super(Type.THREAT_WOUND_TRIGGER);
}
}

View File

@@ -29,7 +29,7 @@ public class CharacterDeathRule {
RequiredTriggerAction action = new RequiredTriggerAction(null);
action.setText("Character(s) death");
action.appendEffect(
new KillEffect(deadCharacters));
new KillEffect(deadCharacters, KillEffect.Cause.WOUNDS));
return Collections.singletonList(action);
}

View File

@@ -59,7 +59,7 @@ public class ResolveSkirmishRule {
RequiredTriggerAction action = new RequiredTriggerAction(null);
action.setText("Resolving skirmish");
action.appendEffect(new KillEffect(losers));
action.appendEffect(new KillEffect(losers, KillEffect.Cause.OVERWHELM));
return Collections.singletonList(action);
}

View File

@@ -10,6 +10,7 @@ import com.gempukku.lotro.game.state.actions.DefaultActionsEnvironment;
import com.gempukku.lotro.logic.actions.RequiredTriggerAction;
import com.gempukku.lotro.logic.effects.ChooseAndWoundCharactersEffect;
import com.gempukku.lotro.logic.effects.RemoveThreatsEffect;
import com.gempukku.lotro.logic.effects.ThreatWoundsEffect;
import com.gempukku.lotro.logic.modifiers.ModifierFlag;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
@@ -32,9 +33,16 @@ public class ThreatRule {
public List<? extends Action> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult) {
if (effectResult.getType() == EffectResult.Type.KILL) {
KillResult killResult = (KillResult) effectResult;
boolean threatsTrigger = Filters.filter(killResult.getKilledCards(), game.getGameState(), game.getModifiersQuerying(), Filters.or(CardType.COMPANION, CardType.ALLY)).size() > 0;
if (Filters.filter(killResult.getKilledCards(), game.getGameState(), game.getModifiersQuerying(), Filters.or(CardType.COMPANION, CardType.ALLY)).size() > 0) {
RequiredTriggerAction action = new RequiredTriggerAction(null);
action.appendEffect(
new ThreatWoundsEffect(killResult));
return Collections.singletonList(action);
}
}
if (effectResult.getType() == EffectResult.Type.THREAT_WOUND_TRIGGER) {
int threats = game.getGameState().getThreats();
if (threatsTrigger && threats > 0) {
if (threats > 0) {
RequiredTriggerAction action = new RequiredTriggerAction(null);
action.setText("Threat damage assignment");
action.appendEffect(