"Wind That Sped Ships"

This commit is contained in:
marcins78@gmail.com
2011-11-14 15:49:58 +00:00
parent 52d4fafbd0
commit 8c5762c79b
5 changed files with 148 additions and 12 deletions

View File

@@ -0,0 +1,54 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collection;
public class OptionalEffect extends AbstractSubActionEffect {
private Action _action;
private String _playerId;
private Effect _optionalEffect;
public OptionalEffect(Action action, String playerId, Effect optionalEffect) {
_action = action;
_playerId = playerId;
_optionalEffect = optionalEffect;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return true;
}
@Override
public Collection<? extends EffectResult> playEffect(final LotroGame game) {
game.getUserFeedback().sendAwaitingDecision(_playerId,
new MultipleChoiceAwaitingDecision(1, "Do you wish to " + _optionalEffect.getText(game) + "?", new String[]{"Yes", "No"}) {
@Override
protected void validDecisionMade(int index, String result) {
if (index == 0) {
SubAction subAction = new SubAction(_action);
subAction.appendEffect(_optionalEffect);
processSubAction(game, subAction);
}
}
});
return null;
}
}

View File

@@ -6,10 +6,10 @@ import com.gempukku.lotro.cards.effects.AddTokenEffect;
import com.gempukku.lotro.cards.modifiers.HasInitiativeModifier;
import com.gempukku.lotro.cards.modifiers.conditions.AndCondition;
import com.gempukku.lotro.common.*;
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.GameUtils;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.actions.OptionalTriggerAction;
import com.gempukku.lotro.logic.effects.AddTwilightEffect;
@@ -48,21 +48,12 @@ public class Card8_059 extends AbstractPermanent {
new Condition() {
@Override
public boolean isFullfilled(GameState gameState, ModifiersQuerying modifiersQuerying) {
return getRaiderTokensTotal(gameState, modifiersQuerying) >= 6;
return GameUtils.getSpottableTokensTotal(gameState, modifiersQuerying, Token.RAIDER) >= 6;
}
}
), Side.SHADOW));
}
private int getRaiderTokensTotal(GameState gameState, ModifiersQuerying modifiersQuerying) {
int raiderTokensTotal = 0;
for (PhysicalCard physicalCard : Filters.filterActive(gameState, modifiersQuerying, Filters.hasToken(Token.RAIDER)))
raiderTokensTotal += gameState.getTokenCount(physicalCard, Token.RAIDER);
return raiderTokensTotal;
}
@Override
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (PlayConditions.played(game, effectResult, self)) {
@@ -80,7 +71,7 @@ public class Card8_059 extends AbstractPermanent {
ActivateCardAction action = new ActivateCardAction(self);
action.appendEffect(
new AddTwilightEffect(self, getRaiderTokensTotal(game.getGameState(), game.getModifiersQuerying())));
new AddTwilightEffect(self, GameUtils.getSpottableTokensTotal(game.getGameState(), game.getModifiersQuerying(), Token.RAIDER)));
action.appendEffect(
new DiscardCardsFromPlayEffect(self, self));
return Collections.singletonList(action);

View File

@@ -0,0 +1,74 @@
package com.gempukku.lotro.cards.set8.raider;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.AddUntilEndOfPhaseModifierEffect;
import com.gempukku.lotro.cards.effects.OptionalEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.modifiers.StrengthModifier;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
/**
* Set: Siege of Gondor
* Side: Shadow
* Culture: Raider
* Twilight Cost: 1
* Type: Event • Skirmish
* Game Text: Make a corsair strength +1 for each [RAIDER] token you spot (limit +6). If you have initiative, you may
* place this event on top of your draw deck.
*/
public class Card8_066 extends AbstractEvent {
public Card8_066() {
super(Side.SHADOW, 1, Culture.RAIDER, "Wind That Sped Ships", Phase.SKIRMISH);
}
@Override
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose Corsair", Keyword.CORSAIR) {
@Override
protected void cardSelected(final LotroGame game, final PhysicalCard card) {
int count = Math.min(6, GameUtils.getSpottableTokensTotal(game.getGameState(), game.getModifiersQuerying(), Token.RAIDER));
IntegerAwaitingDecision spotDecision = new IntegerAwaitingDecision(1, "How many RAIDER tokens you wish to spot?", 0, count) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int value = getValidatedResult(result);
action.appendEffect(
new AddUntilEndOfPhaseModifierEffect(
new StrengthModifier(self, card, value), Phase.SKIRMISH));
if (PlayConditions.hasInitiative(game, Side.SHADOW))
action.appendEffect(
new OptionalEffect(action, playerId,
new UnrespondableEffect() {
@Override
public String getText(LotroGame game) {
return "Place this event on top of your draw deck";
}
@Override
protected void doPlayEffect(LotroGame game) {
action.skipDiscardPart();
game.getGameState().putCardOnTopOfDeck(self);
}
}));
}
};
spotDecision.setDefaultValue(count);
action.appendEffect(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId, spotDecision));
}
});
return action;
}
}

View File

@@ -1,7 +1,11 @@
package com.gempukku.lotro.logic;
import com.gempukku.lotro.common.Token;
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.modifiers.ModifiersQuerying;
import java.util.*;
@@ -60,4 +64,13 @@ public class GameUtils {
else
return sb.substring(0, sb.length() - 2);
}
public static int getSpottableTokensTotal(GameState gameState, ModifiersQuerying modifiersQuerying, Token token) {
int tokensTotal = 0;
for (PhysicalCard physicalCard : Filters.filterActive(gameState, modifiersQuerying, Filters.hasToken(token)))
tokensTotal += gameState.getTokenCount(physicalCard, token);
return tokensTotal;
}
}

View File

@@ -22,6 +22,10 @@ public abstract class IntegerAwaitingDecision extends AbstractAwaitingDecision {
setParam("max", max.toString());
}
public void setDefaultValue(int defaultValue) {
setParam("defaultValue", String.valueOf(defaultValue));
}
protected int getValidatedResult(String result) throws DecisionResultInvalidException {
try {
int value = Integer.parseInt(result);