mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Added card stacking for "other" cards.
This commit is contained in:
@@ -57,6 +57,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
|
|
||||||
private final int landStackMax = 5;
|
private final int landStackMax = 5;
|
||||||
private final int tokenStackMax = 5;
|
private final int tokenStackMax = 5;
|
||||||
|
private final int othersStackMax = 5;
|
||||||
|
|
||||||
private final boolean mirror;
|
private final boolean mirror;
|
||||||
|
|
||||||
@@ -132,7 +133,6 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
return allLands;
|
return allLands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final CardStackRow collectAllTokens() {
|
private final CardStackRow collectAllTokens() {
|
||||||
final CardStackRow allTokens = new CardStackRow();
|
final CardStackRow allTokens = new CardStackRow();
|
||||||
outerLoop:
|
outerLoop:
|
||||||
@@ -258,14 +258,16 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
int y = PlayArea.GUTTER_Y;
|
int y = PlayArea.GUTTER_Y;
|
||||||
|
|
||||||
//System.out.println("-------- " + (mirror ? "^" : "_") + " (Positioning ) Card width = " + cardWidth + ". Playarea = " + playAreaWidth + " x " + playAreaHeight );
|
System.out.println("-------- " + (mirror ? "^" : "_") + " (Positioning ) Card width = " + cardWidth + ". Playarea = " + playAreaWidth + " x " + playAreaHeight );
|
||||||
for (final CardStackRow row : template) {
|
for (final CardStackRow row : template) {
|
||||||
int rowBottom = 0;
|
int rowBottom = 0;
|
||||||
x = PlayArea.GUTTER_X;
|
x = PlayArea.GUTTER_X;
|
||||||
for (int stackIndex = 0, stackCount = row.size(); stackIndex < stackCount; stackIndex++) {
|
for (int stackIndex = 0, stackCount = row.size(); stackIndex < stackCount; stackIndex++) {
|
||||||
final CardStack stack = row.get(stackIndex);
|
final CardStack stack = row.get(stackIndex);
|
||||||
// Align others to the right.
|
// Align others to the right.
|
||||||
if (RowType.Other.isGoodFor(stack.get(0).getCard())) {
|
if (RowType.Other.isGoodFor(stack.get(0).getCard()) ||
|
||||||
|
(stack.get(0).getCard().isEnchantment() && !stack.get(0).getCard().isCreature() && !stack.get(0).getCard().isEnchanted() && !stack.get(0).getCard().isCloned() &&
|
||||||
|
(!stack.get(0).getCard().isEnchantingCard() && ((Card) (stack.get(0).getCard().getEnchanting())).getController() == stack.get(0).getCard().getController()))) {
|
||||||
x = (this.playAreaWidth - PlayArea.GUTTER_X) + this.extraCardSpacingX;
|
x = (this.playAreaWidth - PlayArea.GUTTER_X) + this.extraCardSpacingX;
|
||||||
for (int i = stackIndex, n = row.size(); i < n; i++) {
|
for (int i = stackIndex, n = row.size(); i < n; i++) {
|
||||||
CardStack r = row.get(i);
|
CardStack r = row.get(i);
|
||||||
@@ -301,7 +303,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
|
|
||||||
int afterFirstRow;
|
int afterFirstRow;
|
||||||
|
|
||||||
//System.out.println( "======== " + ( mirror ? "^" : "_" ) + " (try arrange) Card width = " + cardWidth + ". PlayArea = " + playAreaWidth + " x " + playAreaHeight + " ========");
|
System.out.println( "======== " + ( mirror ? "^" : "_" ) + " (try arrange) Card width = " + cardWidth + ". PlayArea = " + playAreaWidth + " x " + playAreaHeight + " ========");
|
||||||
boolean landsFit, tokensFit, creaturesFit;
|
boolean landsFit, tokensFit, creaturesFit;
|
||||||
if (this.mirror) {
|
if (this.mirror) {
|
||||||
// Wrap all creatures and lands.
|
// Wrap all creatures and lands.
|
||||||
@@ -369,7 +371,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
for (final CardStack stack : sourceRow) {
|
for (final CardStack stack : sourceRow) {
|
||||||
final int rowWidth = currentRow.getWidth();
|
final int rowWidth = currentRow.getWidth();
|
||||||
final int stackWidth = stack.getWidth();
|
final int stackWidth = stack.getWidth();
|
||||||
//System.out.printf("Adding %s (+%dpx), current row is %dpx and has %s \n", stack, stackWidth, rowWidth, currentRow );
|
System.out.printf("Adding %s (+%dpx), current row is %dpx and has %s \n", stack, stackWidth, rowWidth, currentRow );
|
||||||
// If the row is not empty and this stack doesn't fit, add the row.
|
// If the row is not empty and this stack doesn't fit, add the row.
|
||||||
if (rowWidth + stackWidth > this.playAreaWidth && !currentRow.isEmpty()) {
|
if (rowWidth + stackWidth > this.playAreaWidth && !currentRow.isEmpty()) {
|
||||||
|
|
||||||
@@ -421,7 +423,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
private int planOthersRow(final List<CardStack> sourceRow, final int firstPile, final List<CardStackRow> template, final CardStackRow rowToFill) {
|
private int planOthersRow(final List<CardStack> sourceRow, final int firstPile, final List<CardStackRow> template, final CardStackRow rowToFill) {
|
||||||
int rowWidth = rowToFill.getWidth();
|
int rowWidth = rowToFill.getWidth();
|
||||||
|
|
||||||
// System.out.println("This row has:" + rowToFill + "; want to add:" + sourceRow );
|
System.out.println("This row has:" + rowToFill + "; want to add:" + sourceRow );
|
||||||
for (int i = firstPile; i < sourceRow.size(); i++ ) {
|
for (int i = firstPile; i < sourceRow.size(); i++ ) {
|
||||||
CardStack stack = sourceRow.get(i);
|
CardStack stack = sourceRow.get(i);
|
||||||
|
|
||||||
@@ -662,8 +664,12 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
|
|
||||||
public CardStackRow(final List<CardPanel> cardPanels, final RowType type) {
|
public CardStackRow(final List<CardPanel> cardPanels, final RowType type) {
|
||||||
this();
|
this();
|
||||||
|
if (type == RowType.Other) {
|
||||||
|
this.addAllOthers(cardPanels, type);
|
||||||
|
} else {
|
||||||
this.addAll(cardPanels, type);
|
this.addAll(cardPanels, type);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addAll(final List<CardPanel> cardPanels, final RowType type) {
|
private void addAll(final List<CardPanel> cardPanels, final RowType type) {
|
||||||
for (final CardPanel panel : cardPanels) {
|
for (final CardPanel panel : cardPanels) {
|
||||||
@@ -676,6 +682,39 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an alternate method to addAll() that sorts "other" cards into stacks
|
||||||
|
* based on sickness, cloning, counters, and cards attached to them. All cards
|
||||||
|
* that aren't equipped/enchanted/enchanting/equipping/etc that are otherwise
|
||||||
|
* the same get stacked.
|
||||||
|
*/
|
||||||
|
private void addAllOthers(final List<CardPanel> cardPanels, final RowType type) {
|
||||||
|
for (final CardPanel panel : cardPanels) {
|
||||||
|
if (!type.isGoodFor(panel.getCard()) || (panel.getAttachedToPanel() != null)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
boolean stackable = false;
|
||||||
|
for (CardStack s : this) {
|
||||||
|
Card otherCard = s.get(0).getCard();
|
||||||
|
Card thisCard = panel.getCard();
|
||||||
|
if (otherCard.getName().equals(thisCard.getName()) && s.size() < othersStackMax) {
|
||||||
|
if (panel.getAttachedPanels().isEmpty()
|
||||||
|
&& thisCard.getCounters().equals(otherCard.getCounters())
|
||||||
|
&& (thisCard.isSick() == otherCard.isSick())
|
||||||
|
&& (thisCard.isCloned() == otherCard.isCloned())) {
|
||||||
|
s.add(panel);
|
||||||
|
stackable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!stackable) {
|
||||||
|
final CardStack stack = new CardStack();
|
||||||
|
stack.add(panel);
|
||||||
|
this.add(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(final Collection<? extends CardStack> c) {
|
public boolean addAll(final Collection<? extends CardStack> c) {
|
||||||
final boolean changed = super.addAll(c);
|
final boolean changed = super.addAll(c);
|
||||||
|
|||||||
Reference in New Issue
Block a user