From 6b9a2bb12cf0d420b0a7b9308e3fdf32615a5f0e Mon Sep 17 00:00:00 2001 From: spjspj Date: Sun, 8 Jul 2018 21:28:25 +1000 Subject: [PATCH] Add in new bar chart distribution for the 'M' mana analyse button. --- .../java/mage/client/cards/DragCardGrid.java | 2 ++ .../java/mage/client/cards/ManaBarChart.java | 28 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java index 3738225d41..70dc871497 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java @@ -1397,6 +1397,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg } mc = mc.replaceAll("\\{([WUBRG]).([WUBRG])\\}", "{$1}{$2}"); mc = mc.replaceAll("\\{", "#"); + mc = mc.replaceAll("#2\\/", "#"); + mc = mc.replaceAll("p}", "}"); mc = mc.toLowerCase(Locale.ENGLISH); int cmc = card.getConvertedManaCost(); diff --git a/Mage.Client/src/main/java/mage/client/cards/ManaBarChart.java b/Mage.Client/src/main/java/mage/client/cards/ManaBarChart.java index c7b7f39e77..15ae7abb53 100644 --- a/Mage.Client/src/main/java/mage/client/cards/ManaBarChart.java +++ b/Mage.Client/src/main/java/mage/client/cards/ManaBarChart.java @@ -66,6 +66,9 @@ public class ManaBarChart extends JComponent { } } + if (max_num_pips <= 0) { + max_num_pips = 1; + } int height_factor = 200 / max_num_pips; int width_factor = 200 / (max_cmc + 2); if (width_factor > 20) { @@ -75,11 +78,21 @@ public class ManaBarChart extends JComponent { width_factor = 11; } - g.setColor(Color.LIGHT_GRAY); + g.setColor(new Color(130, 130, 130)); for (int i = 0; i < max_num_pips; i++) { - if (i % 10 == 0) { + if (max_num_pips > 10) { + if (i % 10 == 0) { + g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor); + } else if (i % 10 == 5) { + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{5}, 0); + Stroke oldstroke = g.getStroke(); + g.setStroke(dashed); + g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor); + g.setStroke(oldstroke); + } + } else if (i % 2 == 0) { g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor); - } else if (i % 10 == 5) { + } else if (i % 2 == 1) { Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{5}, 0); Stroke oldstroke = g.getStroke(); g.setStroke(dashed); @@ -88,6 +101,15 @@ public class ManaBarChart extends JComponent { } } + for (int i = 0; i < 17; i++) { + if (i % 5 == 0) { + g.drawLine(width_factor * i, 200, width_factor * i, 190); + } else { + g.drawLine(width_factor * i, 200, width_factor * i, 195); + } + + } + HashMap running_totals_at_cmcs = new HashMap(); for (String key : pips_at_cmcs.keySet()) { Matcher regexMatcher = regex.matcher(key);