mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Fixed that permanets attached to non permanents (Enchant player and no curse / enchant card in graveyard) are shown wrongly attached to the first other permanent on the battlefield (fixes #632).
This commit is contained in:
parent
72cf165c76
commit
3d55659568
2 changed files with 32 additions and 22 deletions
|
@ -113,7 +113,7 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
JLayeredPane battlefieldPanel = (JLayeredPane) component;
|
JLayeredPane battlefieldPanel = (JLayeredPane) component;
|
||||||
JComponent jPanel = ui.get("jPanel");
|
JComponent jPanel = ui.get("jPanel");
|
||||||
|
|
||||||
Row allLands = new Row();
|
Row rowAllLands = new Row();
|
||||||
|
|
||||||
outerLoop:
|
outerLoop:
|
||||||
//
|
//
|
||||||
|
@ -125,8 +125,8 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
int insertIndex = -1;
|
int insertIndex = -1;
|
||||||
|
|
||||||
// Find lands with the same name.
|
// Find lands with the same name.
|
||||||
for (int i = 0, n = allLands.size(); i < n; i++) {
|
for (int i = 0, n = rowAllLands.size(); i < n; i++) {
|
||||||
Stack stack = allLands.get(i);
|
Stack stack = rowAllLands.get(i);
|
||||||
MagePermanent firstPanel = stack.get(0);
|
MagePermanent firstPanel = stack.get(0);
|
||||||
if (firstPanel.getOriginal().getName().equals(permanent.getOriginal().getName())) {
|
if (firstPanel.getOriginal().getName().equals(permanent.getOriginal().getName())) {
|
||||||
|
|
||||||
|
@ -169,19 +169,19 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.add(permanent);
|
stack.add(permanent);
|
||||||
allLands.add(insertIndex == -1 ? allLands.size() : insertIndex, stack);
|
rowAllLands.add(insertIndex == -1 ? rowAllLands.size() : insertIndex, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
Row allCreatures = new Row(permanents, RowType.creature);
|
Row rowAllCreatures = new Row(permanents, RowType.creature);
|
||||||
Row allOthers = new Row(permanents, RowType.other);
|
Row rowAllOthers = new Row(permanents, RowType.other);
|
||||||
Row allAttached = new Row(permanents, RowType.attached);
|
Row rowAllAttached = new Row(permanents, RowType.attached);
|
||||||
|
|
||||||
boolean othersOnTheRight = true;
|
boolean othersOnTheRight = true;
|
||||||
if (options != null && options.containsKey("nonLandPermanentsInOnePile")) {
|
if (options != null && options.containsKey("nonLandPermanentsInOnePile")) {
|
||||||
if (options.get("nonLandPermanentsInOnePile").equals("true")) {
|
if (options.get("nonLandPermanentsInOnePile").equals("true")) {
|
||||||
othersOnTheRight = false;
|
othersOnTheRight = false;
|
||||||
allCreatures.addAll(allOthers);
|
rowAllCreatures.addAll(rowAllOthers);
|
||||||
allOthers.clear();
|
rowAllOthers.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,9 +198,9 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
stackSpacingX = stackVertical ? 0 : Math.round(cardWidth * STACK_SPACING_X);
|
stackSpacingX = stackVertical ? 0 : Math.round(cardWidth * STACK_SPACING_X);
|
||||||
stackSpacingY = Math.round(cardHeight * STACK_SPACING_Y);
|
stackSpacingY = Math.round(cardHeight * STACK_SPACING_Y);
|
||||||
attachmentSpacingY = Math.round(cardHeight * ATTACHMENT_SPACING_Y);
|
attachmentSpacingY = Math.round(cardHeight * ATTACHMENT_SPACING_Y);
|
||||||
Row creatures = (Row) allCreatures.clone();
|
Row creatures = (Row) rowAllCreatures.clone();
|
||||||
Row lands = (Row) allLands.clone();
|
Row lands = (Row) rowAllLands.clone();
|
||||||
Row others = (Row) allOthers.clone();
|
Row others = (Row) rowAllOthers.clone();
|
||||||
// Wrap all creatures and lands.
|
// Wrap all creatures and lands.
|
||||||
wrap(creatures, rows, -1);
|
wrap(creatures, rows, -1);
|
||||||
int afterCreaturesIndex = rows.size();
|
int afterCreaturesIndex = rows.size();
|
||||||
|
@ -291,7 +291,7 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
|
|
||||||
// we need this only for defining card size
|
// we need this only for defining card size
|
||||||
// attached permanents will be handled separately
|
// attached permanents will be handled separately
|
||||||
for (Stack stack : allAttached) {
|
for (Stack stack : rowAllAttached) {
|
||||||
for (MagePermanent panel : stack) {
|
for (MagePermanent panel : stack) {
|
||||||
panel.setCardBounds(0, 0, cardWidth, cardHeight);
|
panel.setCardBounds(0, 0, cardWidth, cardHeight);
|
||||||
}
|
}
|
||||||
|
@ -380,8 +380,7 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
case other:
|
case other:
|
||||||
return !CardUtil.isLand(card) && !CardUtil.isCreature(card);
|
return !CardUtil.isLand(card) && !CardUtil.isCreature(card);
|
||||||
case attached:
|
case attached:
|
||||||
return card.getOriginalPermanent().isAttachedTo()
|
return card.getOriginalPermanent().isAttachedToPermanent();
|
||||||
&& !card.getOriginalPermanent().getSubTypes().contains("Curse");
|
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unhandled type: " + this);
|
throw new RuntimeException("Unhandled type: " + this);
|
||||||
}
|
}
|
||||||
|
@ -401,18 +400,18 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAll(Collection<MagePermanent> permanents, RowType type) {
|
private void addAll(Collection<MagePermanent> permanents, RowType type) {
|
||||||
for (MagePermanent panel : permanents) {
|
for (MagePermanent permanent : permanents) {
|
||||||
if (!type.isType(panel)) {
|
if (!type.isType(permanent)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// all attached permanents are grouped separately later
|
// all attached permanents are grouped separately later
|
||||||
if (!type.equals(RowType.attached) && RowType.attached.isType(panel)) {
|
if (!type.equals(RowType.attached) && RowType.attached.isType(permanent)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Stack stack = new Stack();
|
Stack stack = new Stack();
|
||||||
stack.add(panel);
|
stack.add(permanent);
|
||||||
if (panel.getOriginalPermanent().getAttachments() != null) {
|
if (permanent.getOriginalPermanent().getAttachments() != null) {
|
||||||
stack.setMaxAttachedCount(panel.getOriginalPermanent().getAttachments().size());
|
stack.setMaxAttachedCount(permanent.getOriginalPermanent().getAttachments().size());
|
||||||
}
|
}
|
||||||
add(stack);
|
add(stack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class PermanentView extends CardView {
|
||||||
private final UUID attachedTo;
|
private final UUID attachedTo;
|
||||||
private final boolean morphed;
|
private final boolean morphed;
|
||||||
private final boolean manifested;
|
private final boolean manifested;
|
||||||
|
private final boolean attachedToPermanent;
|
||||||
|
|
||||||
public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) {
|
public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) {
|
||||||
super(permanent, null, permanent.getControllerId().equals(createdForPlayerId));
|
super(permanent, null, permanent.getControllerId().equals(createdForPlayerId));
|
||||||
|
@ -143,7 +144,13 @@ public class PermanentView extends CardView {
|
||||||
" A face-down card can also be turned face up for its morph cost.");
|
" A face-down card can also be turned face up for its morph cost.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// determines if shown in it's own column
|
||||||
|
if (permanent.getAttachedTo() != null) {
|
||||||
|
attachedToPermanent = game.getPermanent(permanent.getAttachedTo()) != null;
|
||||||
|
} else {
|
||||||
|
attachedToPermanent = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTapped() {
|
public boolean isTapped() {
|
||||||
|
@ -198,6 +205,10 @@ public class PermanentView extends CardView {
|
||||||
return attachedTo != null;
|
return attachedTo != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAttachedToPermanent() {
|
||||||
|
return attachedToPermanent;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMorphed() {
|
public boolean isMorphed() {
|
||||||
return morphed;
|
return morphed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue