Implemented banding (#41)

This commit is contained in:
L_J 2018-02-13 20:36:25 +01:00 committed by GitHub
parent adec5cf88b
commit e7301e2c08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 708 additions and 136 deletions

View file

@ -423,6 +423,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
tooltipShowing = false;
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.TARGET);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.PAIRED);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.BANDED);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.SOURCE);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.ENCHANT_PLAYERS);
}

View file

@ -379,6 +379,7 @@ public class MageActionCallback implements ActionCallback {
ArrowUtil.drawArrowsForTargets(data, parentPoint);
ArrowUtil.drawArrowsForSource(data, parentPoint);
ArrowUtil.drawArrowsForPairedCards(data, parentPoint);
ArrowUtil.drawArrowsForBandedCards(data, parentPoint);
ArrowUtil.drawArrowsForEnchantPlayers(data, parentPoint);
tooltipCard = data.card;
showTooltipPopup(data, parentComponent, parentPoint);
@ -441,6 +442,7 @@ public class MageActionCallback implements ActionCallback {
public void hideGameUpdate(UUID gameId) {
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.TARGET);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.PAIRED);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.BANDED);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.SOURCE);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.ENCHANT_PLAYERS);
}
@ -452,6 +454,7 @@ public class MageActionCallback implements ActionCallback {
if (gameId != null) {
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.TARGET);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.PAIRED);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.BANDED);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.SOURCE);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.ENCHANT_PLAYERS);
}

View file

@ -38,7 +38,7 @@ public class ArrowBuilder {
private int currentHeight;
public enum Type {
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
PAIRED, BANDED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
}
/**

View file

@ -34,6 +34,23 @@ public final class ArrowUtil {
}
}
public static void drawArrowsForBandedCards(TransferData data, Point parentPoint) {
if (data.card.getBandedCards() != null && !data.card.getBandedCards().isEmpty()) {
Point me = new Point(data.locationOnScreen);
me.translate(-parentPoint.x, -parentPoint.y);
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
for (UUID uuid : data.card.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() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.yellow, ArrowBuilder.Type.BANDED);
}
}
}
}
}
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()) {