mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
@@ -1,7 +1,6 @@
|
|||||||
package forge.adventure.data;
|
package forge.adventure.data;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import forge.StaticData;
|
import forge.StaticData;
|
||||||
import forge.adventure.util.CardUtil;
|
import forge.adventure.util.CardUtil;
|
||||||
@@ -89,9 +88,7 @@ public class RewardData implements Serializable {
|
|||||||
else
|
else
|
||||||
allCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(), new CardUtil.CardPredicate(legals, true));
|
allCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(), new CardUtil.CardPredicate(legals, true));
|
||||||
//Filter out specific cards.
|
//Filter out specific cards.
|
||||||
allCards = Iterables.filter(allCards, new Predicate<PaperCard>() {
|
allCards = Iterables.filter(allCards, input -> {
|
||||||
@Override
|
|
||||||
public boolean apply(PaperCard input){
|
|
||||||
if(input == null)
|
if(input == null)
|
||||||
return false;
|
return false;
|
||||||
if (Iterables.contains(input.getRules().getMainPart().getKeywords(), "Remove CARDNAME from your deck before playing if you're not playing for ante."))
|
if (Iterables.contains(input.getRules().getMainPart().getKeywords(), "Remove CARDNAME from your deck before playing if you're not playing for ante."))
|
||||||
@@ -100,17 +97,14 @@ public class RewardData implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
if(Arrays.asList(Config.instance().getConfigData().restrictedEditions).contains(input.getEdition()))
|
if(Arrays.asList(Config.instance().getConfigData().restrictedEditions).contains(input.getEdition()))
|
||||||
return false;
|
return false;
|
||||||
|
if(input.getRules().isCustom())
|
||||||
|
return false;
|
||||||
return !Arrays.asList(Config.instance().getConfigData().restrictedCards).contains(input.getName());
|
return !Arrays.asList(Config.instance().getConfigData().restrictedCards).contains(input.getName());
|
||||||
}
|
|
||||||
});
|
});
|
||||||
//Filter AI cards for enemies.
|
//Filter AI cards for enemies.
|
||||||
allEnemyCards=Iterables.filter(allCards, new Predicate<PaperCard>() {
|
allEnemyCards=Iterables.filter(allCards, input -> {
|
||||||
@Override
|
|
||||||
public boolean apply(PaperCard input) {
|
|
||||||
if (input == null) return false;
|
if (input == null) return false;
|
||||||
return !input.getRules().getAiHints().getRemAIDecks();
|
return !input.getRules().getAiHints().getRemAIDecks();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -898,6 +898,17 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
return inventoryItems.contains(name, false);
|
return inventoryItems.contains(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int countItem(String name) {
|
||||||
|
int count = 0;
|
||||||
|
if (!hasItem(name))
|
||||||
|
return count;
|
||||||
|
for (String s : inventoryItems) {
|
||||||
|
if (s.equals(name))
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addItem(String name) {
|
public boolean addItem(String name) {
|
||||||
ItemData item = ItemData.getItem(name);
|
ItemData item = ItemData.getItem(name);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
@@ -1102,11 +1113,13 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CardPool getCollectionCards() {
|
public CardPool getCollectionCards(boolean allCards) {
|
||||||
CardPool collectionCards = new CardPool();
|
CardPool collectionCards = new CardPool();
|
||||||
collectionCards.addAll(cards);
|
collectionCards.addAll(cards);
|
||||||
|
if (!allCards) {
|
||||||
collectionCards.removeAll(autoSellCards);
|
collectionCards.removeAll(autoSellCards);
|
||||||
collectionCards.removeAll(noSellCards);
|
collectionCards.removeAll(noSellCards);
|
||||||
|
}
|
||||||
|
|
||||||
return collectionCards;
|
return collectionCards;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
|||||||
cardsInUse.addAllFlat(AdventurePlayer.current().getSelectedDeck().getAllCardsInASinglePool().toFlatList());
|
cardsInUse.addAllFlat(AdventurePlayer.current().getSelectedDeck().getAllCardsInASinglePool().toFlatList());
|
||||||
|
|
||||||
if (showCollectionCards) {
|
if (showCollectionCards) {
|
||||||
collectionPool.addAllFlat(AdventurePlayer.current().getCollectionCards().toFlatList());
|
collectionPool.addAllFlat(AdventurePlayer.current().getCollectionCards(false).toFlatList());
|
||||||
}
|
}
|
||||||
if (showNoSellCards) {
|
if (showNoSellCards) {
|
||||||
collectionPool.addAllFlat(AdventurePlayer.current().getNoSellCards().toFlatList());
|
collectionPool.addAllFlat(AdventurePlayer.current().getNoSellCards().toFlatList());
|
||||||
@@ -1057,7 +1057,7 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
|||||||
cardsInUse.addAll(AdventurePlayer.current().getSelectedDeck().getOrCreate(DeckSection.Sideboard));
|
cardsInUse.addAll(AdventurePlayer.current().getSelectedDeck().getOrCreate(DeckSection.Sideboard));
|
||||||
|
|
||||||
if (showCollectionCards) {
|
if (showCollectionCards) {
|
||||||
adventurePool.addAll(AdventurePlayer.current().getCollectionCards());
|
adventurePool.addAll(AdventurePlayer.current().getCollectionCards(false));
|
||||||
}
|
}
|
||||||
if (showNoSellCards) {
|
if (showNoSellCards) {
|
||||||
adventurePool.addAll(AdventurePlayer.current().getNoSellCards());
|
adventurePool.addAll(AdventurePlayer.current().getNoSellCards());
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import com.badlogic.gdx.utils.Timer;
|
import com.badlogic.gdx.utils.Timer;
|
||||||
import com.github.tommyettinger.textra.TextraButton;
|
import com.github.tommyettinger.textra.TextraButton;
|
||||||
import com.github.tommyettinger.textra.TextraLabel;
|
import com.github.tommyettinger.textra.TextraLabel;
|
||||||
|
import com.github.tommyettinger.textra.TypingLabel;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.character.ShopActor;
|
import forge.adventure.character.ShopActor;
|
||||||
import forge.adventure.data.RewardData;
|
import forge.adventure.data.RewardData;
|
||||||
@@ -24,13 +25,15 @@ import forge.deck.Deck;
|
|||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.sound.SoundEffectType;
|
import forge.sound.SoundEffectType;
|
||||||
import forge.sound.SoundSystem;
|
import forge.sound.SoundSystem;
|
||||||
|
import forge.util.ItemPool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the rewards of a fight or a treasure
|
* Displays the rewards of a fight or a treasure
|
||||||
*/
|
*/
|
||||||
public class RewardScene extends UIScene {
|
public class RewardScene extends UIScene {
|
||||||
private TextraButton doneButton, detailButton, restockButton;
|
private TextraButton doneButton, detailButton, restockButton;
|
||||||
private TextraLabel shopNameLabel, playerGold, playerShards;
|
private TextraLabel playerGold, playerShards;
|
||||||
|
private TypingLabel shopNameLabel;
|
||||||
|
|
||||||
private ShopActor shopActor;
|
private ShopActor shopActor;
|
||||||
private static RewardScene object;
|
private static RewardScene object;
|
||||||
@@ -55,6 +58,7 @@ public class RewardScene extends UIScene {
|
|||||||
static public final float CARD_WIDTH = 550f ;
|
static public final float CARD_WIDTH = 550f ;
|
||||||
static public final float CARD_HEIGHT = 400f;
|
static public final float CARD_HEIGHT = 400f;
|
||||||
static public final float CARD_WIDTH_TO_HEIGHT = CARD_WIDTH / CARD_HEIGHT;
|
static public final float CARD_WIDTH_TO_HEIGHT = CARD_WIDTH / CARD_HEIGHT;
|
||||||
|
ItemPool<PaperCard> collectionPool = null;
|
||||||
|
|
||||||
private RewardScene() {
|
private RewardScene() {
|
||||||
|
|
||||||
@@ -134,6 +138,10 @@ public class RewardScene extends UIScene {
|
|||||||
//save RAM
|
//save RAM
|
||||||
ImageCache.unloadCardTextures(true);
|
ImageCache.unloadCardTextures(true);
|
||||||
Forge.restrictAdvMenus = false;
|
Forge.restrictAdvMenus = false;
|
||||||
|
if (this.collectionPool != null) {
|
||||||
|
this.collectionPool.clear();
|
||||||
|
this.collectionPool = null;
|
||||||
|
}
|
||||||
Forge.switchToLast();
|
Forge.switchToLast();
|
||||||
}
|
}
|
||||||
public void reactivateInputs() {
|
public void reactivateInputs() {
|
||||||
@@ -297,6 +305,10 @@ public class RewardScene extends UIScene {
|
|||||||
if (type==Type.Shop) {
|
if (type==Type.Shop) {
|
||||||
this.shopActor = shopActor;
|
this.shopActor = shopActor;
|
||||||
this.changes = shopActor.getMapStage().getChanges();
|
this.changes = shopActor.getMapStage().getChanges();
|
||||||
|
if (this.collectionPool == null) {
|
||||||
|
this.collectionPool = new ItemPool<>(PaperCard.class);
|
||||||
|
this.collectionPool.addAllFlat(AdventurePlayer.current().getCollectionCards(true).toFlatList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
||||||
actor.remove();
|
actor.remove();
|
||||||
@@ -311,7 +323,8 @@ public class RewardScene extends UIScene {
|
|||||||
String shopName = shopActor.getDescription();
|
String shopName = shopActor.getDescription();
|
||||||
if (shopName != null && !shopName.isEmpty()) {
|
if (shopName != null && !shopName.isEmpty()) {
|
||||||
shopNameLabel.setVisible(true);
|
shopNameLabel.setVisible(true);
|
||||||
shopNameLabel.setText(shopName);
|
shopNameLabel.setText("[%?SHINY]{GRADIENT}" + shopName + "{ENDGRADIENT}");
|
||||||
|
shopNameLabel.skipToTheEnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -348,7 +361,8 @@ public class RewardScene extends UIScene {
|
|||||||
String shopName = shopActor.getDescription();
|
String shopName = shopActor.getDescription();
|
||||||
if ((shopName != null && !shopName.isEmpty())) {
|
if ((shopName != null && !shopName.isEmpty())) {
|
||||||
shopNameLabel.setVisible(true);
|
shopNameLabel.setVisible(true);
|
||||||
shopNameLabel.setText(shopName);
|
shopNameLabel.setText("[%?SHINY]{GRADIENT}" + shopName + "{ENDGRADIENT}");
|
||||||
|
shopNameLabel.skipToTheEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shopActor.canRestock()) {
|
if (shopActor.canRestock()) {
|
||||||
@@ -390,8 +404,8 @@ public class RewardScene extends UIScene {
|
|||||||
int y = Forge.getDeviceAdapter().getRealScreenSize(false).getRight();
|
int y = Forge.getDeviceAdapter().getRealScreenSize(false).getRight();
|
||||||
int realX = Forge.getDeviceAdapter().getRealScreenSize(true).getLeft();
|
int realX = Forge.getDeviceAdapter().getRealScreenSize(true).getLeft();
|
||||||
int realY = Forge.getDeviceAdapter().getRealScreenSize(true).getRight();
|
int realY = Forge.getDeviceAdapter().getRealScreenSize(true).getRight();
|
||||||
float fW = x > y ? x : y;
|
float fW = Math.max(x, y);
|
||||||
float fH = x > y ? y : x;
|
float fH = Math.min(x, y);
|
||||||
float mul = fW/fH < AR ? AR/(fW/fH) : (fW/fH)/AR;
|
float mul = fW/fH < AR ? AR/(fW/fH) : (fW/fH)/AR;
|
||||||
if (fW/fH >= 2f) {//tall display
|
if (fW/fH >= 2f) {//tall display
|
||||||
mul = (fW/fH) - ((fW/fH)/AR);
|
mul = (fW/fH) - ((fW/fH)/AR);
|
||||||
@@ -456,6 +470,15 @@ public class RewardScene extends UIScene {
|
|||||||
stage.addActor(buyCardButton);
|
stage.addActor(buyCardButton);
|
||||||
addToSelectable(buyCardButton);
|
addToSelectable(buyCardButton);
|
||||||
}
|
}
|
||||||
|
if (this.collectionPool != null && Reward.Type.Card.equals(reward.getType())) {
|
||||||
|
int count = collectionPool.count(reward.getCard());
|
||||||
|
String text = buyCardButton.getTextraLabel().storedText;
|
||||||
|
buyCardButton.setText("[%75]" + text + "\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + count);
|
||||||
|
} else if (Reward.Type.Item.equals(reward.getType())) {
|
||||||
|
int count = AdventurePlayer.current().countItem(reward.getItem().name);
|
||||||
|
String text = buyCardButton.getTextraLabel().storedText;
|
||||||
|
buyCardButton.setText("[%75]" + text + "\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + count);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
addToSelectable(actor);
|
addToSelectable(actor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ public class UIActor extends Group {
|
|||||||
newActor = Controls.newTextraLabel("");
|
newActor = Controls.newTextraLabel("");
|
||||||
readLabelProperties((TextraLabel) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
readLabelProperties((TextraLabel) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||||
break;
|
break;
|
||||||
|
case "TypingLabel":
|
||||||
|
newActor = Controls.newTypingLabel("");
|
||||||
|
readLabelProperties((TextraLabel) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||||
|
break;
|
||||||
case "Table":
|
case "Table":
|
||||||
newActor = new Table(Controls.getSkin());
|
newActor = new Table(Controls.getSkin());
|
||||||
readTableProperties((Table) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
readTableProperties((Table) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
"y": 240
|
"y": 240
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "shopName",
|
"name": "shopName",
|
||||||
"style":"background",
|
"style":"background",
|
||||||
"text": "A Street Market",
|
"text": "A Street Market",
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
"y": 435
|
"y": 435
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "shopName",
|
"name": "shopName",
|
||||||
"style":"background",
|
"style":"background",
|
||||||
"text": "A Street Market",
|
"text": "A Street Market",
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
"y": 200
|
"y": 200
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "shopName",
|
"name": "shopName",
|
||||||
"style":"background",
|
"style":"background",
|
||||||
"text": "Shard Trader",
|
"text": "Shard Trader",
|
||||||
|
|||||||
Reference in New Issue
Block a user