forked from External/mage
replace public fields with encapsulation
This commit is contained in:
parent
d1e319787c
commit
8319fbf9ad
26 changed files with 544 additions and 327 deletions
|
|
@ -14,7 +14,7 @@ public final class IgnoreList {
|
|||
+ "<br/>\\unignore [username] - remove a username from your ignore list on this server.</font>";
|
||||
|
||||
public static final int MAX_IGNORE_LIST_SIZE = 50;
|
||||
public static Set<ChatMessage.MessageType> IGNORED_MESSAGE_TYPES
|
||||
public static final Set<ChatMessage.MessageType> IGNORED_MESSAGE_TYPES
|
||||
= ImmutableSet.of(ChatMessage.MessageType.TALK,
|
||||
ChatMessage.MessageType.WHISPER_FROM);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,32 +19,32 @@ public final class ArrowUtil {
|
|||
private ArrowUtil() {}
|
||||
|
||||
public static void drawArrowsForPairedCards(TransferData data, Point parentPoint) {
|
||||
if (data.card.getPairedCard() != null) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
if (data.getCard().getPairedCard() != null) {
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
UUID uuid = data.card.getPairedCard();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
UUID uuid = data.getCard().getPairedCard();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.green, ArrowBuilder.Type.PAIRED);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.green, ArrowBuilder.Type.PAIRED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawArrowsForBandedCards(TransferData data, Point parentPoint) {
|
||||
if (data.card.getBandedCards() != null && !data.card.getBandedCards().isEmpty()) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
if (data.getCard().getBandedCards() != null && !data.getCard().getBandedCards().isEmpty()) {
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
for (UUID uuid : data.card.getBandedCards()) {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
for (UUID uuid : data.getCard().getBandedCards()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 55, (int) me.getY() + 25, (int) target.getX() + 60, (int) target.getY() + 35, Color.yellow, ArrowBuilder.Type.BANDED);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 55, (int) me.getY() + 25, (int) target.getX() + 60, (int) target.getY() + 35, Color.yellow, ArrowBuilder.Type.BANDED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,17 +52,17 @@ public final class ArrowUtil {
|
|||
}
|
||||
|
||||
public static void drawArrowsForEnchantPlayers(TransferData data, Point parentPoint) {
|
||||
if (data.gameId != null && MageFrame.getGame(data.gameId) != null) {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
if (data.getGameId() != null && MageFrame.getGame(data.getGameId()) != null) {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
PlayerPanelExt playAreaPanel = pa.getPlayerPanel();
|
||||
if (playAreaPanel != null && playAreaPanel.getPlayer() != null && playAreaPanel.getPlayer().hasAttachments()) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
for (UUID attachmentId : playAreaPanel.getPlayer().getAttachments()) {
|
||||
if (attachmentId.equals(data.card.getId())) {
|
||||
if (attachmentId.equals(data.getCard().getId())) {
|
||||
Point player = pa.getLocationOnScreen();
|
||||
player.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId,(int) me.getX() + 35, (int) me.getY(), (int) player.getX() + 40, (int) player.getY() - 40, Color.magenta, ArrowBuilder.Type.ENCHANT_PLAYERS);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(),(int) me.getX() + 35, (int) me.getY(), (int) player.getX() + 40, (int) player.getY() - 40, Color.magenta, ArrowBuilder.Type.ENCHANT_PLAYERS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,45 +71,45 @@ public final class ArrowUtil {
|
|||
}
|
||||
|
||||
public static void drawArrowsForSource(TransferData data, Point parentPoint) {
|
||||
if (data.card.isAbility()) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
if (data.getCard().isAbility()) {
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
UUID uuid = data.card.getParentId();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
UUID uuid = data.getCard().getParentId();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point source = permanent.getLocationOnScreen();
|
||||
source.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) source.getX() + 40, (int) source.getY() + 10, (int) me.getX() + 35, (int) me.getY() + 20, Color.blue, ArrowBuilder.Type.SOURCE);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) source.getX() + 40, (int) source.getY() + 10, (int) me.getX() + 35, (int) me.getY() + 20, Color.blue, ArrowBuilder.Type.SOURCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawArrowsForTargets(TransferData data, Point parentPoint) {
|
||||
java.util.List<UUID> targets = data.card.getTargets();
|
||||
java.util.List<UUID> targets = data.getCard().getTargets();
|
||||
if (targets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
for (UUID uuid : targets) {
|
||||
|
||||
PlayAreaPanel p = MageFrame.getGame(data.gameId).getPlayers().get(uuid);
|
||||
PlayAreaPanel p = MageFrame.getGame(data.getGameId()).getPlayers().get(uuid);
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (PlayAreaPanel panel : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
for (PlayAreaPanel panel : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
MagePermanent permanent = panel.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -117,12 +117,12 @@ public final class ArrowUtil {
|
|||
if (view != null) {
|
||||
CardsView graveyard = view.getGraveyard();
|
||||
if (graveyard.containsKey(uuid)) {
|
||||
p = MageFrame.getGame(data.gameId).getPlayers().get(view.getPlayerId());
|
||||
p = MageFrame.getGame(data.getGameId()).getPlayers().get(view.getPlayerId());
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
int yOffset = p.isSmallMode() ? (PlayAreaPanel.PANEL_HEIGHT - PlayAreaPanel.PANEL_HEIGHT_SMALL) : 0;
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 15, (int) target.getY() + 145 - yOffset, Color.red, ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 15, (int) target.getY() + 145 - yOffset, Color.red, ArrowBuilder.Type.TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import java.util.Map;
|
|||
*/
|
||||
public class FastSearchUtil {
|
||||
|
||||
public static String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set or expansion";
|
||||
public static String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set or expansion";
|
||||
public static final String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set or expansion";
|
||||
public static final String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set or expansion";
|
||||
|
||||
public static void showFastSearchForStringComboBox(JComboBox combo, String chooseMessage) {
|
||||
showFastSearchForStringComboBox(combo, chooseMessage, 300, 500);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,24 @@ public final class GuiDisplayUtil {
|
|||
|
||||
public static class TextLines {
|
||||
|
||||
public int basicTextLength;
|
||||
public ArrayList<String> lines;
|
||||
private int basicTextLength;
|
||||
private java.util.List<String> lines;
|
||||
|
||||
public int getBasicTextLength() {
|
||||
return basicTextLength;
|
||||
}
|
||||
|
||||
public void setBasicTextLength(int basicTextLength) {
|
||||
this.basicTextLength = basicTextLength;
|
||||
}
|
||||
|
||||
public java.util.List<String> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public void setLines(java.util.List<String> lines) {
|
||||
this.lines = lines;
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreDividerLocations(Rectangle bounds, String lastDividerLocation, JComponent component) {
|
||||
|
|
@ -165,9 +181,9 @@ public final class GuiDisplayUtil {
|
|||
|
||||
public static TextLines getTextLinesfromCardView(CardView card) {
|
||||
TextLines textLines = new TextLines();
|
||||
textLines.lines = new ArrayList<>(card.getRules());
|
||||
textLines.setLines(new ArrayList<>(card.getRules()));
|
||||
for (String rule : card.getRules()) {
|
||||
textLines.basicTextLength += rule.length();
|
||||
textLines.setBasicTextLength(textLines.getBasicTextLength() + rule.length());
|
||||
}
|
||||
if (card.getMageObjectType().canHaveCounters()) {
|
||||
ArrayList<CounterView> counters = new ArrayList<>();
|
||||
|
|
@ -192,15 +208,15 @@ public final class GuiDisplayUtil {
|
|||
index++;
|
||||
}
|
||||
}
|
||||
textLines.lines.add(sb.toString());
|
||||
textLines.basicTextLength += 50;
|
||||
textLines.getLines().add(sb.toString());
|
||||
textLines.setBasicTextLength(textLines.getBasicTextLength() + 50);
|
||||
}
|
||||
}
|
||||
if (card.getMageObjectType().isPermanent() && card instanceof PermanentView) {
|
||||
int damage = ((PermanentView) card).getDamage();
|
||||
if (damage > 0) {
|
||||
textLines.lines.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
||||
textLines.basicTextLength += 50;
|
||||
textLines.getLines().add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
||||
textLines.setBasicTextLength(textLines.getBasicTextLength() + 50);
|
||||
}
|
||||
}
|
||||
return textLines;
|
||||
|
|
@ -350,8 +366,8 @@ public final class GuiDisplayUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!textLines.lines.isEmpty()) {
|
||||
for (String textLine : textLines.lines) {
|
||||
if (!textLines.getLines().isEmpty()) {
|
||||
for (String textLine : textLines.getLines()) {
|
||||
if (textLine != null && !textLine.replace(".", "").trim().isEmpty()) {
|
||||
rule.append("<p style='margin: 2px'>").append(textLine).append("</p>");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue