Search in sources :

Example 31 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class RiptideReplicatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
    SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
    if (subType == null) {
        return false;
    }
    int x = (new CountersSourceCount(CounterType.CHARGE)).calculate(game, source, this);
    Token token = new RiptideReplicatorToken(color, subType, x);
    return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) RiptideReplicatorToken(mage.game.permanent.token.RiptideReplicatorToken) SubType(mage.constants.SubType) ObjectColor(mage.ObjectColor) RiptideReplicatorToken(mage.game.permanent.token.RiptideReplicatorToken) Token(mage.game.permanent.token.Token)

Example 32 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class SurgeOfZealEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (target != null) {
            ObjectColor color = target.getColor(game);
            for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
                if (permanent.getColor(game).shares(color)) {
                    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    game.addEffect(effect, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ObjectColor(mage.ObjectColor) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 33 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class BecomesColorOrColorsTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent target = game.getPermanent(source.getFirstTarget());
    StringBuilder sb = new StringBuilder();
    if (controller != null && target != null) {
        for (int i = 0; i < 5; i++) {
            if (i > 0) {
                if (!controller.chooseUse(Outcome.Neutral, "Choose another color?", source, game)) {
                    break;
                }
            }
            ChoiceColor choiceColor = new ChoiceColor();
            if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
                return false;
            }
            if (!game.isSimulation()) {
                game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + choiceColor.getChoice());
            }
            if (choiceColor.getColor().isBlack()) {
                sb.append('B');
            } else if (choiceColor.getColor().isBlue()) {
                sb.append('U');
            } else if (choiceColor.getColor().isRed()) {
                sb.append('R');
            } else if (choiceColor.getColor().isGreen()) {
                sb.append('G');
            } else if (choiceColor.getColor().isWhite()) {
                sb.append('W');
            }
        }
        String colors = new String(sb);
        ObjectColor chosenColors = new ObjectColor(colors);
        ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, duration);
        effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 34 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class ModernCardRenderer method getBorderPaint.

// Determine the border paint to use, based on an ObjectColors
protected static Paint getBorderPaint(ObjectColor colors, Collection<CardType> types, int width) {
    if (colors.isMulticolored()) {
        if (colors.getColorCount() == 2) {
            List<ObjectColor> twoColors = colors.getColors();
            // Two-color frames look better if we use a whiter white
            // than the normal white frame color for them, as the normal
            // white border color is very close to the gold background
            // color.
            Color color1, color2;
            if (twoColors.get(0).isWhite()) {
                color1 = new Color(240, 240, 240);
            } else {
                color1 = getBorderColor(twoColors.get(0));
            }
            if (twoColors.get(1).isWhite()) {
                color2 = new Color(240, 240, 240);
            } else {
                color2 = getBorderColor(twoColors.get(1));
            }
            // Special case for two colors, gradient paint
            return new LinearGradientPaint(0, 0, width, 0, new float[] { 0.4f, 0.6f }, new Color[] { color1, color2 });
        } else {
            return BORDER_GOLD;
        }
    } else if (colors.isColorless()) {
        if (types.contains(CardType.LAND)) {
            return BORDER_LAND;
        } else {
            return BORDER_COLORLESS;
        }
    } else {
        return getBorderColor(colors);
    }
}
Also used : ObjectColor(mage.ObjectColor) ObjectColor(mage.ObjectColor)

Example 35 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class ModernCardRenderer method drawFrame.

@Override
protected void drawFrame(Graphics2D g, CardPanelAttributes attribs, BufferedImage image, boolean lessOpaqueRulesTextBox) {
    // Get the card colors to base the frame on
    ObjectColor frameColors = getFrameObjectColor();
    // Get the border paint
    Color boxColor = getBoxColor(frameColors, cardView.getCardTypes(), attribs.isTransformed);
    Color additionalBoxColor = getAdditionalBoxColor(frameColors, cardView.getCardTypes(), attribs.isTransformed);
    Paint textboxPaint = getTextboxPaint(frameColors, cardView.getCardTypes(), cardWidth, lessOpaqueRulesTextBox);
    Paint borderPaint = getBorderPaint(frameColors, cardView.getCardTypes(), cardWidth);
    // Special colors
    if (cardView.getFrameStyle() == FrameStyle.KLD_INVENTION) {
        boxColor = BOX_INVENTION;
    }
    // Is this a Zendikar or Unstable land
    boolean isZenUst = isZendikarFullArtLand() || isUnstableFullArtLand();
    boolean isOriginalDual = isOriginalDualLand();
    // Draw the main card content border
    g.setPaint(borderPaint);
    if (cardView.getFrameStyle() == FrameStyle.KLD_INVENTION) {
        g.drawImage(FRAME_INVENTION, 3, 3, cardWidth - 6, cardHeight - 6, null);
        g.drawRect(totalContentInset, typeLineY, contentWidth - 1, cardHeight - borderWidth * 3 - typeLineY - 1);
    } else if (!isZenUst) {
        g.drawRect(totalContentInset, totalContentInset, contentWidth - 1, cardHeight - borderWidth * 3 - totalContentInset - 1);
    }
    // Draw the textbox fill
    if (useInventionFrame()) {
        g.setPaint(new Color(255, 255, 255, 150));
    } else {
        g.setPaint(textboxPaint);
    }
    if (!isZenUst) {
        if (cardView.getCardTypes().contains(CardType.LAND)) {
            int total_height_of_box = cardHeight - borderWidth * 3 - typeLineY - 2 - boxHeight;
            // Analysis of LEA Duals (Scrubland) gives 16.5 height of unit of 'spirals' in the text area
            int height_of_spiral = (int) Math.round(total_height_of_box / 16.5);
            int total_height_spiral = total_height_of_box;
            List<ObjectColor> twoColors = frameColors.getColors();
            if (twoColors.size() <= 2) {
                if (isOriginalDual && twoColors.size() == 2) {
                    g.setPaint(getSpiralLandTextboxColor(twoColors.get(0), twoColors.get(1), false));
                }
                g.fillRect(totalContentInset + 1, typeLineY + boxHeight + 1, contentWidth - 2, total_height_of_box);
            }
            if (frameColors.getColorCount() >= 3) {
                g.fillRect(totalContentInset + 1, typeLineY + boxHeight + 1, contentWidth - 2, total_height_of_box);
            }
            if (frameColors.getColorCount() == 2) {
                if (isOriginalDual) {
                    g.setPaint(getSpiralLandTextboxColor(twoColors.get(0), twoColors.get(1), true));
                    // Horizontal bars
                    g.fillRect(totalContentInset + 1, typeLineY + boxHeight + 1, contentWidth - 2, height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 2 * height_of_spiral, typeLineY + boxHeight + 1 + 2 * height_of_spiral, contentWidth - 2 - 4 * height_of_spiral, height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 4 * height_of_spiral, typeLineY + boxHeight + 1 + 4 * height_of_spiral, contentWidth - 2 - 8 * height_of_spiral, height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 6 * height_of_spiral, typeLineY + boxHeight + 1 + 6 * height_of_spiral, contentWidth - 2 - 12 * height_of_spiral, height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 6 * height_of_spiral, typeLineY + boxHeight + 1 + total_height_of_box - 7 * height_of_spiral, contentWidth - 2 - 12 * height_of_spiral, height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 4 * height_of_spiral, typeLineY + boxHeight + 1 + total_height_of_box - 5 * height_of_spiral, contentWidth - 2 - 8 * height_of_spiral, height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 2 * height_of_spiral, typeLineY + boxHeight + 1 + total_height_of_box - 3 * height_of_spiral, contentWidth - 2 - 4 * height_of_spiral, height_of_spiral);
                    g.fillRect(totalContentInset + 1, typeLineY + boxHeight + 1 + total_height_of_box - height_of_spiral, contentWidth - 2, height_of_spiral);
                    // Vertical bars
                    g.fillRect(totalContentInset + 1, typeLineY + boxHeight + 1, height_of_spiral, total_height_spiral - 1);
                    g.fillRect(totalContentInset + 1 + 2 * height_of_spiral, typeLineY + boxHeight + 1 + 2 * height_of_spiral, height_of_spiral, total_height_spiral - 1 - 4 * height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 4 * height_of_spiral, typeLineY + boxHeight + 1 + 4 * height_of_spiral, height_of_spiral, total_height_spiral - 1 - 8 * height_of_spiral);
                    g.fillRect(totalContentInset + 1 + 6 * height_of_spiral, typeLineY + boxHeight + 1 + 6 * height_of_spiral, height_of_spiral, total_height_spiral - 1 - 12 * height_of_spiral);
                    g.fillRect(totalContentInset + contentWidth - 7 * height_of_spiral, typeLineY + boxHeight + 1 + 6 * height_of_spiral, height_of_spiral, total_height_spiral - 1 - 12 * height_of_spiral);
                    g.fillRect(totalContentInset + contentWidth - 5 * height_of_spiral, typeLineY + boxHeight + 1 + 4 * height_of_spiral, height_of_spiral, total_height_spiral - 1 - 8 * height_of_spiral);
                    g.fillRect(totalContentInset + contentWidth - 3 * height_of_spiral, typeLineY + boxHeight + 1 + 2 * height_of_spiral, height_of_spiral, total_height_spiral - 1 - 4 * height_of_spiral);
                    g.fillRect(totalContentInset + contentWidth - 1 * height_of_spiral, typeLineY + boxHeight + 1 + 0 * height_of_spiral, height_of_spiral, total_height_spiral - 1);
                }
            }
        } else {
            g.fillRect(totalContentInset + 1, typeLineY, contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
        }
    }
    // If it's a planeswalker, extend the textbox left border by some
    if (cardView.isPlanesWalker()) {
        g.setPaint(borderPaint);
        g.fillRect(totalContentInset, typeLineY + boxHeight, cardWidth / 16, cardHeight - typeLineY - boxHeight - borderWidth * 3);
    }
    if (cardView.getFrameStyle() != FrameStyle.KLD_INVENTION && !isZenUst) {
        // Draw a shadow highlight at the right edge of the content frame
        g.setColor(new Color(0, 0, 0, 100));
        g.fillRect(totalContentInset - 1, totalContentInset, 1, cardHeight - borderWidth * 3 - totalContentInset - 1);
        // Draw a shadow highlight separating the card art and rest of frame
        g.drawRect(totalContentInset + 1, totalContentInset + boxHeight, contentWidth - 3, typeLineY - totalContentInset - boxHeight - 1);
    }
    // Draw the name line box
    CardRendererUtils.drawRoundedBox(g, borderWidth, totalContentInset, cardWidth - 2 * borderWidth, boxHeight, contentInset, borderPaint, boxColor);
    // Draw the type line box
    if (!isZenUst) {
        CardRendererUtils.drawRoundedBox(g, borderWidth, typeLineY, cardWidth - 2 * borderWidth, boxHeight, contentInset, borderPaint, boxColor);
        // Draw a small separator between the type line and box, and shadow
        // at the left of the texbox, and above the name line
        g.setColor(new Color(0, 0, 0, 150));
        g.fillRect(totalContentInset - 1, totalContentInset - 1, contentWidth + 1, 1);
        g.fillRect(totalContentInset + 1, typeLineY + boxHeight, contentWidth - 2, 1);
        g.fillRect(cardWidth - totalContentInset - 1, typeLineY + boxHeight, 1, cardHeight - borderWidth * 3 - typeLineY - boxHeight);
        // Draw the type line
        drawTypeLine(g, attribs, getCardTypeLine(), totalContentInset, typeLineY, contentWidth, boxHeight, true);
    }
    // Draw the transform circle
    int nameOffset = drawTransformationCircle(g, attribs, borderPaint);
    // Draw the name line
    drawNameLine(g, attribs, cardView.getDisplayName(), manaCostString, totalContentInset + nameOffset, totalContentInset, contentWidth - nameOffset, boxHeight);
    // Draw the textbox rules
    if (isZendikarFullArtLand()) {
        int x = totalContentInset;
        int y = typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset;
        int w = contentWidth;
        int h = boxHeight - 4;
        if (cardView.getFrameStyle() == FrameStyle.ZEN_FULL_ART_BASIC) {
            // Draw curved lines (old Zendikar land style) - bigger (around 6%) inset on curve on bottom than inset (around 4.5%) on top...
            int x2 = x + contentWidth;
            int y2 = y;
            int thisy = totalContentInset + boxHeight;
            drawZendikarCurvedFace(g, image, x, thisy, x2, y2, boxColor, borderPaint);
        } else if (cardView.getFrameStyle() == FrameStyle.BFZ_FULL_ART_BASIC) {
            // Draw curved lines (BFZ land style)
            int y2 = y;
            int yb = totalContentInset + boxHeight;
            int topxdelta = 45 * contentWidth / 1000;
            int endydelta = 60 * (totalContentInset + y2) / 265;
            int x2 = x + contentWidth;
            // Curve ends at 60 out of 265
            drawBFZCurvedFace(g, image, x, yb, x2, y2, topxdelta, endydelta, boxColor, borderPaint);
        }
        // If an expedition, needs the rules box to be visible.
        if (cardView.getExpansionSetCode().equals("EXP")) {
            // Draw a small separator between the type line and box, and shadow
            // at the left of the texbox, and above the name line
            g.setPaint(textboxPaint);
            float alpha = 0.55f;
            AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
            Composite origc = g.getComposite();
            g.setComposite(comp);
            g.setBackground(new Color(155, 0, 0, 150));
            g.fillRect(totalContentInset + 1, typeLineY - boxHeight, contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
            g.setComposite(origc);
            g.fillRect(totalContentInset - 1, totalContentInset - 1, contentWidth + 1, 1);
            g.fillRect(totalContentInset + 1, typeLineY - boxHeight, contentWidth - 2, 1);
            drawRulesText(g, textboxKeywords, textboxRules, totalContentInset + 2, typeLineY - boxHeight, contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3, true);
        }
        CardRendererUtils.drawZendikarLandBox(g, x, y, w, h, contentInset, borderPaint, boxColor);
        drawTypeLine(g, attribs, getCardSuperTypeLine(), totalContentInset + contentInset, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset, contentWidth / 2 - boxHeight, boxHeight - 4, false);
        drawTypeLine(g, attribs, getCardSubTypeLine(), totalContentInset + 4 * contentWidth / 7 + boxHeight, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset, 3 * contentWidth / 7 - boxHeight - contentInset, boxHeight - 4, true);
        drawRulesText(g, textboxKeywords, textboxRules, x, y, w, h, false);
    } else if (isUnstableFullArtLand()) {
        int x = 0;
        int y = 0;
        int w = cardWidth;
        int h = cardHeight;
        // Curve ends at 60 out of 265
        drawUSTCurves(g, image, x, y, w, h, 0, 0, additionalBoxColor, borderPaint);
    } else if (!isZenUst) {
        drawRulesText(g, textboxKeywords, textboxRules, totalContentInset + 2, typeLineY + boxHeight + 2, contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3, false);
    }
    // Draw the bottom right stuff
    drawBottomRight(g, attribs, borderPaint, boxColor);
}
Also used : ObjectColor(mage.ObjectColor) ObjectColor(mage.ObjectColor)

Aggregations

ObjectColor (mage.ObjectColor)82 Permanent (mage.game.permanent.Permanent)50 Player (mage.players.Player)27 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)19 UUID (java.util.UUID)14 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)14 Card (mage.cards.Card)13 FilterPermanent (mage.filter.FilterPermanent)13 Spell (mage.game.stack.Spell)12 Ability (mage.abilities.Ability)10 FixedTarget (mage.target.targetpointer.FixedTarget)10 ChoiceColor (mage.choices.ChoiceColor)9 Mana (mage.Mana)8 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)8 ArrayList (java.util.ArrayList)7 ContinuousEffect (mage.abilities.effects.ContinuousEffect)7 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)7 FilterCard (mage.filter.FilterCard)7 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)6 MageObject (mage.MageObject)5