mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
update ImageView
show NoSell overlay
This commit is contained in:
@@ -54,13 +54,14 @@ public class PaperCard implements Comparable<IPaperCard>, InventoryItemFromSet,
|
|||||||
private final int artIndex;
|
private final int artIndex;
|
||||||
private final boolean foil;
|
private final boolean foil;
|
||||||
private Boolean hasImage;
|
private Boolean hasImage;
|
||||||
|
private final boolean noSell;
|
||||||
private String sortableName;
|
private String sortableName;
|
||||||
private final String functionalVariant;
|
private final String functionalVariant;
|
||||||
|
|
||||||
// Calculated fields are below:
|
// Calculated fields are below:
|
||||||
private transient CardRarity rarity; // rarity is given in ctor when set is assigned
|
private transient CardRarity rarity; // rarity is given in ctor when set is assigned
|
||||||
// Reference to a new instance of Self, but foiled!
|
// Reference to a new instance of Self, but foiled!
|
||||||
private transient PaperCard foiledVersion;
|
private transient PaperCard foiledVersion, noSellVersion;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -137,6 +138,24 @@ public class PaperCard implements Comparable<IPaperCard>, InventoryItemFromSet,
|
|||||||
this.artIndex, false, String.valueOf(collectorNumber), this.artist, this.functionalVariant);
|
this.artIndex, false, String.valueOf(collectorNumber), this.artist, this.functionalVariant);
|
||||||
return unFoiledVersion;
|
return unFoiledVersion;
|
||||||
}
|
}
|
||||||
|
public PaperCard getNoSellVersion() {
|
||||||
|
if (this.noSell)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
if (this.noSellVersion == null) {
|
||||||
|
this.noSellVersion = new PaperCard(this.rules, this.edition, this.rarity,
|
||||||
|
this.artIndex, this.foil, String.valueOf(collectorNumber), this.artist, this.functionalVariant, true);
|
||||||
|
}
|
||||||
|
return this.noSellVersion;
|
||||||
|
}
|
||||||
|
public PaperCard getSellable() {
|
||||||
|
if (!this.noSell)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
PaperCard sellable = new PaperCard(this.rules, this.edition, this.rarity,
|
||||||
|
this.artIndex, this.foil, String.valueOf(collectorNumber), this.artist, this.functionalVariant, false);
|
||||||
|
return sellable;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getItemType() {
|
public String getItemType() {
|
||||||
@@ -144,6 +163,9 @@ public class PaperCard implements Comparable<IPaperCard>, InventoryItemFromSet,
|
|||||||
return localizer.getMessage("lblCard");
|
return localizer.getMessage("lblCard");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNoSell() {
|
||||||
|
return noSell;
|
||||||
|
}
|
||||||
public boolean hasImage() {
|
public boolean hasImage() {
|
||||||
return hasImage(false);
|
return hasImage(false);
|
||||||
}
|
}
|
||||||
@@ -162,6 +184,12 @@ public class PaperCard implements Comparable<IPaperCard>, InventoryItemFromSet,
|
|||||||
public PaperCard(final CardRules rules0, final String edition0, final CardRarity rarity0,
|
public PaperCard(final CardRules rules0, final String edition0, final CardRarity rarity0,
|
||||||
final int artIndex0, final boolean foil0, final String collectorNumber0,
|
final int artIndex0, final boolean foil0, final String collectorNumber0,
|
||||||
final String artist0, final String functionalVariant) {
|
final String artist0, final String functionalVariant) {
|
||||||
|
this(rules0, edition0, rarity0, artIndex0, foil0, collectorNumber0, artist0, functionalVariant, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaperCard(final CardRules rules0, final String edition0, final CardRarity rarity0,
|
||||||
|
final int artIndex0, final boolean foil0, final String collectorNumber0,
|
||||||
|
final String artist0, final String functionalVariant, final boolean noSell0) {
|
||||||
if (rules0 == null || edition0 == null || rarity0 == null) {
|
if (rules0 == null || edition0 == null || rarity0 == null) {
|
||||||
throw new IllegalArgumentException("Cannot create card without rules, edition or rarity");
|
throw new IllegalArgumentException("Cannot create card without rules, edition or rarity");
|
||||||
}
|
}
|
||||||
@@ -177,6 +205,7 @@ public class PaperCard implements Comparable<IPaperCard>, InventoryItemFromSet,
|
|||||||
// This is a good tradeoff
|
// This is a good tradeoff
|
||||||
sortableName = TextUtil.toSortableName(CardTranslation.getTranslatedName(rules0.getName()));
|
sortableName = TextUtil.toSortableName(CardTranslation.getTranslatedName(rules0.getName()));
|
||||||
this.functionalVariant = functionalVariant != null ? functionalVariant : IPaperCard.NO_FUNCTIONAL_VARIANT;
|
this.functionalVariant = functionalVariant != null ? functionalVariant : IPaperCard.NO_FUNCTIONAL_VARIANT;
|
||||||
|
noSell = noSell0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PaperCard FAKE_CARD = new PaperCard(CardRules.getUnsupportedCardNamed("Fake Card"), "Fake Edition", CardRarity.Common);
|
public static PaperCard FAKE_CARD = new PaperCard(CardRules.getUnsupportedCardNamed("Fake Card"), "Fake Edition", CardRarity.Common);
|
||||||
|
|||||||
@@ -473,7 +473,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
if (data.containsKey("noSellCards")) {
|
if (data.containsKey("noSellCards")) {
|
||||||
PaperCard[] items = (PaperCard[]) data.readObject("noSellCards");
|
PaperCard[] items = (PaperCard[]) data.readObject("noSellCards");
|
||||||
for (PaperCard item : items) {
|
for (PaperCard item : items) {
|
||||||
noSellCards.add(item);
|
if (item != null)
|
||||||
|
noSellCards.add(item.getNoSellVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.containsKey("autoSellCards")) {
|
if (data.containsKey("autoSellCards")) {
|
||||||
@@ -636,7 +637,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
autoSellCards.add(reward.getCard());
|
autoSellCards.add(reward.getCard());
|
||||||
refreshEditor();
|
refreshEditor();
|
||||||
} else if (reward.isNoSell()) {
|
} else if (reward.isNoSell()) {
|
||||||
noSellCards.add(reward.getCard());
|
noSellCards.add(reward.getCard().getNoSellVersion());
|
||||||
refreshEditor();
|
refreshEditor();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package forge.adventure.scene;
|
|||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
import forge.adventure.data.AdventureEventData;
|
import forge.adventure.data.AdventureEventData;
|
||||||
import forge.adventure.player.AdventurePlayer;
|
|
||||||
import forge.item.PaperCard;
|
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,12 +59,4 @@ public class DeckEditScene extends ForgeScene {
|
|||||||
}
|
}
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAutoSell(PaperCard pc) {
|
|
||||||
return AdventurePlayer.current().getAutoSellCards().contains(pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNoSell(PaperCard pc) {
|
|
||||||
return AdventurePlayer.current().getNoSellCards().contains(pc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,8 +222,8 @@ public class ConsoleCommandInterpreter {
|
|||||||
if (s.length < 1) return "Command needs 1 parameter: Card name.";
|
if (s.length < 1) return "Command needs 1 parameter: Card name.";
|
||||||
PaperCard card = StaticData.instance().getCommonCards().getCard(s[0]);
|
PaperCard card = StaticData.instance().getCommonCards().getCard(s[0]);
|
||||||
if (card == null) return "Cannot find card: " + s[0];
|
if (card == null) return "Cannot find card: " + s[0];
|
||||||
Current.player().addCard(card);
|
Current.player().addCard(card.getNoSellVersion());
|
||||||
Current.player().noSellCards.add(card);
|
Current.player().noSellCards.add(card.getNoSellVersion());
|
||||||
return "Added card: " + s[0];
|
return "Added card: " + s[0];
|
||||||
});
|
});
|
||||||
registerCommand(new String[]{"give", "item"}, s -> {
|
registerCommand(new String[]{"give", "item"}, s -> {
|
||||||
|
|||||||
@@ -1126,13 +1126,11 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
if (cardPrice == null)
|
if (cardPrice == null)
|
||||||
cardPrice = ((ShopScene) Forge.getCurrentScene()).getCardPrice((PaperCard) item);
|
cardPrice = ((ShopScene) Forge.getCurrentScene()).getCardPrice((PaperCard) item);
|
||||||
drawCardLabel(g, "$" + cardPrice, Color.GOLD, x, y ,w ,h);
|
drawCardLabel(g, "$" + cardPrice, Color.GOLD, x, y ,w ,h);
|
||||||
} /*else if (Forge.getCurrentScene() instanceof DeckEditScene) {
|
} else {
|
||||||
if (((DeckEditScene) Forge.getCurrentScene()).isAutoSell((PaperCard) item)) {
|
if (((PaperCard) item).isNoSell()) {
|
||||||
drawCardLabel(g, Forge.getLocalizer().getMessage("lblAutoSell"), Color.GREEN, x, y, w, h);
|
|
||||||
} else if (((DeckEditScene) Forge.getCurrentScene()).isNoSell((PaperCard) item)) {
|
|
||||||
drawCardLabel(g, Forge.getLocalizer().getMessage("lblNoSell"), Color.RED, x, y, w, h);
|
drawCardLabel(g, Forge.getLocalizer().getMessage("lblNoSell"), Color.RED, x, y, w, h);
|
||||||
}
|
}
|
||||||
}*///TODO FIX Distinction
|
}
|
||||||
}
|
}
|
||||||
} else if (item instanceof ConquestCommander) {
|
} else if (item instanceof ConquestCommander) {
|
||||||
CardRenderer.drawCard(g, ((ConquestCommander) item).getCard(), x, y, w, h, pos);
|
CardRenderer.drawCard(g, ((ConquestCommander) item).getCard(), x, y, w, h, pos);
|
||||||
|
|||||||
Reference in New Issue
Block a user