* Fixed null pointer exception for tooltip and triggered abilities (made a kind of workaround and it's still unclear to me what caused this problems).

This commit is contained in:
LevelX2 2015-03-12 16:54:30 +01:00
parent b58c017048
commit e29eea791c
2 changed files with 22 additions and 15 deletions

View file

@ -14,6 +14,7 @@ import javax.swing.*;
import java.awt.*;
import java.net.URL;
import java.util.ArrayList;
import mage.constants.Rarity;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
public class GuiDisplayUtil {
@ -221,21 +222,27 @@ public class GuiDisplayUtil {
}
buffer.append(getTypes(card));
buffer.append("</td><td align='right'>");
switch (card.getRarity()) {
case RARE:
buffer.append("<b color='#FFBF00'>");
break;
case UNCOMMON:
buffer.append("<b color='silver'>");
break;
case COMMON:
buffer.append("<b color='black'>");
break;
case MYTHIC:
buffer.append("<b color='#D5330B'>");
break;
String rarity ;
if (card.getRarity() == null) {
rarity = Rarity.COMMON.getCode();
buffer.append("<b color='black'>");
}else {
switch (card.getRarity()) {
case RARE:
buffer.append("<b color='#FFBF00'>");
break;
case UNCOMMON:
buffer.append("<b color='silver'>");
break;
case COMMON:
buffer.append("<b color='black'>");
break;
case MYTHIC:
buffer.append("<b color='#D5330B'>");
break;
}
rarity = card.getRarity().getCode();
}
String rarity = card.getRarity().getCode();
if (card.getExpansionSetCode() != null) {
buffer.append(ManaSymbols.replaceSetCodeWithHTML(card.getExpansionSetCode().toUpperCase(), rarity));
}

View file

@ -90,7 +90,7 @@ public class CardPluginImpl implements CardPlugin {
@Override
public MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
CardPanel cardPanel = new CardPanel(permanent, gameId, loadImage, callback, false, dimension);
boolean implemented = !permanent.getRarity().equals(Rarity.NA);
boolean implemented = permanent.getRarity() != null && !permanent.getRarity().equals(Rarity.NA);
cardPanel.setShowCastingCost(implemented);
return cardPanel;
}