Fixing archery.

This commit is contained in:
marcins78@gmail.com
2011-11-30 21:38:06 +00:00
parent 3d275b31c3
commit a6cbc0fc3c
4 changed files with 83 additions and 17 deletions

View File

@@ -58,10 +58,10 @@ public class Card4_057 extends AbstractPermanent {
action.insertEffect(
new AddUntilEndOfPhaseModifierEffect(
new StrengthModifier(self, Filters.sameCard(card), bonus), Phase.SKIRMISH));
action.appendEffect(
new SelfDiscardEffect(self));
}
});
action.appendEffect(
new SelfDiscardEffect(self));
return Collections.singletonList(action);
}
return null;

View File

@@ -21,7 +21,7 @@ public class ChooseAndWoundCharactersEffect extends ChooseActiveCardsEffect {
}
public ChooseAndWoundCharactersEffect(Action action, String playerId, int minimum, int maximum, int count, Filterable... filters) {
super(action.getActionSource().getPhysicalCard(), playerId, "Choose characters to wound", minimum, maximum, filters);
super((action.getActionSource() != null) ? action.getActionSource().getPhysicalCard() : null, playerId, "Choose characters to wound", minimum, maximum, filters);
_action = action;
_count = count;
}
@@ -44,7 +44,8 @@ public class ChooseAndWoundCharactersEffect extends ChooseActiveCardsEffect {
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
SubAction subAction = new SubAction(_action);
for (int i = 0; i < _count; i++) {
WoundCharactersEffect woundEffect = new WoundCharactersEffect(_action.getActionSource().getPhysicalCard(), Filters.in(cards));
PhysicalCard source = (_action.getActionSource() != null) ? _action.getActionSource().getPhysicalCard() : null;
WoundCharactersEffect woundEffect = new WoundCharactersEffect(source, Filters.in(cards));
if (_sourceText != null)
woundEffect.setSourceText(_sourceText);
subAction.appendEffect(woundEffect);

View File

@@ -45,21 +45,29 @@ public class LotroServer extends AbstractServer {
_chatServer = chatServer;
_test = test;
_defaultCollection = new DefaultCardCollection(library);
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 365; j++) {
String blueprintId = i + "_" + j;
try {
LotroCardBlueprint cardBlueprint = _lotroCardBlueprintLibrary.getLotroCardBlueprint(blueprintId);
CardType cardType = cardBlueprint.getCardType();
if (cardType == CardType.SITE || cardType == CardType.THE_ONE_RING)
_defaultCollection.addCards(blueprintId, cardBlueprint, 1);
else
_defaultCollection.addCards(blueprintId, cardBlueprint, 4);
} catch (IllegalArgumentException exp) {
Thread thr = new Thread(
new Runnable() {
public void run() {
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 365; j++) {
String blueprintId = i + "_" + j;
try {
LotroCardBlueprint cardBlueprint = _lotroCardBlueprintLibrary.getLotroCardBlueprint(blueprintId);
CardType cardType = cardBlueprint.getCardType();
if (cardType == CardType.SITE || cardType == CardType.THE_ONE_RING)
_defaultCollection.addCards(blueprintId, cardBlueprint, 1);
else
_defaultCollection.addCards(blueprintId, cardBlueprint, 4);
} catch (IllegalArgumentException exp) {
}
}
}
}
}
}
}
);
thr.start();
_playerDao = new PlayerDAO(dbAccess);
_deckDao = new DeckDAO(dbAccess);

View File

@@ -0,0 +1,57 @@
package com.gempukku.lotro.at;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.PhysicalCardImpl;
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
import com.gempukku.lotro.logic.decisions.AwaitingDecisionType;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class ArcheryAtTest extends AbstractAtTest {
@Test
public void archeryWorksBothWays() throws DecisionResultInvalidException {
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
initializeSimplestGame(extraCards);
PhysicalCardImpl legolas = new PhysicalCardImpl(100, "1_51", P1, _library.getLotroCardBlueprint("1_51"));
PhysicalCardImpl archerMinion = new PhysicalCardImpl(101, "4_138", P2, _library.getLotroCardBlueprint("4_138"));
skipMulligans();
_game.getGameState().addCardToZone(_game, legolas, Zone.FREE_CHARACTERS);
// End fellowship phase
assertEquals(Phase.FELLOWSHIP, _game.getGameState().getCurrentPhase());
playerDecided(P1, "");
_game.getGameState().addCardToZone(_game, archerMinion, Zone.SHADOW_CHARACTERS);
// End shadow phase
assertEquals(Phase.SHADOW, _game.getGameState().getCurrentPhase());
playerDecided(P2, "");
// End maneuver phase
playerDecided(P1, "");
playerDecided(P2, "");
// End archery phase
playerDecided(P1, "");
playerDecided(P2, "");
AwaitingDecision archeryWoundDecision = _userFeedback.getAwaitingDecision(P1);
assertEquals(AwaitingDecisionType.CARD_SELECTION, archeryWoundDecision.getDecisionType());
assertEquals(2, ((String[]) archeryWoundDecision.getDecisionParameters().get("cardId")).length);
playerDecided(P1, String.valueOf(legolas.getCardId()));
assertEquals(1, _game.getGameState().getWounds(legolas));
assertEquals(1, _game.getGameState().getWounds(archerMinion));
assertEquals(Phase.ASSIGNMENT, _game.getGameState().getCurrentPhase());
}
}