Adding permanent collections.
This commit is contained in:
@@ -147,20 +147,16 @@ public class AdminResource extends AbstractResource {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
@Path("/addLeaguePrize")
|
||||
@Path("/addItems")
|
||||
@POST
|
||||
public String addLeaguePrize(
|
||||
@FormParam("leagueType") String leagueType,
|
||||
public String addItems(
|
||||
@FormParam("collectionType") String collectionType,
|
||||
@FormParam("packProduct") String packProduct,
|
||||
@FormParam("cardProduct") String cardProduct,
|
||||
@FormParam("players") String players,
|
||||
@Context HttpServletRequest request) throws Exception {
|
||||
validateAdmin(request);
|
||||
|
||||
League league = getLeagueByType(leagueType);
|
||||
if (league == null)
|
||||
throw new WebApplicationException(Response.Status.NOT_FOUND);
|
||||
|
||||
List<CardCollection.Item> items = new LinkedList<CardCollection.Item>();
|
||||
|
||||
List<String> packs = getItems(packProduct);
|
||||
@@ -175,18 +171,26 @@ public class AdminResource extends AbstractResource {
|
||||
|
||||
for (String playerName : playerNames) {
|
||||
Player player = _playerDao.getPlayer(playerName);
|
||||
MutableCardCollection collection = _collectionDao.getCollectionForPlayer(player, leagueType);
|
||||
|
||||
MutableCardCollection collection = getPlayerCollection(player, collectionType);
|
||||
for (String pack : packs)
|
||||
collection.addPacks(pack, 1);
|
||||
for (String card : cards)
|
||||
collection.addCards(card, 1);
|
||||
_collectionDao.setCollectionForPlayer(player, leagueType, collection);
|
||||
_deliveryService.addPackage(player, leagueType, items);
|
||||
_collectionDao.setCollectionForPlayer(player, collectionType, collection);
|
||||
_deliveryService.addPackage(player, collectionType, items);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private MutableCardCollection getPlayerCollection(Player player, String collectionType) {
|
||||
MutableCardCollection collection = _collectionDao.getCollectionForPlayer(player, collectionType);
|
||||
if (collection == null && collectionType.equals("permanent"))
|
||||
collection = new DefaultCardCollection();
|
||||
return collection;
|
||||
}
|
||||
|
||||
private List<String> getItems(String values) {
|
||||
List<String> result = new LinkedList<String>();
|
||||
for (String pack : values.split("\n")) {
|
||||
|
||||
@@ -122,9 +122,11 @@ public class CollectionResource extends AbstractResource {
|
||||
CardCollection collection = null;
|
||||
if (collectionType.equals("default"))
|
||||
collection = _lotroServer.getDefaultCollection();
|
||||
else if (collectionType.equals("permanent"))
|
||||
else if (collectionType.equals("permanent")) {
|
||||
collection = _collectionDao.getCollectionForPlayer(player, "permanent");
|
||||
else {
|
||||
if (collection == null)
|
||||
collection = new DefaultCardCollection();
|
||||
} else {
|
||||
League league = _leagueService.getLeagueByType(collectionType);
|
||||
if (league != null)
|
||||
collection = _leagueService.getLeagueCollection(player, league);
|
||||
|
||||
@@ -46,14 +46,16 @@
|
||||
<input type="submit" value="Add product">
|
||||
</form>
|
||||
|
||||
<h2>Add league prize</h2>
|
||||
<h1>Collections</h1>
|
||||
|
||||
<form method="POST" action="server/admin/addLeaguePrize">
|
||||
Type: <input type="text" name="leagueType"><br/>
|
||||
<h2>Add items</h2>
|
||||
|
||||
<form method="POST" action="server/admin/addItems">
|
||||
Type: <input type="text" name="collectionType"><br/>
|
||||
Packs: <textarea rows="5" cols="20" name="packProduct"></textarea><br/>
|
||||
Cards: <textarea rows="5" cols="20" name="cardProduct"></textarea><br/>
|
||||
Players: <textarea rows="5" cols="20" name="players"></textarea><br/>
|
||||
<input type="submit" value="Add prize">
|
||||
<input type="submit" value="Add items">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -50,6 +50,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
var collectionSelect = $("<select id='collectionSelect'></select>");
|
||||
collectionSelect.css({"float": "right", width: "180px"});
|
||||
collectionSelect.append("<option value='default'>All cards</option>");
|
||||
collectionSelect.append("<option value='permanent'>My cards</option>");
|
||||
this.manageDecksDiv.append(collectionSelect);
|
||||
|
||||
var newDeckBut = $("<button title='New deck'><span class='ui-icon ui-icon-document'></span></button>").button();
|
||||
|
||||
Reference in New Issue
Block a user