League packs and stuff.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package com.gempukku.lotro.packs;
|
||||
|
||||
import com.gempukku.lotro.cards.packs.RarityReader;
|
||||
import com.gempukku.lotro.cards.packs.SetRarity;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class RarityPackBox implements PackBox {
|
||||
private Random _random = new Random();
|
||||
private LotroCardBlueprintLibrary _library;
|
||||
private SetRarity _setRarity;
|
||||
|
||||
public RarityPackBox(LotroCardBlueprintLibrary library, int setNo) {
|
||||
_library = library;
|
||||
|
||||
RarityReader rarityReader = new RarityReader();
|
||||
_setRarity = rarityReader.getSetRarity(String.valueOf(setNo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CardCollection.Item> openPack() {
|
||||
List<CardCollection.Item> result = new LinkedList<CardCollection.Item>();
|
||||
boolean hasFoil = (_random.nextInt(6) == 0);
|
||||
if (hasFoil) {
|
||||
int foilRarity = _random.nextInt(11);
|
||||
if (foilRarity == 0) {
|
||||
List<String> possibleCards = new LinkedList<String>();
|
||||
possibleCards.addAll(_setRarity.getCardsOfRarity("R"));
|
||||
possibleCards.addAll(_setRarity.getCardsOfRarity("P"));
|
||||
Collections.shuffle(possibleCards, _random);
|
||||
addCards(result, possibleCards.subList(0, 1), true);
|
||||
} else if (foilRarity < 4) {
|
||||
List<String> possibleCards = new LinkedList<String>(_setRarity.getCardsOfRarity("U"));
|
||||
Collections.shuffle(possibleCards, _random);
|
||||
addCards(result, possibleCards.subList(0, 1), true);
|
||||
} else {
|
||||
List<String> possibleCards = new LinkedList<String>(_setRarity.getCardsOfRarity("C"));
|
||||
Collections.shuffle(possibleCards, _random);
|
||||
addCards(result, possibleCards.subList(0, 1), true);
|
||||
}
|
||||
}
|
||||
addRandomCardsOfRarity(result, 1, "R");
|
||||
addRandomCardsOfRarity(result, 3, "U");
|
||||
addRandomCardsOfRarity(result, hasFoil ? 6 : 7, "C");
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addRandomCardsOfRarity(List<CardCollection.Item> result, int count, String rarity) {
|
||||
List<String> possibleRares = new LinkedList<String>(_setRarity.getCardsOfRarity(rarity));
|
||||
Collections.shuffle(possibleRares, _random);
|
||||
addCards(result, possibleRares.subList(0, count), false);
|
||||
}
|
||||
|
||||
private void addCards(List<CardCollection.Item> result, Collection<String> cards, boolean foil) {
|
||||
for (String card : cards) {
|
||||
card = card.replace("P", "_");
|
||||
card = card.replace("R", "_");
|
||||
card = card.replace("U", "_");
|
||||
card = card.replace("C", "_");
|
||||
result.add(new CardCollection.Item(CardCollection.Item.Type.CARD, 1, card + (foil ? "*" : ""), _library.getLotroCardBlueprint(card)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
import com.gempukku.lotro.packs.FixedPackBox;
|
||||
import com.gempukku.lotro.packs.LeagueStarterBox;
|
||||
import com.gempukku.lotro.packs.PacksStorage;
|
||||
import com.gempukku.lotro.packs.RarityPackBox;
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -92,6 +93,7 @@ public class ServerResource {
|
||||
_packStorage.addPackBox("FotR - League Starter", new LeagueStarterBox());
|
||||
_packStorage.addPackBox("FotR - Gandalf Starter", new FixedPackBox(_library, "FotR - Gandalf Starter"));
|
||||
_packStorage.addPackBox("FotR - Aragorn Starter", new FixedPackBox(_library, "FotR - Aragorn Starter"));
|
||||
_packStorage.addPackBox("FotR - Booster", new RarityPackBox(_library, 1));
|
||||
|
||||
} catch (IOException exp) {
|
||||
_logger.error("Error while creating resource", exp);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 121 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
@@ -86,8 +86,14 @@ var Card = Class.extend({
|
||||
},
|
||||
|
||||
getUrlByBlueprintId: function(blueprintId) {
|
||||
if (blueprintId == "Fellowship of the Ring - League")
|
||||
return "/gemp-lotr/images/boosters/fotr_booster.jpg";
|
||||
if (blueprintId == "FotR - League Starter")
|
||||
return "/gemp-lotr/images/boosters/fotr_league_starter.png";
|
||||
else if (blueprintId == "FotR - Gandalf Starter")
|
||||
return "/gemp-lotr/images/boosters/fotr_gandalf_starter.png";
|
||||
else if (blueprintId == "FotR - Aragorn Starter")
|
||||
return "/gemp-lotr/images/boosters/fotr_aragorn_starter.png";
|
||||
else if (blueprintId == "FotR - Booster")
|
||||
return "/gemp-lotr/images/boosters/fotr_booster.png";
|
||||
|
||||
var separator = blueprintId.indexOf("_");
|
||||
var setNo = parseInt(blueprintId.substr(0, separator));
|
||||
|
||||
Reference in New Issue
Block a user