mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* Non creature tokens - fixed rollback errors in AI games (example: Food token, see #6331);
Fixed other potentially NPE errors with rarity;
This commit is contained in:
parent
1b60dfc258
commit
cb8d4dc340
12 changed files with 88 additions and 70 deletions
|
|
@ -183,7 +183,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
if (card.getExpansionSetCode() != null && !card.getExpansionSetCode().isEmpty()) {
|
||||
sb.append('\n').append(card.getCardNumber()).append(" - ");
|
||||
sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
sb.append(card.getRarity() == null ? "none" : card.getRarity().toString());
|
||||
}
|
||||
}
|
||||
// sb.append("\n").append(card.getId());
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
import mage.client.util.Event;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.client.util.Listener;
|
||||
import mage.constants.Rarity;
|
||||
import mage.utils.CardColorUtil;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
|
|
@ -362,7 +363,14 @@
|
|||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
||||
Rarity r1 = o1.getOriginal().getRarity();
|
||||
Rarity r2 = o2.getOriginal().getRarity();
|
||||
|
||||
int val = Integer.compare(
|
||||
r1 == null ? 0 : r1.getSorting(),
|
||||
r2 == null ? 0 : r2.getSorting()
|
||||
);
|
||||
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import mage.client.dialog.PreferencesDialog;
|
|||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.util.RandomUtil;
|
||||
|
|
@ -1295,7 +1296,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
// Rarity
|
||||
if (!s) {
|
||||
s |= card.getRarity().toString().toLowerCase(Locale.ENGLISH).contains(searchStr);
|
||||
Rarity r = card.getRarity();
|
||||
if (r != null) {
|
||||
s |= r.toString().toLowerCase(Locale.ENGLISH).contains(searchStr);
|
||||
}
|
||||
}
|
||||
// Type line
|
||||
if (!s) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import static mage.client.constants.Constants.DAMAGE_MAX_LEFT;
|
|||
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Permanent extends Card {
|
||||
|
|
@ -40,11 +39,14 @@ public class Permanent extends Card {
|
|||
protected final BufferedImage tappedImage;
|
||||
protected BufferedImage flippedImage;
|
||||
|
||||
/** Creates new form Permanent
|
||||
/**
|
||||
* Creates new form Permanent
|
||||
*
|
||||
* @param permanent
|
||||
* @param bigCard
|
||||
* @param dimensions
|
||||
* @param gameId */
|
||||
* @param gameId
|
||||
*/
|
||||
public Permanent(PermanentView permanent, BigCard bigCard, CardDimensions dimensions, UUID gameId) {
|
||||
super(permanent, bigCard, dimensions, gameId);
|
||||
this.setSize(this.getPreferredSize());
|
||||
|
|
@ -74,29 +76,28 @@ public class Permanent extends Card {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.getText(cardType));
|
||||
if (permanent.getOriginal() != null) {
|
||||
sb.append("\n----- Originally -------\n");
|
||||
sb.append(permanent.getOriginal().getName());
|
||||
if (!permanent.getOriginal().getManaCost().isEmpty()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getManaCost());
|
||||
}
|
||||
sb.append('\n').append(getType(permanent.getOriginal()));
|
||||
if (permanent.getOriginal().getColor().hasColor()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getColor().toString());
|
||||
}
|
||||
if (permanent.getOriginal().isCreature()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getPower()).append('/').append(permanent.getOriginal().getToughness());
|
||||
}
|
||||
else if (permanent.getOriginal().isPlanesWalker()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getLoyalty());
|
||||
}
|
||||
for (String rule: getRules()) {
|
||||
sb.append('\n').append(rule);
|
||||
}
|
||||
if (!permanent.getOriginal().getExpansionSetCode().isEmpty()) {
|
||||
sb.append('\n').append(permanent.getCardNumber()).append(" - ");
|
||||
sb.append('\n').append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(permanent.getOriginal().getRarity().toString());
|
||||
}
|
||||
sb.append("\n----- Originally -------\n");
|
||||
sb.append(permanent.getOriginal().getName());
|
||||
if (!permanent.getOriginal().getManaCost().isEmpty()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getManaCost());
|
||||
}
|
||||
sb.append('\n').append(getType(permanent.getOriginal()));
|
||||
if (permanent.getOriginal().getColor().hasColor()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getColor().toString());
|
||||
}
|
||||
if (permanent.getOriginal().isCreature()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getPower()).append('/').append(permanent.getOriginal().getToughness());
|
||||
} else if (permanent.getOriginal().isPlanesWalker()) {
|
||||
sb.append('\n').append(permanent.getOriginal().getLoyalty());
|
||||
}
|
||||
for (String rule : getRules()) {
|
||||
sb.append('\n').append(rule);
|
||||
}
|
||||
if (!permanent.getOriginal().getExpansionSetCode().isEmpty()) {
|
||||
sb.append('\n').append(permanent.getCardNumber()).append(" - ");
|
||||
sb.append('\n').append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(permanent.getOriginal().getRarity() == null ? "none" : permanent.getOriginal().getRarity().toString());
|
||||
}
|
||||
// sb.append("\n").append(card.getId());
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
@ -107,12 +108,11 @@ public class Permanent extends Card {
|
|||
protected List<String> getRules() {
|
||||
if (permanent.getCounters() != null) {
|
||||
List<String> rules = new ArrayList<>(permanent.getRules());
|
||||
for (CounterView counter: permanent.getCounters()) {
|
||||
for (CounterView counter : permanent.getCounters()) {
|
||||
rules.add(counter.getCount() + " x " + counter.getName());
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return permanent.getRules();
|
||||
}
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ public class Permanent extends Card {
|
|||
}
|
||||
this.setBounds(r);
|
||||
this.repaint();
|
||||
for (MagePermanent perm: links) {
|
||||
for (MagePermanent perm : links) {
|
||||
r.x += 20;
|
||||
r.y += 20;
|
||||
perm.setBounds(r);
|
||||
|
|
@ -160,22 +160,20 @@ public class Permanent extends Card {
|
|||
if (permanent.isTapped()) {
|
||||
this.getText().setVisible(false);
|
||||
g2.drawImage(tappedImage, 0, 0, this);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.getText().setVisible(true);
|
||||
g2.drawImage(small, 0, 0, this);
|
||||
}
|
||||
|
||||
//Add a border, red if card currently has focus
|
||||
if (isFocusOwner()) {
|
||||
g2.setColor(Color.RED);
|
||||
g2.setColor(Color.RED);
|
||||
} else {
|
||||
g2.setColor(Color.BLACK);
|
||||
g2.setColor(Color.BLACK);
|
||||
}
|
||||
if (permanent.isTapped()) {
|
||||
g2.drawRect(0, 0, ClientDefaultSettings.dimensions.getFrameHeight() - 1, ClientDefaultSettings.dimensions.getFrameWidth() - 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
g2.drawRect(0, 0, ClientDefaultSettings.dimensions.getFrameWidth() - 1, ClientDefaultSettings.dimensions.getFrameHeight() - 1);
|
||||
}
|
||||
|
||||
|
|
@ -207,8 +205,7 @@ public class Permanent extends Card {
|
|||
public Dimension getPreferredSize() {
|
||||
if (permanent != null && permanent.isTapped()) {
|
||||
return new Dimension(ClientDefaultSettings.dimensions.getFrameHeight(), ClientDefaultSettings.dimensions.getFrameWidth());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
|
||||
}
|
||||
}
|
||||
|
|
@ -229,7 +226,7 @@ public class Permanent extends Card {
|
|||
tooltipPopup.hide();
|
||||
}
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()? ClientDefaultSettings.dimensions.getFrameHeight() : ClientDefaultSettings.dimensions.getFrameWidth());
|
||||
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped() ? ClientDefaultSettings.dimensions.getFrameHeight() : ClientDefaultSettings.dimensions.getFrameWidth());
|
||||
int y = (int) this.getLocationOnScreen().getY() + 40;
|
||||
tooltipPopup = factory.getPopup(this, tooltipText, x, y);
|
||||
tooltipPopup.show();
|
||||
|
|
@ -246,7 +243,8 @@ public class Permanent extends Card {
|
|||
return permanent;
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
/**
|
||||
* This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ public class MageCardComparator implements Comparator<CardView> {
|
|||
break;
|
||||
// Rarity
|
||||
case 6:
|
||||
aCom = a.getRarity().getSorting();
|
||||
bCom = b.getRarity().getSorting();
|
||||
aCom = a.getRarity() == null ? 0 : a.getRarity().getSorting();
|
||||
bCom = b.getRarity() == null ? 0 : b.getRarity().getSorting();
|
||||
break;
|
||||
// Set name
|
||||
case 7:
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import mage.client.cards.CardEventSource;
|
|||
import mage.client.cards.ICardGrid;
|
||||
import mage.client.deckeditor.SortSetting;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.ClientEventType;
|
||||
import mage.client.util.ClientDefaultSettings;
|
||||
import mage.client.util.ClientEventType;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
|
|
@ -235,7 +235,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
return c.isCreature() ? c.getPower() + '/'
|
||||
+ c.getToughness() : "-";
|
||||
case 6:
|
||||
return c.getRarity().toString();
|
||||
return c.getRarity() == null ? "" : c.getRarity().toString();
|
||||
case 7:
|
||||
return c.getExpansionSetCode();
|
||||
case 8:
|
||||
|
|
|
|||
|
|
@ -1,19 +1,30 @@
|
|||
|
||||
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
import mage.constants.Rarity;
|
||||
import mage.view.CardView;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardViewRarityComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
return o1.getRarity().compareTo(o2.getRarity());
|
||||
Rarity r1 = o1.getRarity();
|
||||
Rarity r2 = o2.getRarity();
|
||||
|
||||
int val = Integer.compare(
|
||||
r1 == null ? 0 : r1.getSorting(),
|
||||
r2 == null ? 0 : r2.getSorting()
|
||||
);
|
||||
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -750,7 +750,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
if (card.getExpansionSetCode() != null && !card.getExpansionSetCode().isEmpty()) {
|
||||
sb.append('\n').append(card.getCardNumber()).append(" - ");
|
||||
sb.append(card.getExpansionSetCode()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
sb.append(card.getRarity() == null ? "none" : card.getRarity().toString());
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue