mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Re-envision AEther screen
This commit is contained in:
@@ -79,4 +79,8 @@ public enum FSkinTexture implements FImage {
|
||||
public void drawRotated(Graphics g, float x, float y, float w, float h, float rotation) {
|
||||
g.drawRotatedImage(texture, x, y, w, h, x + w / 2, y + h / 2, rotation);
|
||||
}
|
||||
|
||||
public void drawFlipped(Graphics g, float x, float y, float w, float h) {
|
||||
g.drawFlippedImage(texture, x, y, w, h);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,28 @@
|
||||
package forge.screens.planarconquest;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.deck.CardPool;
|
||||
import forge.assets.FSkinTexture;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.CardManager;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.itemmanager.filters.CardColorFilter;
|
||||
import forge.itemmanager.filters.CardRarityFilter;
|
||||
import forge.itemmanager.filters.CardTypeFilter;
|
||||
import forge.itemmanager.filters.ItemFilter;
|
||||
import forge.model.FModel;
|
||||
import forge.planarconquest.ConquestData;
|
||||
import forge.planarconquest.ConquestPlane;
|
||||
import forge.screens.FScreen;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.Utils;
|
||||
|
||||
public class ConquestAEtherScreen extends FScreen {
|
||||
private static final float PULL_BTN_HEIGHT = 1.2f * Utils.AVG_FINGER_HEIGHT;
|
||||
|
||||
private final AEtherManager lstAEther = add(new AEtherManager());
|
||||
private final FLabel lblTip = add(new FLabel.Builder()
|
||||
.text("Filter above list then press below button\nto unlock a random card from the filtered list.")
|
||||
.textColor(FLabel.INLINE_LABEL_COLOR)
|
||||
.align(HAlignment.CENTER).font(FSkinFont.get(12)).build());
|
||||
private final FLabel btnPull = add(new PullButton());
|
||||
|
||||
private final AEtherDisplay display = add(new AEtherDisplay());
|
||||
private final Set<PaperCard> pool = new HashSet<PaperCard>();
|
||||
private final Set<PaperCard> filteredPool = new HashSet<PaperCard>();
|
||||
private int shardCost;
|
||||
|
||||
public ConquestAEtherScreen() {
|
||||
super("", ConquestMenu.getMenu());
|
||||
|
||||
lstAEther.setup(ItemManagerConfig.CONQUEST_AETHER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,30 +32,33 @@ public class ConquestAEtherScreen extends FScreen {
|
||||
|
||||
setHeaderCaption(model.getName());
|
||||
|
||||
CardPool pool = new CardPool();
|
||||
pool.clear();
|
||||
for (PaperCard card : plane.getCardPool().getAllCards()) {
|
||||
if (!model.hasUnlockedCard(card)) {
|
||||
pool.add(card);
|
||||
}
|
||||
}
|
||||
lstAEther.setPool(pool, true);
|
||||
updateFilteredPool();
|
||||
}
|
||||
|
||||
private void calculateShardCost() {
|
||||
shardCost = FModel.getConquest().calculateShardCost(lstAEther.getFilteredItems(), lstAEther.getPool().countDistinct());
|
||||
updatePullButton();
|
||||
private void updateFilteredPool() {
|
||||
filteredPool.clear();
|
||||
for (PaperCard card : pool) {
|
||||
filteredPool.add(card);
|
||||
}
|
||||
updateShardCost();
|
||||
}
|
||||
|
||||
private void updatePullButton() {
|
||||
private void updateShardCost() {
|
||||
shardCost = FModel.getConquest().calculateShardCost(filteredPool, pool.size());
|
||||
int availableShards = FModel.getConquest().getModel().getAEtherShards();
|
||||
btnPull.setEnabled(shardCost > 0 && shardCost <= availableShards);
|
||||
btnPull.setText((shardCost > 0 ? String.valueOf(shardCost) : "---") + " / " + String.valueOf(availableShards));
|
||||
}
|
||||
|
||||
private void pullFromTheAEther() {
|
||||
ConquestData model = FModel.getConquest().getModel();
|
||||
PaperCard card = Aggregates.random(lstAEther.getFilteredItems()).getKey();
|
||||
lstAEther.removeItem(card, 1);
|
||||
PaperCard card = Aggregates.random(filteredPool);
|
||||
pool.remove(card);
|
||||
filteredPool.remove(card);
|
||||
|
||||
ConquestRewardDialog.show("Card pulled from the AEther", card, null);
|
||||
|
||||
@@ -79,61 +66,32 @@ public class ConquestAEtherScreen extends FScreen {
|
||||
model.unlockCard(card);
|
||||
model.saveData();
|
||||
|
||||
updatePullButton();
|
||||
updateShardCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLayout(float startY, float width, float height) {
|
||||
float padding = ItemFilter.PADDING;
|
||||
float x = padding;
|
||||
float w = width - 2 * padding;
|
||||
float tipLabelHeight = lblTip.getAutoSizeBounds().height;
|
||||
lstAEther.setBounds(x, startY, w, height - startY - PULL_BTN_HEIGHT - tipLabelHeight - 4 * padding);
|
||||
lblTip.setBounds(x, height - PULL_BTN_HEIGHT - tipLabelHeight - 2 * padding, width, tipLabelHeight);
|
||||
btnPull.setBounds(x, height - PULL_BTN_HEIGHT - padding, w, PULL_BTN_HEIGHT);
|
||||
display.setBounds(0, startY, width, height - startY);
|
||||
}
|
||||
|
||||
private class AEtherManager extends CardManager {
|
||||
public AEtherManager() {
|
||||
super(false);
|
||||
setCaption("The AEther");
|
||||
}
|
||||
|
||||
private class AEtherDisplay extends FDisplayObject {
|
||||
@Override
|
||||
protected void addDefaultFilters() {
|
||||
addFilter(new CardColorFilter(this));
|
||||
addFilter(new CardRarityFilter(this));
|
||||
addFilter(new CardTypeFilter(this));
|
||||
}
|
||||
public void draw(Graphics g) {
|
||||
float w = getWidth();
|
||||
float h = getHeight();
|
||||
|
||||
@Override
|
||||
public void updateView(final boolean forceFilter, final Iterable<PaperCard> itemsToSelect) {
|
||||
super.updateView(forceFilter, itemsToSelect);
|
||||
calculateShardCost();
|
||||
}
|
||||
}
|
||||
FSkinTexture background = FSkinTexture.BG_SPACE;
|
||||
float backgroundHeight = w * background.getHeight() / background.getWidth();
|
||||
|
||||
private class PullButton extends FLabel {
|
||||
protected PullButton() {
|
||||
super(new FLabel.ButtonBuilder().font(FSkinFont.forHeight(PULL_BTN_HEIGHT * 0.45f))
|
||||
.icon(FSkinImage.AETHER_SHARD).iconScaleFactor(1f).command(new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
pullFromTheAEther();
|
||||
}
|
||||
}));
|
||||
}
|
||||
if (backgroundHeight < h / 2) {
|
||||
g.fillRect(Color.BLACK, 0, 0, w, h); //ensure no gap between top and bottom images
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawContent(Graphics g, float x, float y, float w, float h) {
|
||||
FSkinFont font = getFont();
|
||||
float textHeight = font.getCapHeight() * 1.25f;
|
||||
y += h / 2 - textHeight;
|
||||
g.drawText("Pull from the AEther", font, getTextColor(), x, y, w, textHeight, false, HAlignment.CENTER, false);
|
||||
y += textHeight;
|
||||
background.draw(g, 0, h - backgroundHeight, w, backgroundHeight);
|
||||
|
||||
//draw shard icon and cost
|
||||
super.drawContent(g, x, y, w, textHeight * 1.25f);
|
||||
g.startClip(0, 0, w, h / 2); //prevent upper image extending beyond halfway point of screen
|
||||
background.drawFlipped(g, 0, 0, w, backgroundHeight);
|
||||
g.endClip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.planarconquest;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import forge.FThreads;
|
||||
@@ -47,7 +46,6 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.BoosterUtils;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.ItemPool;
|
||||
import forge.util.storage.IStorage;
|
||||
import forge.util.storage.StorageImmediatelySerialized;
|
||||
|
||||
@@ -226,17 +224,17 @@ public class ConquestController {
|
||||
return allRewards;
|
||||
}
|
||||
|
||||
public int calculateShardCost(ItemPool<PaperCard> filteredCards, int unfilteredCount) {
|
||||
public int calculateShardCost(Set<PaperCard> filteredCards, int unfilteredCount) {
|
||||
if (filteredCards.isEmpty()) { return 0; }
|
||||
|
||||
ConquestAwardPool pool = FModel.getConquest().getModel().getCurrentPlane().getAwardPool();
|
||||
|
||||
//determine average value of filtered cards
|
||||
int totalValue = 0;
|
||||
for (Entry<PaperCard, Integer> entry : filteredCards) {
|
||||
totalValue += pool.getShardValue(entry.getKey());
|
||||
for (PaperCard card : filteredCards) {
|
||||
totalValue += pool.getShardValue(card);
|
||||
}
|
||||
float averageValue = totalValue / filteredCards.countDistinct();
|
||||
float averageValue = totalValue / filteredCards.size();
|
||||
float multiplier = 1f + (float)FModel.getConquestPreferences().getPrefInt(CQPref.AETHER_MARKUP) / 100f;
|
||||
|
||||
//TODO: Increase multiplier based on average percentage of cards filtered out for each rarity
|
||||
|
||||
Reference in New Issue
Block a user