"Merry", "Pipeweed Aficionado"

This commit is contained in:
marcins78
2013-02-12 16:53:04 +00:00
parent f3a8b4e8c4
commit 6661018263
16 changed files with 87 additions and 54 deletions

View File

@@ -10,22 +10,23 @@ import java.util.Map;
public abstract class ForEachYouSpotDecision extends IntegerAwaitingDecision {
private LotroGame _lotroGame;
private Filterable _filter;
private Filterable[] _filters;
private int _defaultValue;
private int _max;
protected ForEachYouSpotDecision(int id, String text, LotroGame lotroGame, Filterable filter, int defaultValue) {
protected ForEachYouSpotDecision(int id, String text, LotroGame lotroGame, int defaultValue, Filterable... filter) {
super(id, text, 0);
_lotroGame = lotroGame;
_filter = filter;
_filters = filter;
_defaultValue = defaultValue;
}
@Override
public Map<String, Object> getDecisionParameters() {
Map<String, Object> result = super.getDecisionParameters();
int count = Filters.countActive(_lotroGame.getGameState(), _lotroGame.getModifiersQuerying(), _filter);
count += _lotroGame.getModifiersQuerying().getSpotBonus(_lotroGame.getGameState(), _filter);
int count = Filters.countActive(_lotroGame.getGameState(), _lotroGame.getModifiersQuerying(), _filters);
if (_filters.length == 1)
count += _lotroGame.getModifiersQuerying().getSpotBonus(_lotroGame.getGameState(), _filters[0]);
_max = count;
result.put("max", String.valueOf(count));
if (_defaultValue > _max)

View File

@@ -2,7 +2,6 @@ package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.cards.decisions.ForEachYouSpotDecision;
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.timing.AbstractSuccessfulEffect;
@@ -30,7 +29,7 @@ public abstract class ForEachYouSpotEffect extends AbstractSuccessfulEffect {
@Override
public void playEffect(LotroGame game) {
game.getUserFeedback().sendAwaitingDecision(_playerId,
new ForEachYouSpotDecision(1, "Choose how many you wish to spot", game, Filters.and(_filters), Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose how many you wish to spot", game, Integer.MAX_VALUE, _filters) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
spottedCards(getValidatedResult(result));

View File

@@ -45,7 +45,7 @@ public class Card1_074 extends AbstractAttachableFPPossession {
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Keyword.PIPEWEED, CardType.POSSESSION));
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, PossessionClass.PIPE, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, Integer.MAX_VALUE, PossessionClass.PIPE) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -47,7 +47,7 @@ public class Card1_091 extends AbstractAttachableFPPossession {
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Keyword.PIPEWEED, CardType.POSSESSION));
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, PossessionClass.PIPE, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, Integer.MAX_VALUE, PossessionClass.PIPE) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -46,7 +46,7 @@ public class Card1_145 extends AbstractMinion {
action.appendCost(new RemoveTwilightEffect(2));
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of minions you wish to spot", game, Filters.and(Race.URUK_HAI, Filters.not(self)), Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of minions you wish to spot", game, Integer.MAX_VALUE, Filters.and(Race.URUK_HAI, Filters.not(self))) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -45,7 +45,7 @@ public class Card1_189 extends AbstractResponseOldEvent {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose how many MORIA minions you wish to spot", game, Filters.and(Culture.MORIA, CardType.MINION), Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose how many MORIA minions you wish to spot", game, Integer.MAX_VALUE, Filters.and(Culture.MORIA, CardType.MINION)) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -48,7 +48,7 @@ public class Card1_285 extends AbstractAttachableFPPossession {
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Keyword.PIPEWEED, CardType.POSSESSION));
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, PossessionClass.PIPE, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, Integer.MAX_VALUE, PossessionClass.PIPE) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -44,7 +44,7 @@ public class Card1_292 extends AbstractAttachableFPPossession {
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Keyword.PIPEWEED, CardType.POSSESSION));
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, PossessionClass.PIPE, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, Integer.MAX_VALUE, PossessionClass.PIPE) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -34,7 +34,7 @@ public class Card1_215 extends AbstractOldEvent {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose how many Nazgul you want to spot", game, Race.NAZGUL, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose how many Nazgul you want to spot", game, Integer.MAX_VALUE, Race.NAZGUL) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -35,7 +35,7 @@ public class Card20_158 extends AbstractAttachableFPPossession {
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.startOfPhase(game, effectResult, Phase.FELLOWSHIP)
&& PlayConditions.canDiscardFromPlay(self, game, CardType.POSSESSION, Keyword.PIPEWEED)
&& PlayConditions.canSpot(game, 2, Filters.not(self), PossessionClass.PIPE)) {
&& PlayConditions.canSpot(game, 2, PossessionClass.PIPE)) {
OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendCost(
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, CardType.POSSESSION, Keyword.PIPEWEED));

View File

@@ -46,7 +46,7 @@ public class Card20_383 extends AbstractAttachableFPPossession {
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Keyword.PIPEWEED, CardType.POSSESSION));
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, PossessionClass.PIPE, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, Integer.MAX_VALUE, PossessionClass.PIPE) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);

View File

@@ -0,0 +1,50 @@
package com.gempukku.lotro.cards.set20.shire;
import com.gempukku.lotro.cards.AbstractCompanion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.SelfExertEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDeckEffect;
import com.gempukku.lotro.cards.modifiers.PossessionClassSpotModifier;
import com.gempukku.lotro.common.*;
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 java.util.Collections;
import java.util.List;
/**
* 1
* •Merry, Pipeweed Aficionado
* Shire Companion • Hobbit
* 3 4 8
* Add 1 to the number of pipes you can spot.
* Fellowship: Exert Merry twice to play a pipeweed possession from your draw deck.
*/
public class Card20_397 extends AbstractCompanion {
public Card20_397() {
super(1, 3, 4, 8, Culture.SHIRE, Race.HOBBIT, null, "Merry", "Pipeweed Aficionado", true);
}
@Override
public Modifier getAlwaysOnModifier(LotroGame game, PhysicalCard self) {
return new PossessionClassSpotModifier(self, PossessionClass.PIPE);
}
@Override
protected List<ActivateCardAction> getExtraInPlayPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game, Phase.FELLOWSHIP, self)
&& PlayConditions.canSelfExert(self, 2, game)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new SelfExertEffect(action, self));
action.appendCost(
new SelfExertEffect(action, self));
action.appendEffect(
new ChooseAndPlayCardFromDeckEffect(playerId, CardType.POSSESSION, Keyword.PIPEWEED));
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -46,7 +46,7 @@ public class Card3_107 extends AbstractAttachableFPPossession {
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Keyword.PIPEWEED, CardType.POSSESSION));
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, PossessionClass.PIPE, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of pipes you wish to spot", game, Integer.MAX_VALUE, PossessionClass.PIPE) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
final int spotCount = getValidatedResult(result);

View File

@@ -35,7 +35,7 @@ public class Card4_058 extends AbstractOldEvent {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of Elf companions you wish to spot", game, Filters.and(Race.ELF, CardType.COMPANION), Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of Elf companions you wish to spot", game, Integer.MAX_VALUE, Filters.and(Race.ELF, CardType.COMPANION)) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotted = getValidatedResult(result);

View File

@@ -31,7 +31,7 @@ public class Card5_048 extends AbstractEvent {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new PlayoutDecisionEffect(playerId,
new ForEachYouSpotDecision(1, "Choose number of Uruk-hai you wish to spot?", game, Race.URUK_HAI, Integer.MAX_VALUE) {
new ForEachYouSpotDecision(1, "Choose number of Uruk-hai you wish to spot?", game, Integer.MAX_VALUE, Race.URUK_HAI) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int count = getValidatedResult(result);

View File

@@ -59,15 +59,11 @@ public class Filters {
}
public static boolean canSpot(GameState gameState, ModifiersQuerying modifiersQuerying, Filterable... filters) {
Filter filter = Filters.and(filters);
SpotFilterCardInPlayVisitor visitor = new SpotFilterCardInPlayVisitor(gameState, modifiersQuerying, filter);
return gameState.iterateActiveCards(visitor);
return canSpot(gameState, modifiersQuerying, 1, filters);
}
public static boolean canSpot(GameState gameState, ModifiersQuerying modifiersQuerying, int count, Filterable... filters) {
Filter filter = Filters.and(filters);
SpotCountFilterCardInPlayVisitor visitor = new SpotCountFilterCardInPlayVisitor(gameState, modifiersQuerying, count, filter);
return gameState.iterateActiveCards(visitor);
return countSpottable(gameState, modifiersQuerying, filters)>=count;
}
public static Collection<PhysicalCard> filterActive(GameState gameState, ModifiersQuerying modifiersQuerying, Filterable... filters) {
@@ -87,7 +83,7 @@ public class Filters {
}
public static PhysicalCard findFirstActive(GameState gameState, ModifiersQuerying modifiersQuerying, Filterable... filters) {
SpotFilterCardInPlayVisitor visitor = new SpotFilterCardInPlayVisitor(gameState, modifiersQuerying, Filters.and(filters));
FindFirstActiveCardInPlayVisitor visitor = new FindFirstActiveCardInPlayVisitor(gameState, modifiersQuerying, Filters.and(filters));
gameState.iterateActiveCards(visitor);
return visitor.getCard();
}
@@ -95,7 +91,10 @@ public class Filters {
public static int countSpottable(GameState gameState, ModifiersQuerying modifiersQuerying, Filterable... filters) {
GetCardsMatchingFilterVisitor matchingFilterVisitor = new GetCardsMatchingFilterVisitor(gameState, modifiersQuerying, Filters.and(filters, Filters.spottable));
gameState.iterateActiveCards(matchingFilterVisitor);
return matchingFilterVisitor.getCounter();
int result = matchingFilterVisitor.getCounter();
if (filters.length==1)
result+=modifiersQuerying.getSpotBonus(gameState, filters[0]);
return result;
}
public static int countActive(GameState gameState, ModifiersQuerying modifiersQuerying, Filterable... filters) {
@@ -169,6 +168,15 @@ public class Filters {
};
}
public static Filter moreStrangthThan(final int strength) {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.getStrength(gameState, physicalCard) > strength;
}
};
}
public static Filter lessStrengthThan(final int strength) {
return new Filter() {
@Override
@@ -947,13 +955,13 @@ public class Filters {
}
};
private static class SpotFilterCardInPlayVisitor implements PhysicalCardVisitor {
private static class FindFirstActiveCardInPlayVisitor implements PhysicalCardVisitor {
private GameState _gameState;
private ModifiersQuerying _modifiersQuerying;
private Filter _filter;
private PhysicalCard _card;
private SpotFilterCardInPlayVisitor(GameState gameState, ModifiersQuerying modifiersQuerying, Filter filter) {
private FindFirstActiveCardInPlayVisitor(GameState gameState, ModifiersQuerying modifiersQuerying, Filter filter) {
_gameState = gameState;
_modifiersQuerying = modifiersQuerying;
_filter = filter;
@@ -973,31 +981,6 @@ public class Filters {
}
}
private static class SpotCountFilterCardInPlayVisitor implements PhysicalCardVisitor {
private GameState _gameState;
private ModifiersQuerying _modifiersQuerying;
private Filter _filter;
private int _spottedCount;
private int _searchingToSpot;
private SpotCountFilterCardInPlayVisitor(GameState gameState, ModifiersQuerying modifiersQuerying, int count, Filter filter) {
_gameState = gameState;
_modifiersQuerying = modifiersQuerying;
_searchingToSpot = count;
_filter = Filters.and(filter, Filters.spottable);
}
@Override
public boolean visitPhysicalCard(PhysicalCard physicalCard) {
if (_filter.accepts(_gameState, _modifiersQuerying, physicalCard)) {
_spottedCount++;
if (_spottedCount >= _searchingToSpot)
return true;
}
return false;
}
}
private static class GetCardsMatchingFilterVisitor extends CompletePhysicalCardVisitor {
private GameState _gameState;
private ModifiersQuerying _modifiersQuerying;