Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ public AdventureModes getAdventureMode(){
return adventureMode;
}

public boolean isCommanderMode() {
return adventureMode != null && adventureMode.isCommanderLike();
}

public int getMaxLife() {
return maxLife;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import forge.adventure.data.ItemData;
import forge.adventure.player.AdventurePlayer;
import forge.adventure.util.AdventureEventController;
import forge.adventure.util.AdventureModes;
import forge.adventure.util.Config;
import forge.adventure.util.Current;
import forge.assets.FImage;
Expand Down Expand Up @@ -51,7 +50,7 @@ public GameType getGameType() {

@Override
public DeckFormat getDeckFormat() {
return AdventurePlayer.current().getAdventureMode() == AdventureModes.Commander ? DeckFormat.Commander : DeckFormat.Adventure;
return AdventurePlayer.current().isCommanderMode() ? DeckFormat.Commander : DeckFormat.Adventure;
}

@Override
Expand All @@ -66,7 +65,7 @@ public boolean usePlayerInventory() {

@Override
protected DeckEditorPage[] getInitialPages() {
if (AdventurePlayer.current().getAdventureMode() == AdventureModes.Commander)
if (AdventurePlayer.current().isCommanderMode())
return new DeckEditorPage[]{
new CollectionCatalogPage(),
new AdventureDeckSectionPage(DeckSection.Commander, ItemManagerConfig.ADVENTURE_EDITOR_POOL),
Expand Down Expand Up @@ -130,7 +129,7 @@ public List<CardEdition> getBasicLandSets(Deck currentDeck) {
public boolean isCommanderEditor() {
if (isLimitedEditor())
return false;
if (AdventurePlayer.current().getAdventureMode() == AdventureModes.Commander)
if (AdventurePlayer.current().isCommanderMode())
return true;
return super.isCommanderEditor();
}
Expand Down Expand Up @@ -1151,4 +1150,3 @@ public void exitWithoutSaving() {
}

}

3 changes: 1 addition & 2 deletions forge-gui-mobile/src/forge/adventure/scene/DuelScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import forge.adventure.stage.GameHUD;
import forge.adventure.stage.IAfterMatch;
import forge.adventure.util.AdventureEventController;
import forge.adventure.util.AdventureModes;
import forge.adventure.util.Config;
import forge.adventure.util.Current;
import forge.assets.FBufferedImage;
Expand Down Expand Up @@ -236,7 +235,7 @@ public void enter() {
String isDeckMissingMsg = "";
if (eventData != null && eventData.eventRules != null) {
mainGameType = eventData.eventRules.gameType;
} else if (AdventurePlayer.current().getAdventureMode() == AdventureModes.Commander){
} else if (AdventurePlayer.current().isCommanderMode()){
mainGameType = GameType.Commander;
} else {
mainGameType = GameType.Adventure;
Expand Down
105 changes: 85 additions & 20 deletions forge-gui-mobile/src/forge/adventure/scene/NewGameScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class NewGameScene extends MenuScene {
private final ImageButton modeHelp;
private DialogData modeSummary;
private final Random rand = new Random();
private String originalEditionLabelText;
private Array<String> originalEditionNames;

private final Array<AdventureModes> modes = new Array<>();

Expand All @@ -69,6 +71,7 @@ private NewGameScene() {
modeHelp = ui.findActor("modeHelp");
colorLabel = ui.findActor("colorIdL");
String colorIdLabel = colorLabel.storedText;
String deckLabel = "[BLACK]" + Forge.getLocalizer().getMessage("lblDeck") + ":";
custom = new Array<>();
colorId = ui.findActor("colorId");
String[] colorSet = Config.instance().colorIds();
Expand Down Expand Up @@ -109,32 +112,41 @@ private NewGameScene() {

starterEdition = ui.findActor("starterEdition");
starterEditionLabel = ui.findActor("starterEditionL");
originalEditionLabelText = starterEditionLabel.storedText;
String[] starterEditions = Config.instance().starterEditions();
String[] starterEditionNames = Config.instance().starterEditionNames();
editionIds = new CardEdition[starterEditions.length];
for (int i = 0; i < editionIds.length; i++)
editionIds[i] = FModel.getMagicDb().getEditions().get(starterEditions[i]);
Array<String> editionNames = new Array<>(editionIds.length);
originalEditionNames = new Array<>(editionIds.length);
for (String editionName : starterEditionNames)
editionNames.add(UIActor.localize(editionName));
starterEdition.setTextList(editionNames);
originalEditionNames.add(UIActor.localize(editionName));
starterEdition.setTextList(originalEditionNames);

// Precon mode: deck names in colorId, set filter in starterEdition
if (Config.instance().hasPreconDecks()) {
modes.add(AdventureModes.Precon);
AdventureModes.Precon.setSelectionName(deckLabel);
AdventureModes.Precon.setModes(Config.instance().filterPreconDecks(0));
}

if (Config.instance().hasCommanderPreconDecks()) {
modes.add(AdventureModes.CommanderPrecon);
AdventureModes.CommanderPrecon.setSelectionName(deckLabel);
AdventureModes.CommanderPrecon.setModes(Config.instance().filterCommanderPreconDecks(0));
}

modes.add(AdventureModes.Chaos);
AdventureModes.Chaos.setSelectionName("[BLACK]" + Forge.getLocalizer().getMessage("lblDeck") + ":");
AdventureModes.Chaos.setSelectionName(deckLabel);
AdventureModes.Chaos.setModes(new Array<>(new String[]{Forge.getLocalizer().getMessage("lblRandomDeck")}));
for (DeckProxy deckProxy : DeckProxy.getAllCustomStarterDecks())
custom.add(deckProxy.getName());
if (!custom.isEmpty()) {
modes.add(AdventureModes.Custom);
AdventureModes.Custom.setSelectionName("[BLACK]" + Forge.getLocalizer().getMessage("lblDeck") + ":");
AdventureModes.Custom.setSelectionName(deckLabel);
AdventureModes.Custom.setModes(custom);
}

// Commander game mode in selection screen
modes.add(AdventureModes.Commander);
AdventureModes.Commander.setSelectionName(colorIdLabel);
AdventureModes.Commander.setModes(colorNames);

String[] modeNames = new String[modes.size];
int constructedIndex = -1;

Expand All @@ -149,8 +161,7 @@ private NewGameScene() {
mode.setCurrentIndex(constructedIndex != -1 ? constructedIndex : 0);

AdventureModes initialMode = modes.get(mode.getCurrentIndex());
starterEdition.setVisible(initialMode == AdventureModes.Standard);
starterEditionLabel.setVisible(initialMode == AdventureModes.Standard);
updateModeSelectionState(initialMode);

gender.setTextList(new String[]{Forge.getLocalizer().getMessage("lblMale") + "[%120][CYAN] \u2642",
Forge.getLocalizer().getMessage("lblFemale") + "[%120][MAGENTA] \u2640"});
Expand All @@ -164,13 +175,20 @@ public void clicked(InputEvent event, float x, float y) {
gender.addListener(event -> NewGameScene.this.updateAvatar());

mode.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
updateModeSelectionState(modes.get(mode.getCurrentIndex()));
}
});
starterEdition.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
AdventureModes smode = modes.get(mode.getCurrentIndex());
colorLabel.setText(smode.getSelectionName());
colorId.setTextList(smode.getModes());
starterEdition.setVisible(smode == AdventureModes.Standard);
starterEditionLabel.setVisible(smode == AdventureModes.Standard);
if (smode == AdventureModes.Precon) {
colorId.setTextList(Config.instance().filterPreconDecks(starterEdition.getCurrentIndex()));
} else if (smode == AdventureModes.CommanderPrecon) {
colorId.setTextList(Config.instance().filterCommanderPreconDecks(starterEdition.getCurrentIndex()));
}
}
});
race = ui.findActor("race");
Expand Down Expand Up @@ -260,6 +278,50 @@ private void generateName() {
selectedName.setText(NameGenerator.getRandomName(val, "Any", ""));
}

private void updateModeSelectionState(AdventureModes selectedMode) {
colorLabel.setText(selectedMode.getSelectionName());
boolean showEdition = selectedMode.usesStarterEditionSelector();
starterEdition.setVisible(showEdition);
starterEditionLabel.setVisible(showEdition);

if (selectedMode == AdventureModes.Precon) {
starterEdition.setTextList(Config.instance().getPreconSetNames());
starterEditionLabel.setText("[BLACK]" + Forge.getLocalizer().getMessageorUseDefault("lblEdition", "Edition") + ":");
colorId.setTextList(Config.instance().filterPreconDecks(starterEdition.getCurrentIndex()));
} else if (selectedMode == AdventureModes.CommanderPrecon) {
starterEdition.setTextList(Config.instance().getCommanderPreconSetNames());
starterEditionLabel.setText("[BLACK]" + Forge.getLocalizer().getMessageorUseDefault("lblEdition", "Edition") + ":");
colorId.setTextList(Config.instance().filterCommanderPreconDecks(starterEdition.getCurrentIndex()));
} else if (selectedMode == AdventureModes.Standard) {
starterEditionLabel.setText(originalEditionLabelText);
starterEdition.setTextList(originalEditionNames);
colorId.setTextList(selectedMode.getModes());
} else {
colorId.setTextList(selectedMode.getModes());
}
}

private ColorSet getStartingColor() {
AdventureModes currentMode = modes.get(mode.getCurrentIndex());
if (currentMode.usesFolderDeckPicker() || currentMode == AdventureModes.Chaos) {
return ColorSet.fromNames("W".toCharArray());
}
if (currentMode == AdventureModes.Custom) {
return colorIds[0];
}
int idx = colorId.getCurrentIndex();
return colorIds[idx < colorIds.length ? idx : 0];
}

private CardEdition getStartingEdition() {
AdventureModes currentMode = modes.get(mode.getCurrentIndex());
if (currentMode == AdventureModes.Standard && editionIds.length > 0) {
int idx = starterEdition.getCurrentIndex();
return editionIds[idx < editionIds.length ? idx : 0];
}
return editionIds.length > 0 ? editionIds[0] : null;
}

boolean started = false;

public boolean start() {
Expand All @@ -276,10 +338,10 @@ public boolean start() {
gender.getCurrentIndex() == 0,
race.getCurrentIndex(),
avatarIndex,
colorIds[custom.isEmpty() || !AdventureModes.Custom.equals(modes.get(mode.getCurrentIndex())) ? colorId.getCurrentIndex() : 0],
getStartingColor(),
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()],
modes.get(mode.getCurrentIndex()), colorId.getCurrentIndex(),
editionIds[starterEdition.getCurrentIndex()], 0);//maybe replace with enum
getStartingEdition(), 0);
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
SoundSystem.instance.changeBackgroundTrack();
WorldStage.getInstance().enterSpawnPOI();
Expand Down Expand Up @@ -324,10 +386,10 @@ public void enter() {
gender.getCurrentIndex() == 0,
race.getCurrentIndex(),
avatarIndex,
colorIds[colorId.getCurrentIndex()],
getStartingColor(),
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()],
modes.get(mode.getCurrentIndex()), colorId.getCurrentIndex(),
editionIds[starterEdition.getCurrentIndex()], 0);
getStartingEdition(), 0);
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
Forge.switchScene(GameScene.instance());
}
Expand Down Expand Up @@ -469,6 +531,9 @@ private void showModeHelp() {
case Commander:
summaryText.append("Mode: Commander\n\nYou will be given a preconstructed commander deck based on the chosen color theme to start the playthrough.\n\nGood luck on your quest of creating a coherent deck that can win consistently and defeat the bosses.");
break;
case CommanderPrecon:
summaryText.append("Mode: Commander Precon\n\nChoose a named commander preconstructed deck to start the playthrough.\n\nThis uses Commander deckbuilding and game rules, but lets you pick from the curated commander precon folder.");
break;
default:
summaryText.append("No summary available for your this game mode.");
break;
Expand Down
16 changes: 15 additions & 1 deletion forge-gui-mobile/src/forge/adventure/util/AdventureModes.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public enum AdventureModes {
Chaos("[GOLD]"+Forge.getLocalizer().getMessage("lblChaos")),
Pile(Forge.getLocalizer().getMessage("lblPile")),
Custom(Forge.getLocalizer().getMessage("lblCustom")),
Commander(Forge.getLocalizer().getMessage("lblCommander"));
Commander(Forge.getLocalizer().getMessage("lblCommander")),
Precon(Forge.getLocalizer().getMessageorUseDefault("lblPrecon", "Precon")),
CommanderPrecon(Forge.getLocalizer().getMessageorUseDefault("lblCommanderPrecon", "Commander Precon"));

private final String name;
private String selectionName;
Expand Down Expand Up @@ -38,4 +40,16 @@ public String getSelectionName() {
public Array<String> getModes() {
return modes;
}

public boolean isCommanderLike() {
return this == Commander || this == CommanderPrecon;
}

public boolean usesFolderDeckPicker() {
return this == Precon || this == CommanderPrecon;
}

public boolean usesStarterEditionSelector() {
return this == Standard || usesFolderDeckPicker();
}
}
Loading
Loading