- "Eomer, Keeper of Oaths" can play only ROHAN possessions from those revelead, rather than any cards.

This commit is contained in:
marcins78@gmail.com
2011-11-21 23:27:57 +00:00
parent db912d2ae5
commit 4dce3aa459
11 changed files with 150 additions and 26 deletions

View File

@@ -0,0 +1,7 @@
package com.gempukku.lotro.cards.packs;
import java.util.List;
public interface BoosterBox {
public List<String> getBooster();
}

View File

@@ -0,0 +1,21 @@
package com.gempukku.lotro.cards.packs;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DefaultPackBox implements PackBox {
private Map<String, BoosterBox> _boosterBoxes = new HashMap<String, BoosterBox>();
public void addBoosterBox(String packId, BoosterBox boosterBox) {
_boosterBoxes.put(packId, boosterBox);
}
@Override
public List<String> openPack(String packId) {
BoosterBox boosterBox = _boosterBoxes.get(packId);
if (boosterBox == null)
return null;
return boosterBox.getBooster();
}
}

View File

@@ -6,7 +6,7 @@ import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import java.util.*;
public class LeagueBoosterBox {
public class LeagueBoosterBox implements BoosterBox {
private Random _random = new Random(0);
private LotroCardBlueprintLibrary _library;
@@ -25,9 +25,7 @@ public class LeagueBoosterBox {
_library = library;
}
public synchronized List<String> getBooster(String setNo) {
if (!setNo.equals("1"))
throw new IllegalArgumentException("Invalid setNo: " + setNo);
public synchronized List<String> getBooster() {
initializeFotR();
boolean hasFoil = _random.nextInt(6) == 0;

View File

@@ -0,0 +1,7 @@
package com.gempukku.lotro.cards.packs;
import java.util.List;
public interface PackBox {
public List<String> openPack(String packId);
}

View File

@@ -37,7 +37,7 @@ public class Card8_087 extends AbstractCompanion {
}
@Override
public List<OptionalTriggerAction> getOptionalAfterTriggers(final String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
public List<OptionalTriggerAction> getOptionalAfterTriggers(final String playerId, final LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.played(game, effectResult, self)
&& game.getGameState().getCurrentPhase() != Phase.PLAY_STARTING_FELLOWSHIP) {
final OptionalTriggerAction action = new OptionalTriggerAction(self);
@@ -45,8 +45,9 @@ public class Card8_087 extends AbstractCompanion {
new RevealTopCardsOfDrawDeckEffect(self, playerId, 10) {
@Override
protected void cardsRevealed(List<PhysicalCard> cards) {
Collection<PhysicalCard> rohanPossessions = Filters.filter(cards, game.getGameState(), game.getModifiersQuerying(), Culture.ROHAN, CardType.POSSESSION);
action.insertEffect(
new PlayAnyNumberOfCardsFromDeckEffect(action, playerId, cards));
new PlayAnyNumberOfCardsFromDeckEffect(action, playerId, rohanPossessions));
}
});
action.appendEffect(

View File

@@ -57,6 +57,11 @@ public class Card9_016 extends AbstractCompanion {
action.appendEffect(
new OptionalEffect(action, playerId,
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, self) {
@Override
public String getText(LotroGame game) {
return "Exert Glorfindel to make a Nazgul he is skirmishing strength -X";
}
@Override
protected void forEachCardExertedCallback(PhysicalCard character) {
action.appendEffect(

View File

@@ -4,6 +4,7 @@ import com.gempukku.lotro.collection.CollectionSerializer;
import com.gempukku.lotro.db.vo.Player;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.MutableCardCollection;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -15,32 +16,28 @@ import java.util.concurrent.ConcurrentHashMap;
public class CollectionDAO {
private DbAccess _dbAccess;
private CardCollection _defaultCollection;
private CollectionSerializer _collectionSerializer;
private Map<Integer, Map<String, CardCollection>> _collections = new ConcurrentHashMap<Integer, Map<String, CardCollection>>();
private Map<Integer, Map<String, MutableCardCollection>> _collections = new ConcurrentHashMap<Integer, Map<String, MutableCardCollection>>();
public CollectionDAO(DbAccess dbAccess, LotroCardBlueprintLibrary library, CardCollection defaultCollection) {
public CollectionDAO(DbAccess dbAccess, LotroCardBlueprintLibrary library) {
_dbAccess = dbAccess;
_defaultCollection = defaultCollection;
_collectionSerializer = new CollectionSerializer(library);
}
public CardCollection getCollectionForPlayer(Player player, String type) {
if (type == null || type.equals("default"))
return _defaultCollection;
Map<String, CardCollection> playerCollections = _collections.get(player.getId());
public MutableCardCollection getCollectionForPlayer(Player player, String type) {
Map<String, MutableCardCollection> playerCollections = _collections.get(player.getId());
if (playerCollections != null) {
CardCollection collection = playerCollections.get(type);
MutableCardCollection collection = playerCollections.get(type);
if (collection != null)
return collection;
}
CardCollection collection = getCollectionFromDB(player, type);
MutableCardCollection collection = getCollectionFromDB(player, type);
if (collection != null) {
Map<String, CardCollection> collectionsByType = _collections.get(player.getId());
Map<String, MutableCardCollection> collectionsByType = _collections.get(player.getId());
if (collectionsByType == null) {
collectionsByType = new ConcurrentHashMap<String, CardCollection>();
collectionsByType = new ConcurrentHashMap<String, MutableCardCollection>();
_collections.put(player.getId(), collectionsByType);
}
collectionsByType.put(type, collection);
@@ -49,7 +46,7 @@ public class CollectionDAO {
return null;
}
private CardCollection getCollectionFromDB(Player player, String type) {
private MutableCardCollection getCollectionFromDB(Player player, String type) {
try {
Connection connection = _dbAccess.getDataSource().getConnection();
try {
@@ -90,12 +87,12 @@ public class CollectionDAO {
}
}
public void setCollectionForPlayer(Player player, String type, CardCollection collection) {
public void setCollectionForPlayer(Player player, String type, MutableCardCollection collection) {
if (!type.equals("default")) {
storeCollectionToDB(player, type, collection);
Map<String, CardCollection> collectionsByType = _collections.get(player.getId());
Map<String, MutableCardCollection> collectionsByType = _collections.get(player.getId());
if (collectionsByType == null) {
collectionsByType = new ConcurrentHashMap<String, CardCollection>();
collectionsByType = new ConcurrentHashMap<String, MutableCardCollection>();
_collections.put(player.getId(), collectionsByType);
}
collectionsByType.put(type, collection);

View File

@@ -1,5 +1,6 @@
package com.gempukku.lotro.game;
import com.gempukku.lotro.cards.packs.PackBox;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
@@ -114,7 +115,10 @@ public class DefaultCardCollection implements MutableCardCollection {
public void addCards(String blueprintId, LotroCardBlueprint blueprint, int count) {
if (blueprint == null)
throw new IllegalArgumentException("blueprint == null");
_counts.put(blueprintId, count);
Integer oldCount = _counts.get(blueprintId);
if (oldCount == null)
oldCount = 0;
_counts.put(blueprintId, oldCount + count);
_cards.put(blueprintId, blueprint);
}
@@ -123,6 +127,29 @@ public class DefaultCardCollection implements MutableCardCollection {
_counts.put(packId, count);
}
@Override
public synchronized List<Item> openPack(String packId, PackBox packBox, LotroCardBlueprintLibrary library) {
Integer count = _counts.get(packId);
if (count == null)
return null;
if (count > 0) {
List<String> packContents = packBox.openPack(packId);
if (packContents == null)
return null;
List<Item> result = new LinkedList<Item>();
for (String cardFromPack : packContents) {
LotroCardBlueprint cardBlueprint = library.getLotroCardBlueprint(cardFromPack);
addCards(cardFromPack, cardBlueprint, 1);
result.add(new Item(Item.Type.CARD, 1, cardFromPack, cardBlueprint));
}
_counts.put(packId, count - 1);
return result;
}
return null;
}
@Override
public Map<String, Integer> getAll() {
return Collections.unmodifiableMap(_counts);

View File

@@ -1,7 +1,13 @@
package com.gempukku.lotro.game;
import com.gempukku.lotro.cards.packs.PackBox;
import java.util.List;
public interface MutableCardCollection extends CardCollection {
public void addCards(String blueprintId, LotroCardBlueprint blueprint, int count);
public void addPacks(String packId, int count);
public List<Item> openPack(String packId, PackBox packBox, LotroCardBlueprintLibrary library);
}

View File

@@ -68,7 +68,7 @@ public class ServerResource {
_lotroServer = new LotroServer(dbAccess, _library, _chatServer, _test);
_lotroServer.startServer();
_collectionDao = new CollectionDAO(dbAccess, _library, _lotroServer.getDefaultCollection());
_collectionDao = new CollectionDAO(dbAccess, _library);
_leagueService = new LeagueService(dbAccess, _collectionDao, _library);
@@ -537,10 +537,14 @@ public class ServerResource {
if (!_test)
participantId = getLoggedUser(request);
Player player = _lotroServer.getPlayerDao().getPlayer(participantId);
CardCollection collection = _collectionDao.getCollectionForPlayer(player, collectionType);
CardCollection collection;
if (collectionType.equals("default"))
collection = _lotroServer.getDefaultCollection();
else {
collection = _collectionDao.getCollectionForPlayer(player, collectionType);
}
if (collection == null)
sendError(Response.Status.NOT_FOUND);
@@ -580,6 +584,56 @@ public class ServerResource {
return doc;
}
@Path("/collection/{collectionType}")
@POST
@Produces(MediaType.APPLICATION_XML)
public Document openPack(
@PathParam("collectionType") String collectionType,
@FormParam("participantId") String participantId,
@FormParam("pack") String packId,
@Context HttpServletRequest request) throws ParserConfigurationException {
if (!_test)
participantId = getLoggedUser(request);
Player player = _lotroServer.getPlayerDao().getPlayer(participantId);
MutableCardCollection collection = _collectionDao.getCollectionForPlayer(player, collectionType);
if (collection == null)
sendError(Response.Status.NOT_FOUND);
List<CardCollection.Item> packContents = collection.openPack(packId, null, null);
if (packContents == null)
sendError(Response.Status.NOT_FOUND);
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document doc = documentBuilder.newDocument();
Element collectionElem = doc.createElement("pack");
doc.appendChild(collectionElem);
for (CardCollection.Item item : packContents) {
String blueprintId = item.getBlueprintId();
if (item.getType() == CardCollection.Item.Type.CARD) {
Element card = doc.createElement("card");
card.setAttribute("count", String.valueOf(item.getCount()));
card.setAttribute("blueprintId", blueprintId);
Side side = item.getCardBlueprint().getSide();
if (side != null)
card.setAttribute("side", side.toString());
collectionElem.appendChild(card);
} else {
Element pack = doc.createElement("pack");
pack.setAttribute("count", String.valueOf(item.getCount()));
pack.setAttribute("blueprintId", blueprintId);
collectionElem.appendChild(pack);
}
}
return doc;
}
@Path("/chat/{room}")
@GET
@Produces(MediaType.APPLICATION_XML)

View File

@@ -5,6 +5,7 @@
- "Blood Runs Chill" now makes opponent to choose the shadow cards to discard.
- "Eowyn, Lady of Ithilien" now makes opponent to wound minions.
- "Three Monstrous Trolls" no longer freezes game, when systems adds twilight (for example for moving).
- "Eomer, Keeper of Oaths" can play only ROHAN possessions from those revelead, rather than any cards.
<b>20 Nov. 2011</b>
- "Sauron" no longer has his twilight cost reduced by the twilight pool size, instead of burdens spotted.