- If an effect makes you exert a character X times, and you can't find a character able to be exerted X times, you can

choose matching character, which can exert X-1 times, and so on.
This commit is contained in:
marcins78@gmail.com
2012-01-23 02:57:11 +00:00
parent 60dfa33f60
commit 2729ca1315
5 changed files with 72 additions and 7 deletions

View File

@@ -8,8 +8,8 @@ import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.effects.AbstractPreventableCardEffect;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.results.ExertResult;
import java.util.Collection;
@@ -29,8 +29,8 @@ public class ExertCharactersEffect extends AbstractPreventableCardEffect {
_source = source;
}
public ExertCharactersEffect(Action action, PhysicalCard source, Filterable... filter) {
super(filter);
public ExertCharactersEffect(Action action, PhysicalCard source, PhysicalCard... cards) {
super(cards);
_action = action;
_source = source;
}

View File

@@ -17,6 +17,7 @@ import java.util.Collection;
public class ChooseAndExertCharactersEffect extends ChooseActiveCardsEffect {
private Action _action;
private int _times;
private Filterable[] _filters;
private SubAction _resultSubAction;
public ChooseAndExertCharactersEffect(Action action, String playerId, int minimum, int maximum, Filterable... filters) {
@@ -27,10 +28,30 @@ public class ChooseAndExertCharactersEffect extends ChooseActiveCardsEffect {
super(action.getActionSource(), playerId, "Choose characters to exert", minimum, maximum, filters);
_action = action;
_times = times;
_filters = filters;
}
@Override
protected Filter getExtraFilterForPlaying(LotroGame game) {
int times = _times;
do {
final int exertTimes = times;
Filter filter = new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canBeExerted(gameState, _action.getActionSource(), physicalCard)
&& modifiersQuerying.getVitality(gameState, physicalCard) > exertTimes;
}
};
if (Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.and(_filters, filter)))
return filter;
times--;
} while (times > 0);
return Filters.none;
}
@Override
protected Filter getExtraFilterForPlayabilityCheck(LotroGame game) {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
@@ -44,7 +65,7 @@ public class ChooseAndExertCharactersEffect extends ChooseActiveCardsEffect {
protected final void cardsSelected(LotroGame game, Collection<PhysicalCard> characters) {
_resultSubAction = new SubAction(_action);
for (int i = 0; i < _times; i++) {
_resultSubAction.appendEffect(new ExertCharactersEffect(_action, _action.getActionSource(), Filters.in(characters)));
_resultSubAction.appendEffect(new ExertCharactersEffect(_action, _action.getActionSource(), characters.toArray(new PhysicalCard[characters.size()])));
}
game.getActionsEnvironment().addActionToStack(_resultSubAction);

View File

@@ -8,15 +8,15 @@ import com.gempukku.lotro.logic.actions.SystemQueueAction;
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
import com.gempukku.lotro.logic.decisions.CardActionSelectionDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.DefaultLotroGame;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.vo.LotroDeck;
import static org.junit.Assert.fail;
import org.junit.BeforeClass;
import java.util.*;
import static org.junit.Assert.fail;
public abstract class AbstractAtTest {
protected static LotroCardBlueprintLibrary _library;
@@ -140,9 +140,13 @@ public abstract class AbstractAtTest {
}
protected void carryOutEffectInPhaseActionByPlayer(String playerId, Effect effect) throws DecisionResultInvalidException {
CardActionSelectionDecision awaitingDecision = (CardActionSelectionDecision) _userFeedback.getAwaitingDecision(playerId);
SystemQueueAction action = new SystemQueueAction();
action.appendEffect(effect);
carryOutEffectInPhaseActionByPlayer(playerId, action);
}
protected void carryOutEffectInPhaseActionByPlayer(String playerId, Action action) throws DecisionResultInvalidException {
CardActionSelectionDecision awaitingDecision = (CardActionSelectionDecision) _userFeedback.getAwaitingDecision(playerId);
awaitingDecision.addAction(action);
playerDecided(playerId, "0");

View File

@@ -0,0 +1,38 @@
package com.gempukku.lotro.at.effects;
import com.gempukku.lotro.at.AbstractAtTest;
import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCardImpl;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
public class ExertEffectAtTest extends AbstractAtTest {
@Test
public void chooseAndExertTwiceAndCanOnlyOnce() throws DecisionResultInvalidException {
initializeSimplestGame();
skipMulligans();
final PhysicalCardImpl merry = new PhysicalCardImpl(101, "1_303", P1, _library.getLotroCardBlueprint("1_303"));
_game.getGameState().addCardToZone(_game, merry, Zone.FREE_CHARACTERS);
_game.getGameState().addWound(merry);
_game.getGameState().addWound(merry);
ActivateCardAction action = new ActivateCardAction(merry);
ChooseAndExertCharactersEffect exertEffect = new ChooseAndExertCharactersEffect(action, P1, 1, 1, 2, CardType.COMPANION, Filters.not(Filters.ringBearer));
action.appendEffect(exertEffect);
carryOutEffectInPhaseActionByPlayer(P1, action);
assertEquals(3, _game.getGameState().getWounds(merry));
assertFalse(exertEffect.wasSuccessful());
assertFalse(exertEffect.wasCarriedOut());
}
}

View File

@@ -1,6 +1,8 @@
<pre style="font-size:80%">
<b>22 Jan. 2012</b>
- Added resistance to card detail information window.
- If an effect makes you exert a character X times, and you can't find a character able to be exerted X times, you can
choose matching character, which can exert X-1 times, and so on.
<b>18 Jan. 2012</b>
- The casual games now have correct amount of cards in deck.