Forge version 1.5.13
Posted: 07 Feb 2014, 18:21
Tentative target release date: Friday February 21 2014.
High Quality Resources for Collectible Card Games and Home of the CCGHQ Team
https://www.slightlymagic.net/forum/
https://www.slightlymagic.net/forum/viewtopic.php?f=52&t=13672
private static final String getFoilSlot(SealedProduct.Template booster) {
String setCode = booster.getEdition() != null ? booster.getEdition() : null;
CardEdition set = setCode != null ? StaticData.instance().getEditions().getEditionByCodeOrThrow(setCode) : null;
if (set == null || set.getFoilType() == FoilType.NOT_SUPPORTED) {
return null;
}
if (MyRandom.getRandom().nextInt(100) <= StaticData.instance().getEditions().getEditionByCodeOrThrow(setCode).getFoilChanceInBooster()) {
if (set.getFoilAlwaysInCommonSlot()) {
return BoosterSlots.COMMON;
}
else {
return Aggregates.random(booster.getSlots()).getKey();
}
}
return null; // null == no foil is generated
}
private static final PaperCard generateFoilCard(SealedProduct.Template booster) {
String setCode = booster.getEdition() != null ? booster.getEdition() : null;
String sheetKey = StaticData.instance().getEditions().contains(setCode) ? BoosterSlots.ANY + " " + setCode : BoosterSlots.ANY;
PrintSheet ps = getPrintSheet(sheetKey);
return StaticData.instance().getCommonCards().getFoiled(ps.random(1, true).get(0));
}
public static final List<PaperCard> getBoosterPack(SealedProduct.Template booster) {
List<PaperCard> result = new ArrayList<PaperCard>();
String foilSlot = getFoilSlot(booster);
for(Pair<String, Integer> slot : booster.getSlots()) {
String slotType = slot.getLeft(); // add expansion symbol here?
int numCards = slot.getRight().intValue();
String[] sType = TextUtil.splitWithParenthesis(slotType, ' ');
String setCode = sType.length == 1 && booster.getEdition() != null ? booster.getEdition() : null;
String sheetKey = StaticData.instance().getEditions().contains(setCode) ? slotType.trim() + " " + setCode: slotType.trim();
if (foilSlot == null || !foilSlot.equals(slotType)) {
PrintSheet ps = getPrintSheet(sheetKey);
result.addAll(ps.random(numCards, true));
} else {
PrintSheet ps = getPrintSheet(sheetKey);
result.addAll(ps.random(numCards - 1, true));
result.add(generateFoilCard(booster));
}
}
return result;
}
I believe what Max is asking for is hooking up the code he just wrote to something that scripts hook into. (Probably in the form of a static ability or two)Agetian wrote:@ Max: I tried to add the "add replacement color" method, not sure if that's what was meant (seemed too simple to be true somehow :\ ), please check - if I did the wrong thing I can kill it.
I'll look into it.Agetian wrote:As of r24741, there's an issue with the display of foil overlay in CardManager, noticeable at least in sealed deck generation (probably it's universal, it's just easy to reproduce it by using sealed deck generation): if you generate a sealed deck and it's going to have a foil in it (or several foils), the foil overlay will not be displayed on the foil card until you hover the mouse over it (at which point it will switch the card to foil and then keep displaying its foil overlay correctly).
P.S. I added a property to turn the foil overlay display on and off.
- Agetian