mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Render wins to unlock commanders
This commit is contained in:
@@ -18,6 +18,8 @@ import forge.model.FModel;
|
|||||||
import forge.planarconquest.ConquestCommander;
|
import forge.planarconquest.ConquestCommander;
|
||||||
import forge.planarconquest.ConquestData;
|
import forge.planarconquest.ConquestData;
|
||||||
import forge.planarconquest.ConquestPlane.Region;
|
import forge.planarconquest.ConquestPlane.Region;
|
||||||
|
import forge.planarconquest.ConquestPlaneData;
|
||||||
|
import forge.planarconquest.ConquestPreferences.CQPref;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
import forge.toolbox.FCardPanel;
|
import forge.toolbox.FCardPanel;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.FContainer;
|
||||||
@@ -37,7 +39,9 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
private static final float LINE_THICKNESS = Utils.scale(1);
|
private static final float LINE_THICKNESS = Utils.scale(1);
|
||||||
private static final float ARROW_ICON_THICKNESS = Utils.scale(3);
|
private static final float ARROW_ICON_THICKNESS = Utils.scale(3);
|
||||||
private static final float REGION_SLIDER_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.7f);
|
private static final float REGION_SLIDER_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.7f);
|
||||||
private static final FSkinFont FONT = FSkinFont.get(15);
|
private static final FSkinFont REGION_NAME_FONT = FSkinFont.get(15);
|
||||||
|
private static final FSkinFont UNLOCK_WINS_FONT = FSkinFont.get(20);
|
||||||
|
private static final float COMMANDER_ROW_HEIGHT = 2 * Utils.AVG_FINGER_HEIGHT;
|
||||||
|
|
||||||
private final RegionDisplay regionDisplay = add(new RegionDisplay());
|
private final RegionDisplay regionDisplay = add(new RegionDisplay());
|
||||||
private final CommanderRow commanderRow = add(new CommanderRow());
|
private final CommanderRow commanderRow = add(new CommanderRow());
|
||||||
@@ -63,7 +67,7 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
float y = startY;
|
float y = startY;
|
||||||
regionDisplay.setBounds(0, y, width, width / CardRenderer.CARD_ART_RATIO + REGION_SLIDER_HEIGHT);
|
regionDisplay.setBounds(0, y, width, width / CardRenderer.CARD_ART_RATIO + REGION_SLIDER_HEIGHT);
|
||||||
y += regionDisplay.getHeight() + PADDING;
|
y += regionDisplay.getHeight() + PADDING;
|
||||||
commanderRow.setBounds(0, y, width, 2 * Utils.AVG_FINGER_HEIGHT);
|
commanderRow.setBounds(0, y, width, COMMANDER_ROW_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RegionDisplay extends FContainer {
|
private class RegionDisplay extends FContainer {
|
||||||
@@ -148,7 +152,7 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
if (model != null) {
|
if (model != null) {
|
||||||
Region region = model.getCurrentRegion();
|
Region region = model.getCurrentRegion();
|
||||||
g.drawImage((FImage)region.getArt(), 0, 0, w, y);
|
g.drawImage((FImage)region.getArt(), 0, 0, w, y);
|
||||||
textRenderer.drawText(g, region.getName(), FONT, FORE_COLOR, REGION_SLIDER_HEIGHT, y, w - 2 * REGION_SLIDER_HEIGHT, REGION_SLIDER_HEIGHT, y, REGION_SLIDER_HEIGHT, false, HAlignment.CENTER, true);
|
textRenderer.drawText(g, region.getName(), REGION_NAME_FONT, FORE_COLOR, REGION_SLIDER_HEIGHT, y, w - 2 * REGION_SLIDER_HEIGHT, REGION_SLIDER_HEIGHT, y, REGION_SLIDER_HEIGHT, false, HAlignment.CENTER, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,8 +212,9 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
float h = getHeight();
|
float h = getHeight();
|
||||||
g.drawRect(LINE_THICKNESS, BORDER_COLOR, -LINE_THICKNESS, -LINE_THICKNESS, w + 2 * LINE_THICKNESS, h + 2 * LINE_THICKNESS);
|
g.drawRect(LINE_THICKNESS, BORDER_COLOR, -LINE_THICKNESS, -LINE_THICKNESS, w + 2 * LINE_THICKNESS, h + 2 * LINE_THICKNESS);
|
||||||
|
|
||||||
|
ConquestPlaneData planeData = model.getCurrentPlaneData();
|
||||||
if (card == null) {
|
if (card == null) {
|
||||||
List<ConquestCommander> commanders = model.getCurrentPlaneData().getCommanders();
|
List<ConquestCommander> commanders = planeData.getCommanders();
|
||||||
if (index < commanders.size()) {
|
if (index < commanders.size()) {
|
||||||
card = Card.getCardForUi(commanders.get(index).getCard()).getView();
|
card = Card.getCardForUi(commanders.get(index).getCard()).getView();
|
||||||
}
|
}
|
||||||
@@ -217,6 +222,15 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
if (card != null) {
|
if (card != null) {
|
||||||
CardRenderer.drawCardWithOverlays(g, card, 0, 0, w, h, CardStackPosition.Top);
|
CardRenderer.drawCardWithOverlays(g, card, 0, 0, w, h, CardStackPosition.Top);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int winsToUnlock = index * FModel.getConquestPreferences().getPrefInt(CQPref.WINS_TO_UNLOCK_COMMANDER);
|
||||||
|
if (planeData.getWins() < winsToUnlock) {
|
||||||
|
g.drawText(String.valueOf(winsToUnlock), UNLOCK_WINS_FONT, FORE_COLOR, 0, 0, w, h, false, HAlignment.CENTER, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,8 @@ import forge.planarconquest.ConquestPlane.Region;
|
|||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public final class ConquestData {
|
public final class ConquestData {
|
||||||
/** Holds the latest version of the Conquest Data. */
|
/** Holds the latest version of the Conquest Data. */
|
||||||
@@ -124,6 +122,7 @@ public final class ConquestData {
|
|||||||
public void addWin() {
|
public void addWin() {
|
||||||
wins++;
|
wins++;
|
||||||
winStreakCurrent++;
|
winStreakCurrent++;
|
||||||
|
getCurrentPlaneData().addWin();
|
||||||
|
|
||||||
if (winStreakCurrent > winStreakBest) {
|
if (winStreakCurrent > winStreakBest) {
|
||||||
winStreakBest = winStreakCurrent;
|
winStreakBest = winStreakCurrent;
|
||||||
@@ -133,6 +132,7 @@ public final class ConquestData {
|
|||||||
public void addLoss() {
|
public void addLoss() {
|
||||||
losses++;
|
losses++;
|
||||||
winStreakCurrent = 0;
|
winStreakCurrent = 0;
|
||||||
|
getCurrentPlaneData().addLoss();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWins() {
|
public int getWins() {
|
||||||
|
|||||||
@@ -6,7 +6,25 @@ import java.util.List;
|
|||||||
public class ConquestPlaneData {
|
public class ConquestPlaneData {
|
||||||
private final List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
private final List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
||||||
|
|
||||||
|
private int wins, losses;
|
||||||
|
|
||||||
public List<ConquestCommander> getCommanders() {
|
public List<ConquestCommander> getCommanders() {
|
||||||
return commanders;
|
return commanders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addWin() {
|
||||||
|
wins++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLoss() {
|
||||||
|
losses++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWins() {
|
||||||
|
return wins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLosses() {
|
||||||
|
return losses;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class ConquestPreferences extends PreferencesStore<ConquestPreferences.CQ
|
|||||||
* Preference identifiers, and their default values.
|
* Preference identifiers, and their default values.
|
||||||
*/
|
*/
|
||||||
public static enum CQPref {
|
public static enum CQPref {
|
||||||
CURRENT_CONQUEST("DEFAULT");
|
CURRENT_CONQUEST("DEFAULT"),
|
||||||
|
WINS_TO_UNLOCK_COMMANDER("10");
|
||||||
|
|
||||||
private final String strDefaultVal;
|
private final String strDefaultVal;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user