mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Workaround to fix problem with deck layout.
This commit is contained in:
parent
769a37958d
commit
5d8ae4d411
5 changed files with 38 additions and 16 deletions
|
@ -54,7 +54,6 @@ import mage.client.deckeditor.SortSetting;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.ImageHelper;
|
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
@ -409,7 +408,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
||||||
Image image = Plugins.getInstance().getOriginalImage(card);
|
Image image = Plugins.getInstance().getOriginalImage(card);
|
||||||
if (image != null && image instanceof BufferedImage) {
|
if (image != null && image instanceof BufferedImage) {
|
||||||
// XXX: scaled to fit width
|
// XXX: scaled to fit width
|
||||||
bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<String>(), false);
|
bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<>(), false);
|
||||||
} else {
|
} else {
|
||||||
drawCardText(card);
|
drawCardText(card);
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,6 +675,9 @@ public class SessionImpl implements Session {
|
||||||
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
|
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
|
// Workaround to fix Can't join table problem
|
||||||
|
deckList.setCardLayout(null);
|
||||||
|
deckList.setSideboardLayout(null);
|
||||||
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
||||||
}
|
}
|
||||||
} catch (InvalidDeckException iex) {
|
} catch (InvalidDeckException iex) {
|
||||||
|
@ -693,6 +696,9 @@ public class SessionImpl implements Session {
|
||||||
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
|
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
|
// Workaround to fix Can't join table problem
|
||||||
|
deckList.setCardLayout(null);
|
||||||
|
deckList.setSideboardLayout(null);
|
||||||
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
|
@ -1175,6 +1181,9 @@ public class SessionImpl implements Session {
|
||||||
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
|
// Workaround to fix Can't join table problem
|
||||||
|
deck.setCardLayout(null);
|
||||||
|
deck.setSideboardLayout(null);
|
||||||
return server.submitDeck(sessionId, tableId, deck);
|
return server.submitDeck(sessionId, tableId, deck);
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
|
@ -1191,6 +1200,8 @@ public class SessionImpl implements Session {
|
||||||
public boolean updateDeck(UUID tableId, DeckCardLists deck) {
|
public boolean updateDeck(UUID tableId, DeckCardLists deck) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
|
deck.setCardLayout(null);
|
||||||
|
deck.setSideboardLayout(null);
|
||||||
server.updateDeck(sessionId, tableId, deck);
|
server.updateDeck(sessionId, tableId, deck);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package mage.cards;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
|
|
||||||
public final class CardGraphicInfo {
|
public final class CardGraphicInfo {
|
||||||
|
|
||||||
private final ObjectColor frameColor;
|
private final ObjectColor frameColor;
|
||||||
private final FrameStyle frameStyle;
|
private final FrameStyle frameStyle;
|
||||||
private final boolean useVariousArt;
|
private final boolean useVariousArt;
|
||||||
|
@ -17,9 +18,15 @@ public final class CardGraphicInfo {
|
||||||
this.useVariousArt = useVariousArt;
|
this.useVariousArt = useVariousArt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectColor getFrameColor() { return this.frameColor != null ? this.frameColor.copy() : null; }
|
public ObjectColor getFrameColor() {
|
||||||
|
return this.frameColor != null ? this.frameColor.copy() : null;
|
||||||
|
}
|
||||||
|
|
||||||
public FrameStyle getFrameStyle() { return this.frameStyle; }
|
public FrameStyle getFrameStyle() {
|
||||||
|
return this.frameStyle;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getUsesVariousArt() { return this.useVariousArt; }
|
public boolean getUsesVariousArt() {
|
||||||
|
return this.useVariousArt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@ import java.util.List;
|
||||||
* Created by stravant@gmail.com on 2016-10-03.
|
* Created by stravant@gmail.com on 2016-10-03.
|
||||||
*/
|
*/
|
||||||
public class DeckCardLayout {
|
public class DeckCardLayout {
|
||||||
private List<List<List<DeckCardInfo>>> cards;
|
|
||||||
private String settings;
|
private final List<List<List<DeckCardInfo>>> cards;
|
||||||
|
private final String settings;
|
||||||
|
|
||||||
public DeckCardLayout(List<List<List<DeckCardInfo>>> cards, String settings) {
|
public DeckCardLayout(List<List<List<DeckCardInfo>>> cards, String settings) {
|
||||||
this.cards = cards;
|
this.cards = cards;
|
||||||
|
|
|
@ -121,18 +121,22 @@ public class DckDeckImporter extends DeckImporter {
|
||||||
//
|
//
|
||||||
DeckCardLayout layout = new DeckCardLayout(grid, settings);
|
DeckCardLayout layout = new DeckCardLayout(grid, settings);
|
||||||
int expectedCount = 0;
|
int expectedCount = 0;
|
||||||
if (target.equals("MAIN")) {
|
switch (target) {
|
||||||
deckList.setCardLayout(layout);
|
case "MAIN":
|
||||||
expectedCount = deckList.getCards().size();
|
deckList.setCardLayout(layout);
|
||||||
} else if (target.equals("SIDEBOARD")) {
|
expectedCount = deckList.getCards().size();
|
||||||
deckList.setSideboardLayout(layout);
|
break;
|
||||||
expectedCount = deckList.getSideboard().size();
|
case "SIDEBOARD":
|
||||||
} else {
|
deckList.setSideboardLayout(layout);
|
||||||
sbMessage.append("Bad target `" + target + "` for layout.\n");
|
expectedCount = deckList.getSideboard().size();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sbMessage.append("Bad target `").append(target).append("` for layout.\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (totalCardCount != expectedCount) {
|
if (totalCardCount != expectedCount) {
|
||||||
sbMessage.append("Layout mismatch: Expected " + expectedCount + " cards, but got " + totalCardCount + " in layout `" + target + "`\n.");
|
sbMessage.append("Layout mismatch: Expected ").append(expectedCount).append(" cards, but got ").append(totalCardCount).append(" in layout `").append(target).append("`\n.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue