- Implemented foiling based on card edition-specific information about the availability and style of foil.

- Added the ability to differentiate between old-style and new-style (modern) foils. If a separate foil sheet called sprite_old_foils.png is available, that sheet will be used for pre-8th edition cards. If not available, the same sprite sheet (sprite_foils.png) will be used for all foils.
- Note that the edition files are not yet modified with the information about availability/style of foil cards. This has the nasty temporary side effect of disabling random foiling for all sets (to be remedied in the nearest future).
This commit is contained in:
Agetian
2013-06-30 16:05:01 +00:00
parent 3dac462afd
commit b90694142c
3 changed files with 63 additions and 10 deletions

View File

@@ -19,7 +19,9 @@ import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.GameLogEntryType;
import forge.Singletons;
import forge.card.CardDb;
import forge.card.CardEdition;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
import forge.deck.CardPool;
@@ -113,9 +115,9 @@ public class GameNew {
return myRemovedAnteCards;
}
private static void preparePlayerLibrary(Player player, final ZoneType zoneType, CardPool secion, boolean canRandomFoil, Random generator) {
private static void preparePlayerLibrary(Player player, final ZoneType zoneType, CardPool section, boolean canRandomFoil, Random generator) {
PlayerZone library = player.getZone(zoneType);
for (final Entry<PaperCard, Integer> stackOfCards : secion) {
for (final Entry<PaperCard, Integer> stackOfCards : section) {
final PaperCard cp = stackOfCards.getKey();
for (int i = 0; i < stackOfCards.getValue(); i++) {
@@ -129,9 +131,22 @@ public class GameNew {
final Card card = cpi.toForgeCard(player);
// Assign random foiling on approximately 1:20 cards
if (cp.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
final int iFoil = generator.nextInt(9) + 1;
// Assign card-specific foiling or random foiling on approximately 1:20 cards if enabled
CardEdition.FoilType foilType = Singletons.getModel().getEditions().get(card.getCurSetCode()).getFoilType();
if (foilType != CardEdition.FoilType.NOT_SUPPORTED && (cp.isFoil() || (canRandomFoil && MyRandom.percentTrue(5)))) {
int iFoil = 0;
switch(foilType) {
case MODERN:
iFoil = generator.nextInt(9) + 1; // modern foils in slots 1-10
break;
case OLD_STYLE:
iFoil = generator.nextInt(9) + 11; // old style foils in slots 11-20
break;
default:
System.out.println(String.format("Unexpected foil type for card %s in edition %s.", card.getName(), card.getCurSetCode()));
}
card.setFoil(iFoil);
}

View File

@@ -116,6 +116,17 @@ public class CardFaceSymbols {
MANA_IMAGES.put("foil08", FSkin.getImage(FSkin.Foils.FOIL_08));
MANA_IMAGES.put("foil09", FSkin.getImage(FSkin.Foils.FOIL_09));
MANA_IMAGES.put("foil10", FSkin.getImage(FSkin.Foils.FOIL_10));
MANA_IMAGES.put("foil11", FSkin.getImage(FSkin.OldFoils.FOIL_11));
MANA_IMAGES.put("foil12", FSkin.getImage(FSkin.OldFoils.FOIL_12));
MANA_IMAGES.put("foil13", FSkin.getImage(FSkin.OldFoils.FOIL_13));
MANA_IMAGES.put("foil14", FSkin.getImage(FSkin.OldFoils.FOIL_14));
MANA_IMAGES.put("foil15", FSkin.getImage(FSkin.OldFoils.FOIL_15));
MANA_IMAGES.put("foil16", FSkin.getImage(FSkin.OldFoils.FOIL_16));
MANA_IMAGES.put("foil17", FSkin.getImage(FSkin.OldFoils.FOIL_17));
MANA_IMAGES.put("foil18", FSkin.getImage(FSkin.OldFoils.FOIL_18));
MANA_IMAGES.put("foil19", FSkin.getImage(FSkin.OldFoils.FOIL_19));
MANA_IMAGES.put("foil20", FSkin.getImage(FSkin.OldFoils.FOIL_20));
}
/**

View File

@@ -208,7 +208,7 @@ public enum FSkin {
FOIL_07 (new int[] {0, 1710, 400, 570}), /** */
FOIL_08 (new int[] {400, 1710, 400, 570}), /** */
FOIL_09 (new int[] {0, 2280, 400, 570}), /** */
FOIL_10 (new int[] {400, 2280, 400, 570});
FOIL_10 (new int[] {400, 2280, 400, 570}); /** */
private int[] coords;
/** @param xy &emsp; int[] coordinates */
@@ -218,6 +218,26 @@ public enum FSkin {
public int[] getCoords() { return coords; }
}
public enum OldFoils implements SkinProp { /** */
FOIL_11 (new int[] {0, 0, 400, 570}), /** */
FOIL_12 (new int[] {400, 0, 400, 570}), /** */
FOIL_13 (new int[] {0, 570, 400, 570}), /** */
FOIL_14 (new int[] {400, 570, 400, 570}), /** */
FOIL_15 (new int[] {0, 1140, 400, 570}), /** */
FOIL_16 (new int[] {400, 1140, 400, 570}), /** */
FOIL_17 (new int[] {0, 1710, 400, 570}), /** */
FOIL_18 (new int[] {400, 1710, 400, 570}), /** */
FOIL_19 (new int[] {0, 2280, 400, 570}), /** */
FOIL_20 (new int[] {400, 2280, 400, 570}); /** */
private int[] coords;
/** @param xy &emsp; int[] coordinates */
OldFoils(final int[] xy) { this.coords = xy; }
/** @return int[] */
@Override
public int[] getCoords() { return coords; }
}
/** */
public enum DockIcons implements SkinProp { /** */
ICO_SHORTCUTS (new int[] {160, 640, 80, 80}), /** */
@@ -395,6 +415,7 @@ public enum FSkin {
FILE_SKINS_DIR = "res/skins/",
FILE_ICON_SPRITE = "sprite_icons.png",
FILE_FOIL_SPRITE = "sprite_foils.png",
FILE_OLD_FOIL_SPRITE = "sprite_old_foils.png",
FILE_AVATAR_SPRITE = "sprite_avatars.png",
FILE_FONT = "font1.ttf",
FILE_SPLASH = "bg_splash.png",
@@ -406,7 +427,7 @@ public enum FSkin {
private static String preferredName;
private static Font font;
private static BufferedImage bimDefaultSprite, bimPreferredSprite, bimFoils,
bimDefaultAvatars, bimPreferredAvatars;
bimOldFoils, bimDefaultAvatars, bimPreferredAvatars;
private static int x0, y0, w0, h0, newW, newH, preferredW, preferredH;
private static int[] tempCoords;
@@ -518,6 +539,7 @@ public enum FSkin {
final File f3 = new File(DEFAULT_DIR + FILE_FOIL_SPRITE);
final File f4 = new File(DEFAULT_DIR + FILE_AVATAR_SPRITE);
final File f5 = new File(preferredDir + FILE_AVATAR_SPRITE);
final File f6 = new File(DEFAULT_DIR + FILE_OLD_FOIL_SPRITE);
try {
bimDefaultSprite = ImageIO.read(f1);
@@ -526,6 +548,8 @@ public enum FSkin {
barProgress.increment();
bimFoils = ImageIO.read(f3);
barProgress.increment();
bimOldFoils = f6.exists() ? ImageIO.read(f6) : ImageIO.read(f3);
barProgress.increment();
bimDefaultAvatars = ImageIO.read(f4);
if (f5.exists()) { bimPreferredAvatars = ImageIO.read(f5); }
@@ -571,7 +595,8 @@ public enum FSkin {
for (final LayoutImages e : LayoutImages.values()) { FSkin.setImage(e); }
// Foils have a separate sprite, so uses a specific method.
for (final Foils e : Foils.values()) { FSkin.setFoil(e); }
for (final Foils e : Foils.values()) { FSkin.setFoil(e, false); }
for (final OldFoils e : OldFoils.values()) { FSkin.setFoil(e, true); }
// Assemble avatar images
FSkin.assembleAvatars();
@@ -585,6 +610,7 @@ public enum FSkin {
// Clear references to buffered images
FSkin.bimDefaultSprite.flush();
FSkin.bimFoils.flush();
FSkin.bimOldFoils.flush();
FSkin.bimPreferredSprite.flush();
FSkin.bimDefaultAvatars.flush();
@@ -592,6 +618,7 @@ public enum FSkin {
FSkin.bimDefaultSprite = null;
FSkin.bimFoils = null;
FSkin.bimOldFoils = null;
FSkin.bimPreferredSprite = null;
FSkin.bimDefaultAvatars = null;
FSkin.bimPreferredAvatars = null;
@@ -867,14 +894,14 @@ public enum FSkin {
}
}
private static void setFoil(final SkinProp s0) {
private static void setFoil(final SkinProp s0, boolean isOldStyle) {
tempCoords = s0.getCoords();
x0 = tempCoords[0];
y0 = tempCoords[1];
w0 = tempCoords[2];
h0 = tempCoords[3];
FSkin.images.put(s0, bimFoils.getSubimage(x0, y0, w0, h0));
FSkin.images.put(s0, isOldStyle ? bimOldFoils.getSubimage(x0, y0, w0, h0) : bimFoils.getSubimage(x0, y0, w0, h0));
}
private static void setColor(final SkinProp s0) {