diff --git a/Mage.Client/src/main/java/mage/client/combat/CombatManager.java b/Mage.Client/src/main/java/mage/client/combat/CombatManager.java index 6c80cbd74a..6d980d9c4e 100644 --- a/Mage.Client/src/main/java/mage/client/combat/CombatManager.java +++ b/Mage.Client/src/main/java/mage/client/combat/CombatManager.java @@ -27,6 +27,9 @@ public enum CombatManager { private final Map combatBlockers = new HashMap<>(); private int globalBlockersCount; // we need global counter as there are several combat groups + private static Color ARROW_COLOR_ATTACKER = Color.red; + private static Color ARROW_COLOR_BLOCKED_ATTACKER = Color.gray; + private Point parentPoint; @@ -79,15 +82,19 @@ public enum CombatManager { private void drawDefender(CombatGroupView group, MagePermanent attackerCard, UUID gameId) { UUID defenderId = group.getDefenderId(); if (defenderId != null) { + // if attacker was blocked then use another allow color + Color attackColor = group.getBlockers().isEmpty() ? ARROW_COLOR_ATTACKER : ARROW_COLOR_BLOCKED_ATTACKER; parentPoint = getParentPoint(attackerCard); PlayAreaPanel p = MageFrame.getGamePlayers(gameId).get(defenderId); if (p != null) { + // attack to player Point target = p.getLocationOnScreen(); target.translate(-parentPoint.x, -parentPoint.y); Point attackerPoint = attackerCard.getLocationOnScreen(); attackerPoint.translate(-parentPoint.x, -parentPoint.y); - ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, Color.red, ArrowBuilder.Type.COMBAT); + ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, attackColor, ArrowBuilder.Type.COMBAT); } else { + // attack to planeswalker for (PlayAreaPanel pa : MageFrame.getGamePlayers(gameId).values()) { MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(defenderId); if (permanent != null) { @@ -95,7 +102,7 @@ public enum CombatManager { target.translate(-parentPoint.x, -parentPoint.y); Point attackerPoint = attackerCard.getLocationOnScreen(); attackerPoint.translate(-parentPoint.x, -parentPoint.y); - ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.COMBAT); + ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() + 10, attackColor, ArrowBuilder.Type.COMBAT); } } } diff --git a/Mage.Client/src/main/java/mage/client/util/gui/Arrow.java b/Mage.Client/src/main/java/mage/client/util/gui/Arrow.java index 6dfcc49c23..6d0d8b54ba 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/Arrow.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/Arrow.java @@ -1,18 +1,11 @@ package mage.client.util.gui; -import java.awt.AlphaComposite; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Composite; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; +import javax.swing.*; +import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.geom.Area; import java.awt.geom.GeneralPath; -import javax.swing.JFrame; -import javax.swing.JPanel; public class Arrow extends JPanel { @@ -26,6 +19,7 @@ public class Arrow extends JPanel { private float headSize = 17; private Composite composite; private Color color = Color.red; + private Color strokeColor = Color.black; public Arrow() { setOpaque(false); @@ -53,8 +47,11 @@ public class Arrow extends JPanel { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setComposite(composite); g2d.setColor(this.color); + //debug stroke draw + //float[] dash2 = {10, 5}; + //g2d.setStroke(new BasicStroke(3.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, dash2, 0)); g2d.fill(arrow); - g2d.setColor(Color.BLACK); + g2d.setColor(this.strokeColor); g2d.draw(arrow); }