mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Flesh out Planeswalk support
This commit is contained in:
@@ -56,6 +56,7 @@ public class TextRenderer {
|
||||
symbolLookup.put("S", FSkinImage.MANA_SNOW);
|
||||
symbolLookup.put("T", FSkinImage.TAP);
|
||||
symbolLookup.put("AE", FSkinImage.AETHER_SHARD);
|
||||
symbolLookup.put("PW", FSkinImage.PW_BADGE_COMMON);
|
||||
}
|
||||
|
||||
public static String startColor(Color color) {
|
||||
|
||||
@@ -39,10 +39,10 @@ import forge.util.Callback;
|
||||
import forge.util.Utils;
|
||||
|
||||
public class ConquestAEtherScreen extends FScreen {
|
||||
private static final Color FILTER_BUTTON_COLOR = ConquestMultiverseScreen.LOCATION_BAR_COLOR;
|
||||
private static final FSkinColor FILTER_BUTTON_TEXT_COLOR = FSkinColor.getStandardColor(ConquestMultiverseScreen.LOCATION_BAR_TEXT_COLOR);
|
||||
private static final FSkinColor FILTER_BUTTON_PRESSED_COLOR = FSkinColor.getStandardColor(FSkinColor.alphaColor(Color.WHITE, 0.1f));
|
||||
private static final FSkinFont LABEL_FONT = FSkinFont.get(16);
|
||||
public static final Color FILTER_BUTTON_COLOR = ConquestMultiverseScreen.LOCATION_BAR_COLOR;
|
||||
public static final FSkinColor FILTER_BUTTON_TEXT_COLOR = FSkinColor.getStandardColor(ConquestMultiverseScreen.LOCATION_BAR_TEXT_COLOR);
|
||||
public static final FSkinColor FILTER_BUTTON_PRESSED_COLOR = FSkinColor.getStandardColor(FSkinColor.alphaColor(Color.WHITE, 0.1f));
|
||||
public static final FSkinFont LABEL_FONT = FSkinFont.get(16);
|
||||
private static final FSkinFont MESSAGE_FONT = FSkinFont.get(14);
|
||||
private static final float PADDING = Utils.scale(5f);
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ public class ConquestMultiverseScreen extends FScreen {
|
||||
ConquestEventRecord record = model.getCurrentPlaneData().getEventRecord(loc);
|
||||
if (record.getWins(activeBattle.getTier()) == 1 && record.getHighestConqueredTier() == activeBattle.getTier()) {
|
||||
//if first time conquering event at the selected tier, show animation of new badge being positioned on location
|
||||
model.rewardPlaneswalkEmblems(FModel.getConquestPreferences().getPrefInt(CQPref.PLANESWALK_CONQUER_EMBLEMS));
|
||||
model.saveData();
|
||||
planeGrid.animateBadgeIntoPosition(loc, activeBattle.getTier());
|
||||
}
|
||||
else {
|
||||
@@ -148,7 +150,7 @@ public class ConquestMultiverseScreen extends FScreen {
|
||||
awardShards(2 * FModel.getConquestPreferences().getPrefInt(CQPref.AETHER_WHEEL_SHARDS), false);
|
||||
break;
|
||||
case PLANESWALK:
|
||||
awardPlaneswalkCharge();
|
||||
awardBonusPlaneswalkEmblems(FModel.getConquestPreferences().getPrefInt(CQPref.PLANESWALK_WHEEL_EMBLEMS));
|
||||
break;
|
||||
case CHAOS:
|
||||
launchChaosBattle();
|
||||
@@ -226,9 +228,27 @@ public class ConquestMultiverseScreen extends FScreen {
|
||||
FOptionPane.showMessageDialog(String.valueOf(shards), FSkinFont.get(32), message, SHARD_IMAGE);
|
||||
}
|
||||
|
||||
private void awardPlaneswalkCharge() {
|
||||
//TODO
|
||||
FOptionPane.showMessageDialog(null, "Received Planeswalk Charge");
|
||||
private static final FImage EMBLEM_IMAGE = new FImage() {
|
||||
final float size = Forge.getScreenWidth() * 0.6f;
|
||||
@Override
|
||||
public float getWidth() {
|
||||
return size;
|
||||
}
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return size;
|
||||
}
|
||||
@Override
|
||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||
FSkinImage.PW_BADGE_COMMON.draw(g, x, y, w, h);
|
||||
}
|
||||
};
|
||||
|
||||
private void awardBonusPlaneswalkEmblems(int emblems) {
|
||||
String message = "Received Bonus Planeswalk Emblems";
|
||||
model.rewardPlaneswalkEmblems(emblems);
|
||||
model.saveData();
|
||||
FOptionPane.showMessageDialog(String.valueOf(emblems), FSkinFont.get(32), message, EMBLEM_IMAGE);
|
||||
}
|
||||
|
||||
private void launchEvent() {
|
||||
|
||||
@@ -90,6 +90,10 @@ public class ConquestPlaneSelector extends FDisplayObject {
|
||||
artIndex = 0;
|
||||
currentArt = CardRenderer.getCardArt(getSelectedPlane().getPlaneCards().get(artIndex));
|
||||
timer.restart();
|
||||
onSelectionChange();
|
||||
}
|
||||
|
||||
protected void onSelectionChange() {
|
||||
}
|
||||
|
||||
private void incrementSelectedIndex(int dir) {
|
||||
|
||||
@@ -1,11 +1,32 @@
|
||||
package forge.screens.planarconquest;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.model.FModel;
|
||||
import forge.planarconquest.ConquestData;
|
||||
import forge.planarconquest.ConquestPlane;
|
||||
import forge.planarconquest.ConquestPreferences;
|
||||
import forge.planarconquest.ConquestPreferences.CQPref;
|
||||
import forge.screens.FScreen;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FLabel;
|
||||
|
||||
public class ConquestPlaneswalkScreen extends FScreen {
|
||||
private ConquestPlaneSelector planeSelector = add(new ConquestPlaneSelector());
|
||||
private static final float PADDING = FList.PADDING;
|
||||
|
||||
private final ConquestPlaneSelector planeSelector = add(new ConquestPlaneSelector() {
|
||||
@Override
|
||||
protected void onSelectionChange() {
|
||||
if (btnPlaneswalk == null) { return; }
|
||||
btnPlaneswalk.updateCaption();
|
||||
}
|
||||
});
|
||||
private final PlaneswalkButton btnPlaneswalk = add(new PlaneswalkButton());
|
||||
|
||||
public ConquestPlaneswalkScreen() {
|
||||
super("", ConquestMenu.getMenu());
|
||||
@@ -22,5 +43,56 @@ public class ConquestPlaneswalkScreen extends FScreen {
|
||||
@Override
|
||||
protected void doLayout(float startY, float width, float height) {
|
||||
planeSelector.setBounds(0, startY, width, height - startY);
|
||||
|
||||
float buttonWidth = width / 2;
|
||||
float buttonHeight = btnPlaneswalk.getFont().getCapHeight() * 2;
|
||||
btnPlaneswalk.setBounds((width - buttonWidth) / 2, height - buttonHeight - PADDING, buttonWidth, buttonHeight);
|
||||
}
|
||||
|
||||
private class PlaneswalkButton extends FLabel {
|
||||
private int unlockCost;
|
||||
|
||||
private PlaneswalkButton() {
|
||||
super(new FLabel.Builder().font(FSkinFont.get(20)).parseSymbols().pressedColor(ConquestAEtherScreen.FILTER_BUTTON_PRESSED_COLOR)
|
||||
.textColor(ConquestAEtherScreen.FILTER_BUTTON_TEXT_COLOR).alphaComposite(1f).align(HAlignment.CENTER));
|
||||
setCommand(new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
ConquestData model = FModel.getConquest().getModel();
|
||||
ConquestPlane selectedPlane = planeSelector.getSelectedPlane();
|
||||
if (model.isPlaneUnlocked(selectedPlane)) {
|
||||
model.planeswalkTo(selectedPlane);
|
||||
model.saveData();
|
||||
Forge.back();
|
||||
}
|
||||
else if (model.spendPlaneswalkEmblems(unlockCost)) {
|
||||
model.unlockPlane(selectedPlane);
|
||||
model.saveData();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateCaption() {
|
||||
ConquestData model = FModel.getConquest().getModel();
|
||||
ConquestPlane selectedPlane = planeSelector.getSelectedPlane();
|
||||
if (model.isPlaneUnlocked(selectedPlane)) {
|
||||
unlockCost = 0;
|
||||
setText("Planeswalk");
|
||||
}
|
||||
else {
|
||||
ConquestPreferences prefs = FModel.getConquestPreferences();
|
||||
unlockCost = prefs.getPrefInt(CQPref.PLANESWALK_FIRST_UNLOCK) + prefs.getPrefInt(CQPref.PLANESWALK_UNLOCK_INCREASE) * (model.getUnlockedPlaneCount() - 1);
|
||||
setText("Unlock {PW}" + unlockCost);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawContent(Graphics g, float w, float h, final boolean pressed) {
|
||||
if (!pressed) {
|
||||
g.fillRect(ConquestAEtherScreen.FILTER_BUTTON_COLOR, 0, 0, w, h);
|
||||
}
|
||||
super.drawContent(g, w, h, pressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ public class ConquestPrefsScreen extends FScreen {
|
||||
|
||||
private enum PrefsGroup {
|
||||
AETHER,
|
||||
BOOSTER
|
||||
BOOSTER,
|
||||
PLANESWALK,
|
||||
CHAOS
|
||||
}
|
||||
|
||||
private FScrollPane scroller = add(new FScrollPane() {
|
||||
@@ -63,6 +65,17 @@ public class ConquestPrefsScreen extends FScreen {
|
||||
scroller.add(new PrefsOption("Uncommons", CQPref.BOOSTER_UNCOMMONS, PrefsGroup.BOOSTER));
|
||||
scroller.add(new PrefsOption("Rares", CQPref.BOOSTER_RARES, PrefsGroup.BOOSTER));
|
||||
scroller.add(new PrefsOption("Boosters per Mythic", CQPref.BOOSTERS_PER_MYTHIC, PrefsGroup.BOOSTER));
|
||||
|
||||
scroller.add(new PrefsHeader("Planeswalk Emblems", FSkinImage.PW_BADGE_COMMON, PrefsGroup.PLANESWALK));
|
||||
scroller.add(new PrefsOption("Base Conquer Reward", CQPref.PLANESWALK_CONQUER_EMBLEMS, PrefsGroup.PLANESWALK));
|
||||
scroller.add(new PrefsOption("Chaos Wheel Bonus", CQPref.PLANESWALK_WHEEL_EMBLEMS, PrefsGroup.PLANESWALK));
|
||||
scroller.add(new PrefsOption("First Plane Unlock Cost", CQPref.PLANESWALK_FIRST_UNLOCK, PrefsGroup.PLANESWALK));
|
||||
scroller.add(new PrefsOption("Cost Increase Per Unlock", CQPref.PLANESWALK_UNLOCK_INCREASE, PrefsGroup.PLANESWALK));
|
||||
|
||||
scroller.add(new PrefsHeader("Chaos Battles", FSkinImage.CHAOS, PrefsGroup.CHAOS));
|
||||
scroller.add(new PrefsOption("Wins For Medium AI", CQPref.CHAOS_BATTLE_WINS_MEDIUMAI, PrefsGroup.CHAOS));
|
||||
scroller.add(new PrefsOption("Wins For Hard AI", CQPref.CHAOS_BATTLE_WINS_HARDAI, PrefsGroup.CHAOS));
|
||||
scroller.add(new PrefsOption("Wins For Expert AI", CQPref.CHAOS_BATTLE_WINS_EXPERTAI, PrefsGroup.CHAOS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,6 +52,7 @@ public final class ConquestData {
|
||||
private ConquestLocation currentLocation;
|
||||
private int selectedCommanderIndex;
|
||||
private int aetherShards;
|
||||
private int planeswalkEmblems;
|
||||
|
||||
private final File directory;
|
||||
private final String xmlFilename;
|
||||
@@ -93,6 +94,7 @@ public final class ConquestData {
|
||||
CardDb cardDb = FModel.getMagicDb().getCommonCards();
|
||||
setPlaneswalker(xml.read("planeswalker", cardDb));
|
||||
aetherShards = xml.read("aetherShards", aetherShards);
|
||||
planeswalkEmblems = xml.read("planeswalkEmblems", planeswalkEmblems);
|
||||
currentLocation = xml.read("currentLocation", ConquestLocation.class);
|
||||
selectedCommanderIndex = xml.read("selectedCommanderIndex", selectedCommanderIndex);
|
||||
chaosBattleRecord0 = xml.read("chaosBattleRecord", ConquestRecord.class);
|
||||
@@ -142,17 +144,32 @@ public final class ConquestData {
|
||||
getCurrentPlaneData().setLocation(currentLocation0);
|
||||
}
|
||||
|
||||
private ConquestPlaneData getOrCreatePlaneData(ConquestPlane plane) {
|
||||
ConquestPlaneData planeData = planeDataMap.get(plane.getName());
|
||||
if (planeData == null) {
|
||||
planeData = new ConquestPlaneData(plane);
|
||||
planeDataMap.put(plane.getName(), planeData);
|
||||
}
|
||||
return planeData;
|
||||
private ConquestPlaneData getPlaneData(ConquestPlane plane) {
|
||||
return planeDataMap.get(plane.getName());
|
||||
}
|
||||
public ConquestPlaneData getCurrentPlaneData() {
|
||||
return getPlaneData(getCurrentPlane());
|
||||
}
|
||||
|
||||
public ConquestPlaneData getCurrentPlaneData() {
|
||||
return getOrCreatePlaneData(getCurrentPlane());
|
||||
public boolean isPlaneUnlocked(ConquestPlane plane) {
|
||||
return planeDataMap.containsKey(plane.getName());
|
||||
}
|
||||
|
||||
public int getUnlockedPlaneCount() {
|
||||
return planeDataMap.size();
|
||||
}
|
||||
|
||||
public void unlockPlane(ConquestPlane plane) {
|
||||
if (isPlaneUnlocked(plane)) { return; }
|
||||
|
||||
planeDataMap.put(plane.getName(), new ConquestPlaneData(plane));
|
||||
}
|
||||
|
||||
public void planeswalkTo(ConquestPlane plane) {
|
||||
ConquestPlaneData planeData = getPlaneData(plane);
|
||||
if (planeData == null) { return; }
|
||||
|
||||
setCurrentLocation(planeData.getLocation());
|
||||
}
|
||||
|
||||
public ConquestCommander getSelectedCommander() {
|
||||
@@ -203,25 +220,45 @@ public final class ConquestData {
|
||||
}
|
||||
|
||||
public void addWin(ConquestBattle event) {
|
||||
getOrCreatePlaneData(event.getLocation().getPlane()).addWin(event);
|
||||
ConquestPlaneData planeData = getPlaneData(event.getLocation().getPlane());
|
||||
if (planeData == null) { return; }
|
||||
|
||||
planeData.addWin(event);
|
||||
getSelectedCommander().getRecord().addWin();
|
||||
event.setConquered(true);
|
||||
}
|
||||
|
||||
public void addLoss(ConquestBattle event) {
|
||||
getOrCreatePlaneData(event.getLocation().getPlane()).addLoss(event);
|
||||
ConquestPlaneData planeData = getPlaneData(event.getLocation().getPlane());
|
||||
if (planeData == null) { return; }
|
||||
|
||||
planeData.addLoss(event);
|
||||
getSelectedCommander().getRecord().addLoss();
|
||||
}
|
||||
|
||||
public int getAEtherShards() {
|
||||
return aetherShards;
|
||||
}
|
||||
public void rewardAEtherShards(int aetherShards0) {
|
||||
aetherShards += aetherShards0;
|
||||
public void rewardAEtherShards(int shards) {
|
||||
aetherShards += shards;
|
||||
}
|
||||
public boolean spendAEtherShards(int aetherShards0) {
|
||||
if (aetherShards >= aetherShards0) {
|
||||
aetherShards -= aetherShards0;
|
||||
public boolean spendAEtherShards(int shards) {
|
||||
if (aetherShards >= shards) {
|
||||
aetherShards -= shards;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getPlaneswalkEmblems() {
|
||||
return planeswalkEmblems;
|
||||
}
|
||||
public void rewardPlaneswalkEmblems(int emblems) {
|
||||
planeswalkEmblems += emblems;
|
||||
}
|
||||
public boolean spendPlaneswalkEmblems(int emblems) {
|
||||
if (planeswalkEmblems >= emblems) {
|
||||
planeswalkEmblems -= emblems;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -42,6 +42,11 @@ public class ConquestPreferences extends PreferencesStore<ConquestPreferences.CQ
|
||||
BOOSTER_RARES("1"),
|
||||
BOOSTERS_PER_MYTHIC("8"),
|
||||
|
||||
PLANESWALK_CONQUER_EMBLEMS("1"),
|
||||
PLANESWALK_WHEEL_EMBLEMS("5"),
|
||||
PLANESWALK_FIRST_UNLOCK("5"),
|
||||
PLANESWALK_UNLOCK_INCREASE("5"),
|
||||
|
||||
CHAOS_BATTLE_WINS_MEDIUMAI("2"),
|
||||
CHAOS_BATTLE_WINS_HARDAI("5"),
|
||||
CHAOS_BATTLE_WINS_EXPERTAI("10");
|
||||
|
||||
Reference in New Issue
Block a user