diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java index 9fa6c433d2e..8a04b6148e9 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java @@ -22,12 +22,9 @@ import java.text.CharacterIterator; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Random; import javax.swing.ImageIcon; - import mage.ObjectColor; import mage.cards.FrameStyle; -import mage.client.cards.Permanent; import mage.client.dialog.PreferencesDialog; import mage.constants.CardType; import mage.view.CardView; @@ -221,7 +218,7 @@ public class ModernCardRenderer extends CardRenderer { BOX_HEIGHT_FRAC * cardHeight); // Type line at - typeLineY = (int)(getTypeLineYFrac() * cardHeight); + typeLineY = (int) (getTypeLineYFrac() * cardHeight); // Box text height boxTextHeight = getTextHeightForBoxHeight(boxHeight); @@ -230,8 +227,7 @@ public class ModernCardRenderer extends CardRenderer { //boxTextFont = BASE_BELEREN_FONT.deriveFont(Font.PLAIN, boxTextHeight); boxTextFont = new Font("Arial", Font.PLAIN, boxTextHeight); boxTextFontNarrow = new Font("Arial Narrow", Font.PLAIN, boxTextHeight); - - + // Box text height ptTextHeight = getPTTextHeightForLineHeight(boxHeight); ptTextOffset = (boxHeight - ptTextHeight) / 2; @@ -254,11 +250,11 @@ public class ModernCardRenderer extends CardRenderer { } else { borderColor = Color.BLACK; } - + // Draw border as one rounded rectangle g.setColor(borderColor); g.fillRoundRect(0, 0, cardWidth, cardHeight, cornerRadius, cornerRadius); - + /* // Separate selection highlight border from card itself. Not used right now if (borderColor != null) { float hwidth = borderWidth / 2.0f; @@ -273,7 +269,7 @@ public class ModernCardRenderer extends CardRenderer { g2.draw(rect); g2.dispose(); } - */ + */ } @Override @@ -308,6 +304,7 @@ public class ModernCardRenderer extends CardRenderer { /** * Get the region to slice out of a source art image for the card + * * @return */ private Rectangle2D getArtRect() { @@ -334,9 +331,9 @@ public class ModernCardRenderer extends CardRenderer { protected boolean isSourceArtFullArt() { int color = artImage.getRGB(0, artImage.getHeight() / 2); - return (((color & 0x00FF0000) > 0x00200000) || - ((color & 0x0000FF00) > 0x00002000) || - ((color & 0x000000FF) > 0x00000020)); + return (((color & 0x00FF0000) > 0x00200000) + || ((color & 0x0000FF00) > 0x00002000) + || ((color & 0x000000FF) > 0x00000020)); } private boolean useInventionFrame() { @@ -365,24 +362,22 @@ public class ModernCardRenderer extends CardRenderer { double targetAspect = targetWidth / targetHeight; if (useInventionFrame()) { // No adjustment to art + } else if (targetAspect * artHeight < artWidth) { + // Trim off some width + artWidth = targetAspect * artHeight; } else { - if (targetAspect * artHeight < artWidth) { - // Trim off some width - artWidth = targetAspect * artHeight; - } else { - // Trim off some height - artHeight = artWidth / targetAspect; - } + // Trim off some height + artHeight = artWidth / targetAspect; } try { BufferedImage subImg = artImage.getSubimage( - (int) (artRect.getX() * fullCardImgWidth), (int) (artRect.getY() * fullCardImgHeight), - (int) artWidth, (int) artHeight); + (int) (artRect.getX() * fullCardImgWidth), (int) (artRect.getY() * fullCardImgHeight), + (int) artWidth, (int) artHeight); if (useInventionFrame()) { g.drawImage(subImg, borderWidth, borderWidth, - cardWidth - 2*borderWidth, cardHeight - 2*borderWidth, + cardWidth - 2 * borderWidth, cardHeight - 2 * borderWidth, null); } else { g.drawImage(subImg, @@ -727,6 +722,7 @@ public class ModernCardRenderer extends CardRenderer { protected boolean loyaltyAbilityColorToggle = false; private class RuleLayout { + public List attributedRules; public int remainingHeight; public boolean fits; @@ -735,7 +731,8 @@ public class ModernCardRenderer extends CardRenderer { } /** - * Figure out if a given text size will work for laying out the rules in a card textbox + * Figure out if a given text size will work for laying out the rules in a + * card textbox */ protected RuleLayout layoutRules(Graphics2D g, List rules, int w, int h, int fontSize) { // The fonts to try @@ -749,7 +746,7 @@ public class ModernCardRenderer extends CardRenderer { for (TextboxRule rule : rules) { AttributedString attributed = rule.generateAttributedString(font, fontItalic); attributedRules.add(attributed); - remaining -= drawSingleRule(g, attributed, rule, 0, 0, w, remaining, /*doDraw=*/false); + remaining -= drawSingleRule(g, attributed, rule, 0, 0, w, remaining, /*doDraw=*/ false); if (remaining < 0) { fits = false; break; @@ -779,13 +776,13 @@ public class ModernCardRenderer extends CardRenderer { // Basic mana draw mana symbol in textbox (for basic lands) if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.getCardTypes().contains(CardType.LAND)) { - drawBasicManaTextbox(g, x, y, w, h, ((TextboxBasicManaRule)allRules.get(0)).getBasicManaSymbol()); + drawBasicManaTextbox(g, x, y, w, h, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol()); return; } // Go through possible font sizes in descending order to find the best fit RuleLayout bestLayout = null; - for (int fontSize: RULES_TEXT_FONT_SIZES) { + for (int fontSize : RULES_TEXT_FONT_SIZES) { bestLayout = layoutRules(g, allRules, w, h, fontSize); // Stop, we found a good fit @@ -803,7 +800,7 @@ public class ModernCardRenderer extends CardRenderer { // If so, calculate the padding based on how much space was left over int padding; if (bestLayout.fits) { - padding = (int) (((float)bestLayout.remainingHeight) / (1 + allRules.size())); + padding = (int) (((float) bestLayout.remainingHeight) / (1 + allRules.size())); } else { // When the text doesn't fit to begin with there's no room for padding padding = 0; @@ -828,9 +825,9 @@ public class ModernCardRenderer extends CardRenderer { // Draw a basic mana symbol private void drawBasicManaTextbox(Graphics2D g, int x, int y, int w, int h, String symbol) { String symbs = symbol; - int symbHeight = (int)(0.8*h); + int symbHeight = (int) (0.8 * h); int manaCostWidth = CardRendererUtils.getManaCostWidth(symbs, symbHeight); - ManaSymbols.draw(g, symbs, x + (w - manaCostWidth)/2, y + (h - symbHeight)/2, symbHeight); + ManaSymbols.draw(g, symbs, x + (w - manaCostWidth) / 2, y + (h - symbHeight) / 2, symbHeight); } // Get the first line of the textbox, the keyword string @@ -1205,12 +1202,10 @@ public class ModernCardRenderer extends CardRenderer { 0, 0, width, 0, new float[]{0.4f, 0.6f}, translatedColors); + } else if (types.contains(CardType.LAND)) { + return LAND_TEXTBOX_GOLD; } else { - if (types.contains(CardType.LAND)) { - return LAND_TEXTBOX_GOLD; - } else { - return TEXTBOX_GOLD; - } + return TEXTBOX_GOLD; } } else if (colors.isColorless()) { if (types.contains(CardType.LAND)) { @@ -1218,12 +1213,10 @@ public class ModernCardRenderer extends CardRenderer { } else { return TEXTBOX_COLORLESS; } + } else if (types.contains(CardType.LAND)) { + return getLandTextboxColor(colors); } else { - if (types.contains(CardType.LAND)) { - return getLandTextboxColor(colors); - } else { - return getTextboxColor(colors); - } + return getTextboxColor(colors); } } } diff --git a/Mage/src/main/java/mage/cards/ExpansionSet.java b/Mage/src/main/java/mage/cards/ExpansionSet.java index 26e3ddb4fdc..37f3e84e4ed 100644 --- a/Mage/src/main/java/mage/cards/ExpansionSet.java +++ b/Mage/src/main/java/mage/cards/ExpansionSet.java @@ -120,10 +120,12 @@ public abstract class ExpansionSet implements Serializable { // since it adds lands then commons before uncommons // and rares this should be the least disruptive. List theBooster = this.createBooster(); - List commons = getCardsByRarity(Rarity.COMMON); - while (15 > theBooster.size()) { - addToBooster(theBooster, commons); + if (15 > theBooster.size()) { + List commons = getCardsByRarity(Rarity.COMMON); + while (15 > theBooster.size()) { + addToBooster(theBooster, commons); + } } while (theBooster.size() > 15) { @@ -235,6 +237,7 @@ public abstract class ExpansionSet implements Serializable { * Can be overwritten to add a replacement for common card in boosters * * @param booster + * @param number */ public void addSpecialCommon(List booster, int number) { @@ -329,9 +332,6 @@ public abstract class ExpansionSet implements Serializable { if (numBoosterDoubleFaced > -1) { criteria.doubleFaced(false); } -// if (maxCardNumberInBooster != Integer.MAX_VALUE) { -// criteria.maxCardNumber(maxCardNumberInBooster); -// } savedCardsInfos = CardRepository.instance.findCards(criteria); // Workaround after card number is numeric if (maxCardNumberInBooster != Integer.MAX_VALUE) { diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/AnotherEnchantedPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/AnotherEnchantedPredicate.java new file mode 100644 index 00000000000..956e595f774 --- /dev/null +++ b/Mage/src/main/java/mage/filter/predicate/permanent/AnotherEnchantedPredicate.java @@ -0,0 +1,30 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.filter.predicate.permanent; + +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * Filters out the id of the enchanted object, if the source is an enchantment + * + * @author LevelX2 + */ +public class AnotherEnchantedPredicate implements ObjectSourcePlayerPredicate> { + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + Permanent enchantment = game.getPermanentOrLKIBattlefield(input.getSourceId()); + return enchantment != null && !input.getObject().getId().equals(enchantment.getAttachedTo()); + } + + @Override + public String toString() { + return "Another enchanted"; + } +}