mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +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) {
|
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);
|
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;
|
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.Graphics;
|
||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinTexture;
|
||||||
import forge.assets.FSkinImage;
|
|
||||||
import forge.deck.CardPool;
|
|
||||||
import forge.item.PaperCard;
|
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.model.FModel;
|
||||||
import forge.planarconquest.ConquestData;
|
import forge.planarconquest.ConquestData;
|
||||||
import forge.planarconquest.ConquestPlane;
|
import forge.planarconquest.ConquestPlane;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FDisplayObject;
|
||||||
import forge.toolbox.FLabel;
|
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
import forge.util.Utils;
|
|
||||||
|
|
||||||
public class ConquestAEtherScreen extends FScreen {
|
public class ConquestAEtherScreen extends FScreen {
|
||||||
private static final float PULL_BTN_HEIGHT = 1.2f * Utils.AVG_FINGER_HEIGHT;
|
private final AEtherDisplay display = add(new AEtherDisplay());
|
||||||
|
private final Set<PaperCard> pool = new HashSet<PaperCard>();
|
||||||
private final AEtherManager lstAEther = add(new AEtherManager());
|
private final Set<PaperCard> filteredPool = new HashSet<PaperCard>();
|
||||||
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 int shardCost;
|
private int shardCost;
|
||||||
|
|
||||||
public ConquestAEtherScreen() {
|
public ConquestAEtherScreen() {
|
||||||
super("", ConquestMenu.getMenu());
|
super("", ConquestMenu.getMenu());
|
||||||
|
|
||||||
lstAEther.setup(ItemManagerConfig.CONQUEST_AETHER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,30 +32,33 @@ public class ConquestAEtherScreen extends FScreen {
|
|||||||
|
|
||||||
setHeaderCaption(model.getName());
|
setHeaderCaption(model.getName());
|
||||||
|
|
||||||
CardPool pool = new CardPool();
|
pool.clear();
|
||||||
for (PaperCard card : plane.getCardPool().getAllCards()) {
|
for (PaperCard card : plane.getCardPool().getAllCards()) {
|
||||||
if (!model.hasUnlockedCard(card)) {
|
if (!model.hasUnlockedCard(card)) {
|
||||||
pool.add(card);
|
pool.add(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lstAEther.setPool(pool, true);
|
updateFilteredPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateShardCost() {
|
private void updateFilteredPool() {
|
||||||
shardCost = FModel.getConquest().calculateShardCost(lstAEther.getFilteredItems(), lstAEther.getPool().countDistinct());
|
filteredPool.clear();
|
||||||
updatePullButton();
|
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();
|
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() {
|
private void pullFromTheAEther() {
|
||||||
ConquestData model = FModel.getConquest().getModel();
|
ConquestData model = FModel.getConquest().getModel();
|
||||||
PaperCard card = Aggregates.random(lstAEther.getFilteredItems()).getKey();
|
PaperCard card = Aggregates.random(filteredPool);
|
||||||
lstAEther.removeItem(card, 1);
|
pool.remove(card);
|
||||||
|
filteredPool.remove(card);
|
||||||
|
|
||||||
ConquestRewardDialog.show("Card pulled from the AEther", card, null);
|
ConquestRewardDialog.show("Card pulled from the AEther", card, null);
|
||||||
|
|
||||||
@@ -79,61 +66,32 @@ public class ConquestAEtherScreen extends FScreen {
|
|||||||
model.unlockCard(card);
|
model.unlockCard(card);
|
||||||
model.saveData();
|
model.saveData();
|
||||||
|
|
||||||
updatePullButton();
|
updateShardCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float startY, float width, float height) {
|
protected void doLayout(float startY, float width, float height) {
|
||||||
float padding = ItemFilter.PADDING;
|
display.setBounds(0, startY, width, height - startY);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AEtherManager extends CardManager {
|
|
||||||
public AEtherManager() {
|
|
||||||
super(false);
|
|
||||||
setCaption("The AEther");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class AEtherDisplay extends FDisplayObject {
|
||||||
@Override
|
@Override
|
||||||
protected void addDefaultFilters() {
|
public void draw(Graphics g) {
|
||||||
addFilter(new CardColorFilter(this));
|
float w = getWidth();
|
||||||
addFilter(new CardRarityFilter(this));
|
float h = getHeight();
|
||||||
addFilter(new CardTypeFilter(this));
|
|
||||||
|
FSkinTexture background = FSkinTexture.BG_SPACE;
|
||||||
|
float backgroundHeight = w * background.getHeight() / background.getWidth();
|
||||||
|
|
||||||
|
if (backgroundHeight < h / 2) {
|
||||||
|
g.fillRect(Color.BLACK, 0, 0, w, h); //ensure no gap between top and bottom images
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
background.draw(g, 0, h - backgroundHeight, w, backgroundHeight);
|
||||||
public void updateView(final boolean forceFilter, final Iterable<PaperCard> itemsToSelect) {
|
|
||||||
super.updateView(forceFilter, itemsToSelect);
|
|
||||||
calculateShardCost();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PullButton extends FLabel {
|
g.startClip(0, 0, w, h / 2); //prevent upper image extending beyond halfway point of screen
|
||||||
protected PullButton() {
|
background.drawFlipped(g, 0, 0, w, backgroundHeight);
|
||||||
super(new FLabel.ButtonBuilder().font(FSkinFont.forHeight(PULL_BTN_HEIGHT * 0.45f))
|
g.endClip();
|
||||||
.icon(FSkinImage.AETHER_SHARD).iconScaleFactor(1f).command(new FEventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(FEvent e) {
|
|
||||||
pullFromTheAEther();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
//draw shard icon and cost
|
|
||||||
super.drawContent(g, x, y, w, textHeight * 1.25f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package forge.planarconquest;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
@@ -47,7 +46,6 @@ import forge.properties.ForgePreferences.FPref;
|
|||||||
import forge.quest.BoosterUtils;
|
import forge.quest.BoosterUtils;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.ItemPool;
|
|
||||||
import forge.util.storage.IStorage;
|
import forge.util.storage.IStorage;
|
||||||
import forge.util.storage.StorageImmediatelySerialized;
|
import forge.util.storage.StorageImmediatelySerialized;
|
||||||
|
|
||||||
@@ -226,17 +224,17 @@ public class ConquestController {
|
|||||||
return allRewards;
|
return allRewards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int calculateShardCost(ItemPool<PaperCard> filteredCards, int unfilteredCount) {
|
public int calculateShardCost(Set<PaperCard> filteredCards, int unfilteredCount) {
|
||||||
if (filteredCards.isEmpty()) { return 0; }
|
if (filteredCards.isEmpty()) { return 0; }
|
||||||
|
|
||||||
ConquestAwardPool pool = FModel.getConquest().getModel().getCurrentPlane().getAwardPool();
|
ConquestAwardPool pool = FModel.getConquest().getModel().getCurrentPlane().getAwardPool();
|
||||||
|
|
||||||
//determine average value of filtered cards
|
//determine average value of filtered cards
|
||||||
int totalValue = 0;
|
int totalValue = 0;
|
||||||
for (Entry<PaperCard, Integer> entry : filteredCards) {
|
for (PaperCard card : filteredCards) {
|
||||||
totalValue += pool.getShardValue(entry.getKey());
|
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;
|
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
|
//TODO: Increase multiplier based on average percentage of cards filtered out for each rarity
|
||||||
|
|||||||
Reference in New Issue
Block a user