"Fereveldir"
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package com.gempukku.lotro.cards.set4.elven;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractCompanion;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.ExertCharactersEffect;
|
||||
import com.gempukku.lotro.cards.effects.RemoveTokenEffect;
|
||||
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.actions.ActivateCardAction;
|
||||
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
|
||||
import com.gempukku.lotro.logic.effects.ChooseAndWoundCharactersEffect;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: The Two Towers
|
||||
* Side: Free
|
||||
* Culture: Elven
|
||||
* Twilight Cost: 2
|
||||
* Type: Companion • Elf
|
||||
* Strength: 5
|
||||
* Vitality: 3
|
||||
* Resistance: 6
|
||||
* Game Text: To play, spot an Elf.
|
||||
* Skirmish: Exert Fereveldir and discard an [ELVEN] token from your condition to wound a minion Fereveldir
|
||||
* is skirmishing.
|
||||
*/
|
||||
public class Card4_067 extends AbstractCompanion {
|
||||
public Card4_067() {
|
||||
super(2, 5, 3, Culture.ELVEN, Race.ELF, null, "Fereveldir", true);
|
||||
}
|
||||
|
||||
@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.race(Race.ELF));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Action> getExtraInPlayPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
|
||||
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self)
|
||||
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), self)
|
||||
&& Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.owner(playerId), Filters.type(CardType.CONDITION), Filters.hasToken(Token.ELVEN)) > 0) {
|
||||
final ActivateCardAction action = new ActivateCardAction(self, Keyword.SKIRMISH);
|
||||
action.appendCost(
|
||||
new ExertCharactersEffect(self, self));
|
||||
action.appendCost(
|
||||
new ChooseActiveCardEffect(self, playerId, "Choose condition", Filters.owner(playerId), Filters.type(CardType.CONDITION), Filters.hasToken(Token.ELVEN)) {
|
||||
@Override
|
||||
protected void cardSelected(PhysicalCard card) {
|
||||
action.insertCost(
|
||||
new RemoveTokenEffect(self, card, Token.ELVEN));
|
||||
}
|
||||
});
|
||||
action.appendEffect(
|
||||
new ChooseAndWoundCharactersEffect(action, playerId, 1, 1, Filters.type(CardType.MINION), Filters.inSkirmishAgainst(Filters.sameCard(self))));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,15 @@ public class Filters {
|
||||
|
||||
// Filters available
|
||||
|
||||
public static Filter hasToken(final Token token) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return gameState.getTokenCount(physicalCard, token) > 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Filter canBeAssignedToSkirmish() {
|
||||
return new Filter() {
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LotroCardBlueprintLibrary {
|
||||
@@ -14,6 +16,7 @@ public class LotroCardBlueprintLibrary {
|
||||
private Map<String, LotroCardBlueprint> _blueprintMap = new HashMap<String, LotroCardBlueprint>();
|
||||
|
||||
private Map<String, String> _blueprintMapping = new HashMap<String, String>();
|
||||
private Map<String, List<String>> _fullBlueprintMapping = new HashMap<String, List<String>>();
|
||||
|
||||
public LotroCardBlueprintLibrary() {
|
||||
try {
|
||||
@@ -24,6 +27,7 @@ public class LotroCardBlueprintLibrary {
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
String[] split = line.split(",");
|
||||
_blueprintMapping.put(split[0], split[1]);
|
||||
addAlternatives(split[0], split[1]);
|
||||
}
|
||||
} finally {
|
||||
bufferedReader.close();
|
||||
@@ -31,7 +35,30 @@ public class LotroCardBlueprintLibrary {
|
||||
} catch (IOException exp) {
|
||||
throw new RuntimeException("Problem loading blueprint mapping", exp);
|
||||
}
|
||||
}
|
||||
|
||||
private void addAlternatives(String blueprint1, String blueprint2) {
|
||||
addAlternative(blueprint1, blueprint2);
|
||||
addAlternative(blueprint2, blueprint1);
|
||||
}
|
||||
|
||||
private void addAlternative(String from, String to) {
|
||||
List<String> list = _fullBlueprintMapping.get(from);
|
||||
if (list == null) {
|
||||
list = new LinkedList<String>();
|
||||
_fullBlueprintMapping.put(from, list);
|
||||
}
|
||||
list.add(to);
|
||||
}
|
||||
|
||||
public boolean hasAlternateInSet(String blueprintId, int setNo) {
|
||||
List<String> alternatives = _fullBlueprintMapping.get(blueprintId);
|
||||
if (alternatives != null)
|
||||
for (String alternative : alternatives)
|
||||
if (alternative.startsWith(setNo + "_"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public LotroCardBlueprint getLotroCardBlueprint(String blueprintId) {
|
||||
@@ -61,7 +88,9 @@ public class LotroCardBlueprintLibrary {
|
||||
// public Collection<LotroCardBlueprint> getAllLoadedBlueprints() {
|
||||
// return _blueprintMap.values();
|
||||
// }
|
||||
//
|
||||
|
||||
//
|
||||
|
||||
private LotroCardBlueprint getBlueprint(String blueprintId) {
|
||||
if (_blueprintMapping.containsKey(blueprintId))
|
||||
return getBlueprint(_blueprintMapping.get(blueprintId));
|
||||
|
||||
@@ -37,7 +37,7 @@ public class LotroServer extends AbstractServer {
|
||||
_lotroCardBlueprintLibrary = library;
|
||||
_chatServer = chatServer;
|
||||
_defaultCollection = new DefaultCardCollection();
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
for (int j = 1; j <= 365; j++) {
|
||||
String blueprintId = i + "_" + j;
|
||||
try {
|
||||
@@ -53,24 +53,6 @@ public class LotroServer extends AbstractServer {
|
||||
}
|
||||
}
|
||||
|
||||
if (test) {
|
||||
for (int i = 4; i <= 4; 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) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_playerDao = new PlayerDAO(dbAccess);
|
||||
_deckDao = new DeckDAO(dbAccess);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public abstract class DefaultLotroFormat implements LotroFormat {
|
||||
private int _maximumSameName = 4;
|
||||
private int _minimumDeckSize = 60;
|
||||
private Set<String> _restrictedCard = new HashSet<String>();
|
||||
private Set<Integer> _validSets = new HashSet<Integer>();
|
||||
|
||||
public DefaultLotroFormat(LotroCardBlueprintLibrary library, Block siteBlock, boolean validateShadowFPCount, int minimumDeckSize, int maximumSameName) {
|
||||
_library = library;
|
||||
@@ -34,6 +35,19 @@ public abstract class DefaultLotroFormat implements LotroFormat {
|
||||
_restrictedCard.add(name);
|
||||
}
|
||||
|
||||
protected void addValidSet(int setNo) {
|
||||
_validSets.add(setNo);
|
||||
}
|
||||
|
||||
private void validateSet(String blueprintId) throws DeckInvalidException {
|
||||
for (int validSet : _validSets)
|
||||
if (blueprintId.startsWith(validSet + "_")
|
||||
|| _library.hasAlternateInSet(blueprintId, validSet))
|
||||
return;
|
||||
|
||||
throw new DeckInvalidException("Deck contains card not valid for this format: " + _library.getLotroCardBlueprint(blueprintId).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateDeck(LotroDeck deck) throws DeckInvalidException {
|
||||
try {
|
||||
@@ -64,6 +78,15 @@ public abstract class DefaultLotroFormat implements LotroFormat {
|
||||
throw new DeckInvalidException("One of the sites is from a different block than the format allows");
|
||||
}
|
||||
|
||||
if (_validSets != null) {
|
||||
validateSet(deck.getRingBearer());
|
||||
validateSet(deck.getRing());
|
||||
for (String site : deck.getSites())
|
||||
validateSet(site);
|
||||
for (String card : deck.getAdventureCards())
|
||||
validateSet(card);
|
||||
}
|
||||
|
||||
if (isOrderedSites()) {
|
||||
boolean[] sites = new boolean[9];
|
||||
for (String site : deck.getSites()) {
|
||||
|
||||
@@ -7,6 +7,9 @@ public class FotRBlockFormat extends DefaultLotroFormat {
|
||||
public FotRBlockFormat(LotroCardBlueprintLibrary library) {
|
||||
super(library, Block.FELLOWSHIP, true, 60, 4);
|
||||
addRestrictedCard("Forces of Mordor");
|
||||
addValidSet(1);
|
||||
addValidSet(2);
|
||||
addValidSet(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.gempukku.lotro.game.formats;
|
||||
import com.gempukku.lotro.common.Block;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
|
||||
public class ModifiedFotRBlockFormat extends DefaultLotroFormat {
|
||||
public ModifiedFotRBlockFormat(LotroCardBlueprintLibrary library) {
|
||||
public class FreeFormat extends DefaultLotroFormat {
|
||||
public FreeFormat(LotroCardBlueprintLibrary library) {
|
||||
super(library, Block.FELLOWSHIP, false, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.game.formats.FotRBlockFormat;
|
||||
import com.gempukku.lotro.game.formats.FreeFormat;
|
||||
import com.gempukku.lotro.game.formats.LotroFormat;
|
||||
import com.gempukku.lotro.game.formats.ModifiedFotRBlockFormat;
|
||||
import com.gempukku.lotro.league.LeagueService;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
|
||||
@@ -43,9 +43,7 @@ public class HallServer extends AbstractServer {
|
||||
_chatServer.createChatRoom("Game Hall");
|
||||
|
||||
addFormat("fotr_block", "Fellowship block", "default", new FotRBlockFormat(_lotroServer.getLotroCardBlueprintLibrary()));
|
||||
if (test) {
|
||||
addFormat("m_fotr_block", "Modified Fellowship block", "default", new ModifiedFotRBlockFormat(_lotroServer.getLotroCardBlueprintLibrary()));
|
||||
}
|
||||
addFormat("whatever", "Format for testing", "default", new FreeFormat(_lotroServer.getLotroCardBlueprintLibrary()));
|
||||
}
|
||||
|
||||
private void addFormat(String formatCode, String formatName, String formatCollectionId, LotroFormat format) {
|
||||
|
||||
Reference in New Issue
Block a user