"Depart Silently"

This commit is contained in:
marcins78@gmail.com
2011-09-30 13:38:23 +00:00
parent 0889a067ab
commit 310d7a0cc9
14 changed files with 148 additions and 47 deletions

View File

@@ -0,0 +1,19 @@
package com.gempukku.lotro.cards.modifiers;
import com.gempukku.lotro.filters.Filter;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.logic.modifiers.AbstractModifier;
import com.gempukku.lotro.logic.modifiers.ModifierEffect;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
public class CantBeAssignedToSkirmishModifier extends AbstractModifier {
public CantBeAssignedToSkirmishModifier(PhysicalCard source, Filter affectFilter) {
super(source, "Can't be assigned to skirmish", affectFilter, new ModifierEffect[]{ModifierEffect.ASSIGNMENT_MODIFIER});
}
@Override
public boolean canBeAssignedToSkirmish(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, boolean result) {
return false;
}
}

View File

@@ -3,15 +3,10 @@ package com.gempukku.lotro.cards.set1.moria;
import com.gempukku.lotro.cards.AbstractEvent; import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.CardAffectsCardEffect; import com.gempukku.lotro.cards.effects.CardAffectsCardEffect;
import com.gempukku.lotro.common.CardType; import com.gempukku.lotro.common.*;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.filters.Filters; import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.game.state.Skirmish;
import com.gempukku.lotro.logic.effects.AssignmentEffect; import com.gempukku.lotro.logic.effects.AssignmentEffect;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect; import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
@@ -41,10 +36,10 @@ public class Card1_169 extends AbstractEvent {
final PlayEventAction action = new PlayEventAction(self); final PlayEventAction action = new PlayEventAction(self);
final PhysicalCard ringBearer = game.getGameState().getRingBearer(game.getGameState().getCurrentPlayerId()); final PhysicalCard ringBearer = game.getGameState().getRingBearer(game.getGameState().getCurrentPlayerId());
if (!isFPCharacterAssigned(game.getGameState(), ringBearer)) { if (Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.RING_BEARER), Filters.canBeAssignedToSkirmish()).size() > 0) {
action.appendEffect(new CardAffectsCardEffect(self, ringBearer)); action.appendEffect(new CardAffectsCardEffect(self, ringBearer));
action.appendEffect( action.appendEffect(
new ChooseActiveCardEffect(game.getGameState().getCurrentPlayerId(), "Choose minion to assign Ring-Bearer to", Filters.type(CardType.MINION), Filters.notAssigned()) { new ChooseActiveCardEffect(game.getGameState().getCurrentPlayerId(), "Choose minion to assign Ring-Bearer to", Filters.type(CardType.MINION), Filters.canBeAssignedToSkirmish()) {
@Override @Override
protected void cardSelected(PhysicalCard minion) { protected void cardSelected(PhysicalCard minion) {
action.appendEffect( action.appendEffect(
@@ -55,14 +50,6 @@ public class Card1_169 extends AbstractEvent {
return action; return action;
} }
private boolean isFPCharacterAssigned(GameState gameState, PhysicalCard card) {
for (Skirmish skirmish : gameState.getAssignments()) {
if (skirmish.getFellowshipCharacter() == card)
return true;
}
return false;
}
@Override @Override
public int getTwilightCost() { public int getTwilightCost() {
return 0; return 0;

View File

@@ -29,12 +29,12 @@ public class Card1_171 extends AbstractEvent {
public PlayEventAction getPlayCardAction(final String playerId, final LotroGame game, final PhysicalCard self, int twilightModifier) { public PlayEventAction getPlayCardAction(final String playerId, final LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self); final PlayEventAction action = new PlayEventAction(self);
action.appendEffect( action.appendEffect(
new ChooseActiveCardEffect(playerId, "Choose exhausted companion", Filters.type(CardType.COMPANION), Filters.exhausted(), Filters.notAssigned()) { new ChooseActiveCardEffect(playerId, "Choose exhausted companion", Filters.type(CardType.COMPANION), Filters.exhausted(), Filters.canBeAssignedToSkirmish()) {
@Override @Override
protected void cardSelected(final PhysicalCard companion) { protected void cardSelected(final PhysicalCard companion) {
action.appendEffect(new CardAffectsCardEffect(self, companion)); action.appendEffect(new CardAffectsCardEffect(self, companion));
action.appendEffect( action.appendEffect(
new ChooseActiveCardEffect(playerId, "Choose MORIA Orc", Filters.culture(Culture.MORIA), Filters.race(Race.ORC), Filters.notAssigned()) { new ChooseActiveCardEffect(playerId, "Choose MORIA Orc", Filters.culture(Culture.MORIA), Filters.race(Race.ORC), Filters.canBeAssignedToSkirmish()) {
@Override @Override
protected void cardSelected(PhysicalCard moriaOrc) { protected void cardSelected(PhysicalCard moriaOrc) {
action.appendEffect( action.appendEffect(

View File

@@ -44,10 +44,10 @@ public class Card1_262 extends AbstractMinion {
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) { protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.ASSIGNMENT, self, 0) if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.ASSIGNMENT, self, 0)
&& Filters.countSpottable(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.HOBBIT), Filters.type(CardType.COMPANION)) >= 2 && Filters.countSpottable(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.HOBBIT), Filters.type(CardType.COMPANION)) >= 2
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.sameCard(self), Filters.notAssigned())) { && Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.sameCard(self), Filters.canBeAssignedToSkirmish())) {
final ActivateCardAction action = new ActivateCardAction(self, Keyword.ASSIGNMENT); final ActivateCardAction action = new ActivateCardAction(self, Keyword.ASSIGNMENT);
action.appendEffect( action.appendEffect(
new ChooseActiveCardEffect(game.getGameState().getCurrentPlayerId(), "Choose a Hobbit", Filters.race(Race.HOBBIT), Filters.type(CardType.COMPANION)) { new ChooseActiveCardEffect(game.getGameState().getCurrentPlayerId(), "Choose a Hobbit", Filters.race(Race.HOBBIT), Filters.type(CardType.COMPANION), Filters.canBeAssignedToSkirmish()) {
@Override @Override
protected void cardSelected(PhysicalCard hobbit) { protected void cardSelected(PhysicalCard hobbit) {
action.appendEffect(new CardAffectsCardEffect(self, hobbit)); action.appendEffect(new CardAffectsCardEffect(self, hobbit));

View File

@@ -4,10 +4,7 @@ import com.gempukku.lotro.cards.AbstractResponseEvent;
import com.gempukku.lotro.cards.PlayConditions; import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.CardAffectsCardEffect; import com.gempukku.lotro.cards.effects.CardAffectsCardEffect;
import com.gempukku.lotro.common.Culture; import com.gempukku.lotro.common.*;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.filters.Filters; import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.AbstractActionProxy; import com.gempukku.lotro.game.AbstractActionProxy;
import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.PhysicalCard;
@@ -52,26 +49,28 @@ public class Card1_224 extends AbstractResponseEvent {
for (Skirmish assignment : assignments) for (Skirmish assignment : assignments)
game.getGameState().removeAssignment(assignment); game.getGameState().removeAssignment(assignment);
action.appendEffect( if (Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.RING_BEARER), Filters.canBeAssignedToSkirmish()) > 0) {
new ChooseActiveCardEffect(playerId, "Choose a Nazgul to skirmish the Ring-Bearer", Filters.race(Race.NAZGUL)) { action.appendEffect(
@Override new ChooseActiveCardEffect(playerId, "Choose a Nazgul to skirmish the Ring-Bearer", Filters.race(Race.NAZGUL)) {
protected void cardSelected(PhysicalCard nazgul) { @Override
PhysicalCard ringBearer = game.getGameState().getRingBearer(game.getGameState().getCurrentPlayerId()); protected void cardSelected(PhysicalCard nazgul) {
action.appendEffect(new CardAffectsCardEffect(self, ringBearer)); PhysicalCard ringBearer = game.getGameState().getRingBearer(game.getGameState().getCurrentPlayerId());
action.appendEffect(new AssignmentEffect(playerId, ringBearer, Collections.singletonList(nazgul), "Return to Its Master effect")); action.appendEffect(new CardAffectsCardEffect(self, ringBearer));
game.getGameState().setCancelRingText(true); action.appendEffect(new AssignmentEffect(playerId, ringBearer, Collections.singletonList(nazgul), "Return to Its Master effect"));
game.getActionsEnvironment().addUntilStartOfPhaseActionProxy( game.getGameState().setCancelRingText(true);
new AbstractActionProxy() { game.getActionsEnvironment().addUntilStartOfPhaseActionProxy(
@Override new AbstractActionProxy() {
public List<? extends Action> getRequiredAfterTriggers(LotroGame lotroGame, EffectResult effectResult) { @Override
if (effectResult.getType() == EffectResult.Type.END_OF_PHASE public List<? extends Action> getRequiredAfterTriggers(LotroGame lotroGame, EffectResult effectResult) {
&& lotroGame.getGameState().getCurrentPhase() == Phase.SKIRMISH) if (effectResult.getType() == EffectResult.Type.END_OF_PHASE
game.getGameState().setCancelRingText(false); && lotroGame.getGameState().getCurrentPhase() == Phase.SKIRMISH)
return null; game.getGameState().setCancelRingText(false);
} return null;
}, Phase.REGROUP); }
} }, Phase.REGROUP);
}); }
});
}
} }
}); });
return Collections.singletonList(action); return Collections.singletonList(action);

View File

@@ -40,7 +40,7 @@ public class Card1_236 extends AbstractMinion {
final ActivateCardAction action = new ActivateCardAction(self, Keyword.ASSIGNMENT); final ActivateCardAction action = new ActivateCardAction(self, Keyword.ASSIGNMENT);
if (Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.sameCard(self), Filters.notAssigned())) { if (Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.sameCard(self), Filters.notAssigned())) {
action.appendEffect( action.appendEffect(
new ChooseActiveCardEffect(playerId, "Choose a companion (except the Ring-Bearer", Filters.type(CardType.COMPANION), Filters.not(Filters.keyword(Keyword.RING_BEARER))) { new ChooseActiveCardEffect(playerId, "Choose a companion (except the Ring-Bearer", Filters.type(CardType.COMPANION), Filters.not(Filters.keyword(Keyword.RING_BEARER)), Filters.canBeAssignedToSkirmish()) {
@Override @Override
protected void cardSelected(PhysicalCard companion) { protected void cardSelected(PhysicalCard companion) {
action.appendEffect(new CardAffectsCardEffect(self, companion)); action.appendEffect(new CardAffectsCardEffect(self, companion));

View File

@@ -0,0 +1,60 @@
package com.gempukku.lotro.cards.set3.gandalf;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.AddUntilStartOfPhaseModifierEffect;
import com.gempukku.lotro.cards.modifiers.CantBeAssignedToSkirmishModifier;
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
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.effects.ChooseActiveCardEffect;
/**
* Set: Realms of Elf-lords
* Side: Free
* Culture: Gandalf
* Twilight Cost: 1
* Type: Event
* Game Text: Stealth. Maneuver: At sites 1 to 5, spot Gandalf to prevent Hobbits from being assigned to skirmishes
* until the regroup phase. At any other site, spot Gandalf to make a Hobbit strength +3 until the regroup phase.
*/
public class Card3_031 extends AbstractEvent {
public Card3_031() {
super(Side.FREE_PEOPLE, Culture.GANDALF, "Depart Silently", Phase.MANEUVER);
addKeyword(Keyword.STEALTH);
}
@Override
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
return super.checkPlayRequirements(playerId, game, self, twilightModifier)
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.name("Gandalf"));
}
@Override
public int getTwilightCost() {
return 1;
}
@Override
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
if (game.getGameState().getCurrentSiteNumber() <= 5) {
action.appendEffect(
new AddUntilStartOfPhaseModifierEffect(
new CantBeAssignedToSkirmishModifier(self, Filters.race(Race.HOBBIT)), Phase.REGROUP));
} else {
action.appendEffect(
new ChooseActiveCardEffect(playerId, "Choose a Hobbit", Filters.race(Race.HOBBIT)) {
@Override
protected void cardSelected(PhysicalCard card) {
action.insertEffect(
new AddUntilStartOfPhaseModifierEffect(
new StrengthModifier(self, Filters.sameCard(card), 3), Phase.REGROUP));
}
});
}
return action;
}
}

View File

@@ -57,6 +57,22 @@ public class Filters {
// Filters available // Filters available
public static Filter canBeAssignedToSkirmish() {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
if (physicalCard.getBlueprint().getSide() == Side.SHADOW) {
for (Skirmish assignment : gameState.getAssignments()) {
if (assignment.getFellowshipCharacter() == physicalCard
|| assignment.getShadowCharacters().contains(physicalCard))
return false;
}
}
return modifiersQuerying.canBeAssignedToSkirmish(gameState, physicalCard);
}
};
}
public static Filter weapon() { public static Filter weapon() {
return new Filter() { return new Filter() {
@Override @Override

View File

@@ -150,6 +150,11 @@ public abstract class AbstractModifier implements Modifier {
return result; return result;
} }
@Override
public boolean canBeAssignedToSkirmish(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, boolean result) {
return true;
}
@Override @Override
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source, boolean result) { public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source, boolean result) {
return result; return result;

View File

@@ -62,6 +62,8 @@ public interface Modifier {
public boolean isValidFreePlayerAssignments(GameState gameState, ModifiersQuerying modifiersQuerying, Map<PhysicalCard, List<PhysicalCard>> assignments, boolean result); public boolean isValidFreePlayerAssignments(GameState gameState, ModifiersQuerying modifiersQuerying, Map<PhysicalCard, List<PhysicalCard>> assignments, boolean result);
public boolean canBeAssignedToSkirmish(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, boolean result);
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source, boolean result); public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source, boolean result);
public boolean canBeHealed(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, boolean result); public boolean canBeHealed(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, boolean result);

View File

@@ -357,6 +357,16 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
return result; return result;
} }
@Override
public boolean canBeAssignedToSkirmish(GameState gameState, PhysicalCard card) {
boolean result = true;
for (Modifier modifier : getModifiers(ModifierEffect.ASSIGNMENT_MODIFIER))
if (affectsCardWithSkipSet(gameState, card, modifier))
result = modifier.canBeAssignedToSkirmish(gameState, this, card, result);
return result;
}
@Override @Override
public boolean canBeDiscardedFromPlay(GameState gameState, PhysicalCard card, PhysicalCard source) { public boolean canBeDiscardedFromPlay(GameState gameState, PhysicalCard card, PhysicalCard source) {
boolean result = true; boolean result = true;

View File

@@ -51,6 +51,8 @@ public interface ModifiersQuerying {
public boolean isValidFreePlayerAssignments(GameState gameState, Map<PhysicalCard, List<PhysicalCard>> assignments); public boolean isValidFreePlayerAssignments(GameState gameState, Map<PhysicalCard, List<PhysicalCard>> assignments);
public boolean canBeAssignedToSkirmish(GameState gameState, PhysicalCard card);
public boolean canBeDiscardedFromPlay(GameState gameState, PhysicalCard card, PhysicalCard source); public boolean canBeDiscardedFromPlay(GameState gameState, PhysicalCard card, PhysicalCard source);
public boolean canBeHealed(GameState gameState, PhysicalCard card); public boolean canBeHealed(GameState gameState, PhysicalCard card);

View File

@@ -48,7 +48,8 @@ public class FreePeoplePlayerAssignsMinionsGameProcess implements GameProcess {
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) { public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.isAllyOnCurrentSite(gameState, physicalCard); return modifiersQuerying.isAllyOnCurrentSite(gameState, physicalCard);
} }
})); }),
Filters.canBeAssignedToSkirmish());
_game.getUserFeedback().sendAwaitingDecision(gameState.getCurrentPlayerId(), _game.getUserFeedback().sendAwaitingDecision(gameState.getCurrentPlayerId(),
new PlayerAssignMinionsDecision(1, "Assign minions to companions or allies at home", freePeopleTargets, minions) { new PlayerAssignMinionsDecision(1, "Assign minions to companions or allies at home", freePeopleTargets, minions) {

View File

@@ -52,7 +52,7 @@ public class ShadowPlayerAssignsHisMinionsGameProcess implements GameProcess {
return modifiersQuerying.isAllyOnCurrentSite(gameState, physicalCard); return modifiersQuerying.isAllyOnCurrentSite(gameState, physicalCard);
} }
} }
)); ), Filters.canBeAssignedToSkirmish());
_game.getUserFeedback().sendAwaitingDecision(_playerId, _game.getUserFeedback().sendAwaitingDecision(_playerId,
new PlayerAssignMinionsDecision(1, "Assign minions to companions or allies at home", freePeopleTargets, minions) { new PlayerAssignMinionsDecision(1, "Assign minions to companions or allies at home", freePeopleTargets, minions) {