diff --git a/forge-adventure/pom.xml b/forge-adventure/pom.xml index 3d696393376..2ab05277ddc 100644 --- a/forge-adventure/pom.xml +++ b/forge-adventure/pom.xml @@ -233,11 +233,6 @@ - - com.github.jetopto1 - cling - 1.0.0 - com.badlogicgames.gdx gdx diff --git a/forge-gui-mobile/src/forge/adventure/data/DifficultyData.java b/forge-gui-mobile/src/forge/adventure/data/DifficultyData.java index 6b1d520be93..21a74974c17 100644 --- a/forge-gui-mobile/src/forge/adventure/data/DifficultyData.java +++ b/forge-gui-mobile/src/forge/adventure/data/DifficultyData.java @@ -18,8 +18,11 @@ public class DifficultyData { public float sellFactor=0.2f; public float goldLoss=0.2f; public float lifeLoss=0.2f; + + public float rewardMaxFactor=1f; public String[] startItems=new String[0]; public ObjectMap starterDecks = null; public ObjectMap constructedStarterDecks= null; + public ObjectMap pileDecks= null; } diff --git a/forge-gui-mobile/src/forge/adventure/data/RewardData.java b/forge-gui-mobile/src/forge/adventure/data/RewardData.java index c36c8a1bc24..0f075b8f307 100644 --- a/forge-gui-mobile/src/forge/adventure/data/RewardData.java +++ b/forge-gui-mobile/src/forge/adventure/data/RewardData.java @@ -108,7 +108,8 @@ public class RewardData { if(probability == 0 || WorldSave.getCurrentSave().getWorld().getRandom().nextFloat() <= probability) { if(type==null || type.isEmpty()) type="randomCard"; - int addedCount = (addMaxCount > 0 ? WorldSave.getCurrentSave().getWorld().getRandom().nextInt(addMaxCount) : 0); + int maxCount=Math.round(addMaxCount*Current.player().getDifficulty().rewardMaxFactor); + int addedCount = (maxCount > 0 ? WorldSave.getCurrentSave().getWorld().getRandom().nextInt(maxCount) : 0); if( colors != null && colors.length > 0 ) { //Filter special "colorID" case. String C = Current.player().getColorIdentityLong(); for(int i = 0; i < colors.length; i++){ diff --git a/forge-gui-mobile/src/forge/adventure/scene/NewGameScene.java b/forge-gui-mobile/src/forge/adventure/scene/NewGameScene.java index 24e23ff7b2b..010057a7c4b 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/NewGameScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/NewGameScene.java @@ -15,6 +15,7 @@ import com.github.tommyettinger.textra.TextraLabel; import forge.Forge; import forge.adventure.data.DifficultyData; import forge.adventure.data.HeroListData; +import forge.adventure.util.AdventureModes; import forge.adventure.util.Config; import forge.adventure.util.Selector; import forge.adventure.util.UIActor; @@ -43,12 +44,10 @@ public class NewGameScene extends UIScene { private final Selector gender; private final Selector mode; private final Selector difficulty; - private final Array stringList; - private final Array random; private final Array custom; private final TextraLabel colorLabel; - private final int selected = -1; + private final Array modes=new Array<>(); private NewGameScene() { super(Forge.isLandscapeMode() ? "ui/new_game.json" : "ui/new_game_portrait.json"); @@ -71,34 +70,65 @@ public class NewGameScene extends UIScene { colorLabel = ui.findActor("colorIdL"); String colorIdLabel = colorLabel.storedText; custom = new Array<>(); - for (DeckProxy deckProxy : DeckProxy.getAllCustomStarterDecks()) - custom.add(deckProxy.getName()); - mode.setTextList(custom.isEmpty() ? new String[]{"Standard", "Constructed", "Chaos"} : new String[]{"Standard", "Constructed", "Chaos", "Custom"}); - gender.setTextList(new String[]{"Male", "Female"}); - gender.addListener(event -> NewGameScene.this.updateAvatar()); - Random rand = new Random(); colorId = ui.findActor("colorId"); String[] colorSet = Config.instance().colorIds(); String[] colorIdNames = Config.instance().colorIdNames(); colorIds = new ColorSet[colorSet.length]; for (int i = 0; i < colorIds.length; i++) colorIds[i] = ColorSet.fromNames(colorSet[i].toCharArray()); - stringList = new Array<>(colorIds.length); + Array colorNames = new Array<>(colorIds.length); for (String idName : colorIdNames) - stringList.add(UIActor.localize(idName)); - colorId.setTextList(stringList); - random = new Array<>(); - random.add(Forge.getLocalizer().getMessage("lblRandomDeck")); + colorNames.add(UIActor.localize(idName)); + colorId.setTextList(colorNames); + + for (DifficultyData diff : Config.instance().getConfigData().difficulties)//check first difficulty if exists + { + if(diff.starterDecks!=null) + { + modes.add(AdventureModes.Standard); + AdventureModes.Standard.setSelectionName(colorIdLabel); + AdventureModes.Standard.setModes(colorNames); + } + + if(diff.constructedStarterDecks!=null) + { + modes.add(AdventureModes.Constructed); + AdventureModes.Constructed.setSelectionName(colorIdLabel); + AdventureModes.Constructed.setModes(colorNames); + } + if(diff.pileDecks!=null) + { + modes.add(AdventureModes.Pile); + AdventureModes.Pile.setSelectionName(colorIdLabel); + AdventureModes.Pile.setModes(colorNames); + } + break; + } + modes.add(AdventureModes.Chaos); + AdventureModes.Chaos.setSelectionName("[BLACK]"+Forge.getLocalizer().getMessage("lblDeck")+":"); + 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.setModes(custom); + } + String[] modeNames=new String[modes.size]; + for(int i=0;i NewGameScene.this.updateAvatar()); + mode.addListener(new ChangeListener() { @Override public void changed(ChangeEvent changeEvent, Actor actor) { - colorLabel.setText(mode.getCurrentIndex() < 2 ? colorIdLabel : "[BLACK]"+Forge.getLocalizer().getMessage("lblDeck")+":"); - if (mode.getCurrentIndex() == 3) - colorId.setTextList(custom); - if (mode.getCurrentIndex() == 2) - colorId.setTextList(random); - if (mode.getCurrentIndex() < 2) - colorId.setTextList(stringList); + AdventureModes smode=modes.get(mode.getCurrentIndex()); + colorLabel.setText(smode.getSelectionName()); + colorId.setTextList(smode.getModes()); } }); race = ui.findActor("race"); @@ -117,6 +147,8 @@ public class NewGameScene extends UIScene { } difficulty.setTextList(diffList); difficulty.setCurrentIndex(startingDifficulty); + + Random rand = new Random(); avatarIndex = rand.nextInt(); updateAvatar(); gender.setCurrentIndex(rand.nextInt()); @@ -149,7 +181,7 @@ public class NewGameScene extends UIScene { avatarIndex, colorIds[colorId.getCurrentIndex()], Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()], - mode.getCurrentIndex() == 2, mode.getCurrentIndex() == 1, mode.getCurrentIndex() == 3, colorId.getCurrentIndex(), 0);//maybe replace with enum + modes.get(mode.getCurrentIndex()), colorId.getCurrentIndex(), 0);//maybe replace with enum GamePlayerUtil.getGuiPlayer().setName(selectedName.getText()); Forge.switchScene(GameScene.instance()); }; @@ -197,7 +229,7 @@ public class NewGameScene extends UIScene { avatarIndex, colorIds[colorId.getCurrentIndex()], Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()], - mode.getCurrentIndex() == 2, mode.getCurrentIndex() == 1, mode.getCurrentIndex() == 3, colorId.getCurrentIndex(), 0);//maybe replace with enum + modes.get(mode.getCurrentIndex()), colorId.getCurrentIndex(), 0); GamePlayerUtil.getGuiPlayer().setName(selectedName.getText()); Forge.switchScene(GameScene.instance()); } diff --git a/forge-gui-mobile/src/forge/adventure/scene/SettingsScene.java b/forge-gui-mobile/src/forge/adventure/scene/SettingsScene.java index 0a08d742717..760acf9dc26 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/SettingsScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/SettingsScene.java @@ -3,45 +3,117 @@ package forge.adventure.scene; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.github.tommyettinger.textra.TextraButton; import com.github.tommyettinger.textra.TextraLabel; import forge.Forge; import forge.adventure.util.Config; import forge.adventure.util.Controls; +import forge.adventure.util.UIActor; import forge.gui.GuiBase; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; + /** * Scene to handle settings of the base forge and adventure mode */ public class SettingsScene extends UIScene { static public ForgePreferences Preference; - Stage stage; Texture Background; private final Table settingGroup; TextraButton backButton; + TextraButton newPlane; ScrollPane scrollPane; + SelectBox selectSourcePlane; + TextField newPlaneName; + private void copyNewPlane() { + String plane=(String) selectSourcePlane.getSelected(); + Path source= Paths.get(Config.instance().getPlanePath(plane)); + Path destination= Paths.get(Config.instance().getPlanePath(""+newPlaneName.getText())); + AtomicBoolean somethingWentWrong= new AtomicBoolean(false); + try (Stream stream = Files.walk(source)) + { + Files.createDirectories(destination); + stream.forEach(s -> { + try { Files.copy(s, destination.resolve(source.relativize(s)), REPLACE_EXISTING); } + catch (IOException e) { + somethingWentWrong.set(true); + } + }); + } catch (IOException e) { + somethingWentWrong.set(true); + } + if(somethingWentWrong.get()) + { + Dialog dialog=ui.showDialog(stage,"Something went wrong", UIActor.ButtonOk|UIActor.ButtonAbort,null); + dialog.text("Copy was not successful check your access right\n and if the folder is in use"); + dialog.show(stage); + } + else + { + Dialog dialog=ui.showDialog(stage,"Copied plane", UIActor.ButtonOk|UIActor.ButtonAbort,null); + dialog.text("New plane "+newPlaneName.getText()+" was created\nYou can now start the editor to change the plane\n" + + "or edit it manually from the folder\n" + + Config.instance().getPlanePath(""+newPlaneName.getText())); + Config.instance().getSettingData().plane = ""+newPlaneName.getText(); + Config.instance().saveSettings(); + dialog.show(stage); + } + + } + private void createNewPlane() { + Dialog dialog=ui.showDialog(stage,"Create your own Plane", UIActor.ButtonOk|UIActor.ButtonAbort,()->copyNewPlane()); + dialog.text("Select a plane to copy"); + dialog.getContentTable().row(); + dialog.getContentTable().add(selectSourcePlane); + dialog.getContentTable().row(); + dialog.text("Set new plane name"); + dialog.getContentTable().row(); + dialog.getContentTable().add(newPlaneName); + newPlaneName.setText(selectSourcePlane.getSelected().toString()+"_copy"); + dialog.show(stage); + } + private SettingsScene() { super(Forge.isLandscapeMode() ? "ui/settings.json" : "ui/settings_portrait.json"); + selectSourcePlane = new SelectBox(Controls.getSkin()); + newPlaneName = Controls.newTextField(""); settingGroup = new Table(); if (Preference == null) { Preference = new ForgePreferences(); } - + selectSourcePlane.setItems(Config.instance().getAllAdventures()); SelectBox plane = Controls.newComboBox(Config.instance().getAllAdventures(), Config.instance().getSettingData().plane, o -> { Config.instance().getSettingData().plane = (String) o; Config.instance().saveSettings(); return null; }); + newPlane=Controls.newTextButton("Create own plane"); + newPlane.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + createNewPlane(); + } + }); addLabel(Forge.getLocalizer().getMessage("lblWorld")); settingGroup.add(plane).align(Align.right).pad(2); + addLabel(Forge.getLocalizer().getMessage("lblCreate")+Forge.getLocalizer().getMessage("lblWorld")); + settingGroup.add(newPlane).align(Align.right).pad(2); if (!GuiBase.isAndroid()) { SelectBox videomode = Controls.newComboBox(new String[]{"720p", "768p", "900p", "1080p"}, Config.instance().getSettingData().videomode, o -> { diff --git a/forge-gui-mobile/src/forge/adventure/scene/UIScene.java b/forge-gui-mobile/src/forge/adventure/scene/UIScene.java index b8fa9d2a14a..419f57584c7 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/UIScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/UIScene.java @@ -28,7 +28,7 @@ import forge.adventure.util.UIActor; */ public class UIScene extends Scene { protected UIActor ui; - Stage stage; + protected Stage stage; String uiFile; private final Dialog keyboardDialog; diff --git a/forge-gui-mobile/src/forge/adventure/util/AdventureModes.java b/forge-gui-mobile/src/forge/adventure/util/AdventureModes.java new file mode 100644 index 00000000000..2f2231e23bf --- /dev/null +++ b/forge-gui-mobile/src/forge/adventure/util/AdventureModes.java @@ -0,0 +1,39 @@ +package forge.adventure.util; + +import com.badlogic.gdx.utils.Array; + +public enum AdventureModes { + Standard("Standard"), + Constructed("Constructed"), + Chaos("[RED]Chaos"), + Pile("Pile"), + Custom("Custom"); + + private final String name; + private String selectionName; + private Array modes; + AdventureModes(String name) + { + this.name=name; + } + public String getName() + { + return name.isEmpty()?toString():name; + } + public void setSelectionName(String selectionName) + { + this.selectionName=selectionName; + } + public void setModes( Array modes) + { + this.modes=modes; + } + + public String getSelectionName() { + return selectionName; + } + + public Array getModes() { + return modes; + } +} diff --git a/forge-gui-mobile/src/forge/adventure/util/Config.java b/forge-gui-mobile/src/forge/adventure/util/Config.java index 305e0cd4c6f..ef98bb51300 100644 --- a/forge-gui-mobile/src/forge/adventure/util/Config.java +++ b/forge-gui-mobile/src/forge/adventure/util/Config.java @@ -2,6 +2,7 @@ package forge.adventure.util; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Json; import com.badlogic.gdx.utils.JsonWriter; import com.badlogic.gdx.utils.ObjectMap; @@ -11,6 +12,8 @@ import forge.adventure.data.DifficultyData; import forge.adventure.data.SettingData; import forge.card.ColorSet; import forge.deck.Deck; +import forge.deck.DeckProxy; +import forge.deck.DeckgenUtil; import forge.gui.GuiBase; import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; @@ -43,7 +46,7 @@ public class Config { } private Config() { - String path= GuiBase.isAndroid() ? ForgeConstants.ASSETS_DIR : Files.exists(Paths.get("./res"))?"./":"../forge-gui/"; + String path= resPath(); adventures = new File(GuiBase.isAndroid() ? ForgeConstants.ADVENTURE_DIR : path + "/res/adventure").list(); try { @@ -59,6 +62,7 @@ public class Config { if(adventures!=null&&adventures.length>=1) settingsData.plane=adventures[0]; } + plane=settingsData.plane; if(settingsData.width==0||settingsData.height==0) { @@ -80,10 +84,9 @@ public class Config { if(settingsData.cardTooltipAdjLandscape == null || settingsData.cardTooltipAdjLandscape == 0f) settingsData.cardTooltipAdjLandscape=1f; - this.plane = settingsData.plane; - currentConfig = this; + prefix = getPlanePath(settingsData.plane); - prefix = path + "/res/adventure/" + plane + "/"; + currentConfig = this; if (FModel.getPreferences() != null) Lang = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE); try @@ -99,6 +102,22 @@ public class Config { } + private String resPath() { + + return GuiBase.isAndroid() ? ForgeConstants.ASSETS_DIR : Files.exists(Paths.get("./res"))?"./":"../forge-gui/"; + } + + public String getPlanePath(String plane) { + if(plane.startsWith("")) + { + return ForgeConstants.USER_ADVENTURE_DIR + "/userplanes/" + plane.substring("".length()) + "/"; + } + else + { + return resPath() + "/res/adventure/" + plane + "/"; + } + } + public ConfigData getConfigData() { return configData; } @@ -130,7 +149,7 @@ public class Config { public String getPlane() { - return plane; + return plane.replace("","user_"); } public String[] colorIdNames() { @@ -141,23 +160,38 @@ public class Config { return configData.colorIds; } - public Deck starterDeck(ColorSet color, DifficultyData difficultyData, boolean constructed) { - if(constructed) + public Deck starterDeck(ColorSet color, DifficultyData difficultyData, AdventureModes mode,int index) { + switch (mode) { - for(ObjectMap.Entry entry:difficultyData.constructedStarterDecks) - { - if(ColorSet.fromNames(entry.key.toCharArray()).getColor()==color.getColor()) + case Constructed: + for(ObjectMap.Entry entry:difficultyData.constructedStarterDecks) { - return CardUtil.getDeck(entry.value, false, false, "", false, false); + if(ColorSet.fromNames(entry.key.toCharArray()).getColor()==color.getColor()) + { + return CardUtil.getDeck(entry.value, false, false, "", false, false); + } + } + case Standard: + + for(ObjectMap.Entry entry:difficultyData.starterDecks) + { + if(ColorSet.fromNames(entry.key.toCharArray()).getColor()==color.getColor()) + { + return CardUtil.getDeck(entry.value, false, false, "", false, false); + } + } + case Chaos: + return DeckgenUtil.getRandomOrPreconOrThemeDeck("", false, false, false); + case Custom: + return DeckProxy.getAllCustomStarterDecks().get(index).getDeck(); + case Pile: + for(ObjectMap.Entry entry:difficultyData.pileDecks) + { + if(ColorSet.fromNames(entry.key.toCharArray()).getColor()==color.getColor()) + { + return CardUtil.getDeck(entry.value, false, false, "", false, false); + } } - } - } - for(ObjectMap.Entry entry:difficultyData.starterDecks) - { - if(ColorSet.fromNames(entry.key.toCharArray()).getColor()==color.getColor()) - { - return CardUtil.getDeck(entry.value, false, false, "", false, false); - } } return null; } @@ -174,8 +208,17 @@ public class Config { { return settingsData; } - public String[] getAllAdventures() + public Array getAllAdventures() { + String path=ForgeConstants.USER_ADVENTURE_DIR + "/userplanes/"; + Array adventures = new Array(); + if(new File(path).exists()) + adventures.addAll(new File(path).list()); + for(int i=0;i"+adventures.get(i)); + } + adventures.addAll(this.adventures); return adventures; } diff --git a/forge-gui-mobile/src/forge/adventure/util/Controls.java b/forge-gui-mobile/src/forge/adventure/util/Controls.java index 1fb6f3cc08e..3472b8089e5 100644 --- a/forge-gui-mobile/src/forge/adventure/util/Controls.java +++ b/forge-gui-mobile/src/forge/adventure/util/Controls.java @@ -12,6 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Null; import com.github.tommyettinger.textra.Font; import com.github.tommyettinger.textra.TextraButton; @@ -99,6 +100,26 @@ public class Controls { return ret; } + static public SelectBox newComboBox(Array text, String item, Function func) { + SelectBox ret = new SelectBox(getSkin()); + ret.getStyle().listStyle.selection.setTopHeight(4); + ret.setItems(text); + ret.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + try { + func.apply(((SelectBox) actor).getSelected()); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + func.apply(item); + ret.getList().setAlignment(Align.center); + ret.setSelected(item); + ret.setAlignment(Align.right); + return ret; + } static public SelectBox newComboBox(Float[] text, float item, Function func) { SelectBox ret = new SelectBox(getSkin()); ret.getStyle().listStyle.selection.setTopHeight(4); diff --git a/forge-gui-mobile/src/forge/adventure/util/UIActor.java b/forge-gui-mobile/src/forge/adventure/util/UIActor.java index 4d67a1d35f8..d0ed76b9abb 100644 --- a/forge-gui-mobile/src/forge/adventure/util/UIActor.java +++ b/forge-gui-mobile/src/forge/adventure/util/UIActor.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; @@ -286,4 +287,31 @@ public class UIActor extends Group { } }); } + static final public int ButtonYes=0x1; + static final public int ButtonNo=0x2; + static final public int ButtonOk=0x4; + static final public int ButtonAbort=0x8; + public Dialog showDialog(Stage stage, String header, int buttons, Runnable onOkOrYes) { + Dialog dialog =new Dialog(header, Controls.getSkin()) + { + protected void result(Object object) + { + if(onOkOrYes!=null&&object!=null&&object.equals(true)) + onOkOrYes.run(); + this.hide(); + removeActor(this); + } + }; + if((buttons&ButtonYes)!=0) + dialog.button(Forge.getLocalizer().getMessage("lblYes"), true); + if((buttons&ButtonNo)!=0) + dialog.button(Forge.getLocalizer().getMessage("lblNo"), false); + if((buttons&ButtonOk)!=0) + dialog.button(Forge.getLocalizer().getMessage("lblOk"), true); + if((buttons&ButtonAbort)!=0) + dialog.button(Forge.getLocalizer().getMessage("lblAbort"), false); + addActor(dialog); + dialog.show(stage); + return dialog; + } } diff --git a/forge-gui-mobile/src/forge/adventure/world/WorldSave.java b/forge-gui-mobile/src/forge/adventure/world/WorldSave.java index 914f040ea7e..a8957a458ab 100644 --- a/forge-gui-mobile/src/forge/adventure/world/WorldSave.java +++ b/forge-gui-mobile/src/forge/adventure/world/WorldSave.java @@ -4,13 +4,12 @@ import forge.adventure.data.DifficultyData; import forge.adventure.player.AdventurePlayer; import forge.adventure.pointofintrest.PointOfInterestChanges; import forge.adventure.stage.WorldStage; +import forge.adventure.util.AdventureModes; import forge.adventure.util.Config; import forge.adventure.util.SaveFileData; import forge.adventure.util.SignalList; import forge.card.ColorSet; import forge.deck.Deck; -import forge.deck.DeckProxy; -import forge.deck.DeckgenUtil; import forge.localinstance.properties.ForgeConstants; import forge.player.GamePlayerUtil; @@ -123,10 +122,12 @@ public class WorldSave { return currentSave; } - public static WorldSave generateNewWorld(String name, boolean male, int race, int avatarIndex, ColorSet startingColorIdentity, DifficultyData diff, boolean chaos, boolean constructed, boolean custom, int customDeckIndex, long seed) { + public static WorldSave generateNewWorld(String name, boolean male, int race, int avatarIndex, ColorSet startingColorIdentity, DifficultyData diff, AdventureModes mode, int customDeckIndex, long seed) { currentSave.world.generateNew(seed); currentSave.pointOfInterestChanges.clear(); - Deck starterDeck = chaos ? DeckgenUtil.getRandomOrPreconOrThemeDeck("", false, false, false) : custom ? DeckProxy.getAllCustomStarterDecks().get(customDeckIndex).getDeck() : Config.instance().starterDeck(startingColorIdentity,diff,constructed); + boolean chaos=mode==AdventureModes.Chaos; + boolean custom=mode==AdventureModes.Custom; + Deck starterDeck = Config.instance().starterDeck(startingColorIdentity,diff,mode,customDeckIndex); currentSave.player.create(name, starterDeck, male, race, avatarIndex, chaos, custom, diff); currentSave.player.setWorldPosY((int) (currentSave.world.getData().playerStartPosY * currentSave.world.getData().height * currentSave.world.getTileSize())); currentSave.player.setWorldPosX((int) (currentSave.world.getData().playerStartPosX * currentSave.world.getData().width * currentSave.world.getTileSize())); diff --git a/forge-gui/pom.xml b/forge-gui/pom.xml index c7da09dd551..6baac0096a9 100644 --- a/forge-gui/pom.xml +++ b/forge-gui/pom.xml @@ -73,9 +73,9 @@ compile - com.github.jetopto1.cling + org.fourthline.cling cling-core - 1.0.0 + 2.1.2 compile diff --git a/forge-gui/res/adventure/Shandalar/config.json b/forge-gui/res/adventure/Shandalar/config.json index dedcd612a16..4c5ac285389 100644 --- a/forge-gui/res/adventure/Shandalar/config.json +++ b/forge-gui/res/adventure/Shandalar/config.json @@ -62,7 +62,8 @@ "enemyLifeFactor": 0.8, "spawnRank": 0, "goldLoss": 0.02, - "lifeLoss": 0.1, + "lifeLoss": 0.1, + "rewardMaxFactor" : 1.5, "sellFactor": 0.6, "starterDecks": { "W":"decks/starter/white_e.json", @@ -78,6 +79,13 @@ "R":"decks/starter/Adventure - Low Red.dck", "G":"decks/starter/Adventure - Low Green.dck" }, + "pileDecks": { + "W":"decks/starter/pile_white_e.json", + "B":"decks/starter/pile_black_e.json", + "U":"decks/starter/pile_blue_e.json", + "R":"decks/starter/pile_red_e.json", + "G":"decks/starter/pile_green_e.json" + }, "startItems": [ "Manasight Amulet", "Leather Boots" @@ -89,6 +97,7 @@ "staringMoney": 250, "startingDifficulty": true, "enemyLifeFactor": 1.0, + "rewardMaxFactor" : 1.0, "spawnRank": 1, "goldLoss": 0.1, "lifeLoss": 0.2, @@ -107,6 +116,13 @@ "R":"decks/starter/Adventure - Low Gruul.dck", "G":"decks/starter/Adventure - Low Selesnya.dck" }, + "pileDecks": { + "W":"decks/starter/pile_white_n.json", + "B":"decks/starter/pile_black_n.json", + "U":"decks/starter/pile_blue_n.json", + "R":"decks/starter/pile_red_n.json", + "G":"decks/starter/pile_green_n.json" + }, "startItems": [ "Leather Boots" ] @@ -116,8 +132,9 @@ "startingMana": 10, "staringMoney": 125, "enemyLifeFactor": 1.5, + "rewardMaxFactor" : 0.5, "spawnRank": 2, - "goldLoss": 0.5, + "goldLoss": 0.3, "lifeLoss": 0.3, "sellFactor": 0.25, "starterDecks": { @@ -133,6 +150,45 @@ "U":"decks/starter/Adventure - Low Izzet.dck", "R":"decks/starter/Adventure - Low Boros.dck", "G":"decks/starter/Adventure - Low Simic.dck" + }, + "pileDecks": { + "W":"decks/starter/pile_white_h.json", + "B":"decks/starter/pile_black_h.json", + "U":"decks/starter/pile_blue_h.json", + "R":"decks/starter/pile_red_h.json", + "G":"decks/starter/pile_green_h.json" + } + },{ + "name": "Insane", + "startingLife": 7, + "startingMana": 10, + "staringMoney": 0, + "enemyLifeFactor": 2.5, + "rewardMaxFactor" : 0.0, + "spawnRank": 2, + "goldLoss": 0.5, + "lifeLoss": 0.3, + "sellFactor": 0.05, + "starterDecks": { + "W":"decks/starter/white_h.json", + "B":"decks/starter/black_h.json", + "U":"decks/starter/blue_h.json", + "R":"decks/starter/red_h.json", + "G":"decks/starter/green_h.json" + }, + "constructedStarterDecks": { + "W":"decks/starter/Adventure - Low Orzhov.dck", + "B":"decks/starter/Adventure - Low Golgari.dck", + "U":"decks/starter/Adventure - Low Izzet.dck", + "R":"decks/starter/Adventure - Low Boros.dck", + "G":"decks/starter/Adventure - Low Simic.dck" + }, + "pileDecks": { + "W":"decks/starter/pile_white_h.json", + "B":"decks/starter/pile_black_h.json", + "U":"decks/starter/pile_blue_h.json", + "R":"decks/starter/pile_red_h.json", + "G":"decks/starter/pile_green_h.json" } } ] diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_e.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_e.json new file mode 100644 index 00000000000..9e362018704 --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_e.json @@ -0,0 +1,44 @@ +{ +"name":"Black", + "mainDeck": [ + { + "count":12, + "cardName": "Swamp" + }, + { + "count":6, + "cardName": "Mountain" + }, + { + "count":6, + "colors": ["black"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["red"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["black"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["red"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["black"], + "rarity": ["rare"], + "manaCosts": [5,6,7,8,9] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_h.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_h.json new file mode 100644 index 00000000000..69f702f1663 --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_h.json @@ -0,0 +1,48 @@ +{ +"name":"Black", + "mainDeck": [ + { + "count":10, + "cardName": "Swamp" + }, + { + "count":4, + "cardName": "Mountain" + }, + { + "count":4, + "cardName": "Island" + }, + { + "count":6, + "colors": ["black"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["red","blue"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["black"], + "rarity": ["Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["red","blue"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["black"], + "rarity": ["Uncommon","Common"], + "manaCosts": [5,6] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/black.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_n.json similarity index 73% rename from forge-gui/res/adventure/Shandalar/decks/starter/black.json rename to forge-gui/res/adventure/Shandalar/decks/starter/pile_black_n.json index d3b335897e9..7cd884251b9 100644 --- a/forge-gui/res/adventure/Shandalar/decks/starter/black.json +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_black_n.json @@ -17,37 +17,31 @@ "count":6, "colors": ["black"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["red","blue"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["black"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, { "count":2, "colors": ["red","blue"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, { - "count":5, - "colors": ["black"], - "rarity": ["Uncommon","Common"], - "manaCosts": [5,6] - }, - { - "count":1, + "count":6, "colors": ["black"], "rarity": ["rare"], - "manaCosts": [7,8,9] + "manaCosts": [5,6,7,8,9] } ] } diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_e.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_e.json new file mode 100644 index 00000000000..dd2a9c686eb --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_e.json @@ -0,0 +1,44 @@ +{ +"name":"Blue", + "mainDeck": [ + { + "count":12, + "cardName": "Island" + }, + { + "count":6, + "cardName": "Swamp" + }, + { + "count":6, + "colors": ["blue"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["black"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["blue"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["black"], + "rarity": ["Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["blue"], + "rarity": ["rare"], + "manaCosts": [5,6,7,8,9] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_h.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_h.json new file mode 100644 index 00000000000..a95eff4eab9 --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_h.json @@ -0,0 +1,48 @@ +{ +"name":"Blue", + "mainDeck": [ + { + "count":10, + "cardName": "Island" + }, + { + "count":4, + "cardName": "Plains" + }, + { + "count":4, + "cardName": "Swamp" + }, + { + "count":6, + "colors": ["blue"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["white","black"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["blue"], + "rarity": ["Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["white","black"], + "rarity": ["Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["blue"], + "rarity": ["Uncommon","Common"], + "manaCosts": [5,6] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/blue.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_n.json similarity index 72% rename from forge-gui/res/adventure/Shandalar/decks/starter/blue.json rename to forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_n.json index b9775c98fe2..349e9728402 100644 --- a/forge-gui/res/adventure/Shandalar/decks/starter/blue.json +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_blue_n.json @@ -17,37 +17,31 @@ "count":6, "colors": ["blue"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["white","black"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["blue"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, { "count":2, "colors": ["white","black"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, - { - "count":5, - "colors": ["blue"], - "rarity": ["Uncommon","Common"], - "manaCosts": [5,6] - }, - { - "count":1, + { + "count":6, "colors": ["blue"], "rarity": ["rare"], - "manaCosts": [7,8,9] + "manaCosts": [5,6,7,8,9] } ] } diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_e.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_e.json new file mode 100644 index 00000000000..a4dc8a1e7bb --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_e.json @@ -0,0 +1,44 @@ +{ +"name":"Green", + "mainDeck": [ + { + "count":12, + "cardName": "Forest" + }, + { + "count":6, + "cardName": "Plains" + }, + { + "count":6, + "colors": ["green"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["white"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["green"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["white"], + "rarity": ["Uncommon"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["green"], + "rarity": ["rare"], + "manaCosts": [5,6,7,8,9] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_h.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_h.json new file mode 100644 index 00000000000..4f56b5c553a --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_h.json @@ -0,0 +1,48 @@ +{ +"name":"Green", + "mainDeck": [ + { + "count":10, + "cardName": "Forest" + }, + { + "count":4, + "cardName": "Plains" + }, + { + "count":4, + "cardName": "Mountain" + }, + { + "count":6, + "colors": ["green"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["white","red"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["green"], + "rarity": ["Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["red","white"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["green"], + "rarity": ["Uncommon","Common"], + "manaCosts": [5,6] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/green.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_n.json similarity index 73% rename from forge-gui/res/adventure/Shandalar/decks/starter/green.json rename to forge-gui/res/adventure/Shandalar/decks/starter/pile_green_n.json index e7d2fac8dd7..1dea67ff040 100644 --- a/forge-gui/res/adventure/Shandalar/decks/starter/green.json +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_green_n.json @@ -17,37 +17,31 @@ "count":6, "colors": ["green"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["white","red"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["green"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, { "count":2, "colors": ["red","white"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, { - "count":5, - "colors": ["green"], - "rarity": ["Uncommon","Common"], - "manaCosts": [5,6] - }, - { - "count":1, + "count":6, "colors": ["green"], "rarity": ["rare"], - "manaCosts": [7,8,9] + "manaCosts": [5,6,7,8,9] } ] } diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_e.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_e.json new file mode 100644 index 00000000000..779b50200ae --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_e.json @@ -0,0 +1,44 @@ +{ +"name":"Red", + "mainDeck": [ + { + "count":12, + "cardName": "Mountain" + }, + { + "count":6, + "cardName": "Forest" + }, + { + "count":6, + "colors": ["red"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["green"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["red"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["green"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["red"], + "rarity": ["rare"] , + "manaCosts": [5,6,7,8,9] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_h.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_h.json new file mode 100644 index 00000000000..5e46b22aaa4 --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_h.json @@ -0,0 +1,48 @@ +{ +"name":"Red", + "mainDeck": [ + { + "count":10, + "cardName": "Mountain" + }, + { + "count":4, + "cardName": "Forest" + }, + { + "count":4, + "cardName": "Swamp" + }, + { + "count":6, + "colors": ["red"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["green","black"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["red"], + "rarity": ["Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["green","black"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["red"], + "rarity": ["Uncommon","Common"], + "manaCosts": [5,6] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/red.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_n.json similarity index 73% rename from forge-gui/res/adventure/Shandalar/decks/starter/red.json rename to forge-gui/res/adventure/Shandalar/decks/starter/pile_red_n.json index f4f2f2206ee..1647f855ef5 100644 --- a/forge-gui/res/adventure/Shandalar/decks/starter/red.json +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_red_n.json @@ -17,37 +17,31 @@ "count":6, "colors": ["red"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["green","black"], "rarity": ["Uncommon","Common"], - "manaCosts": [1,2], + "manaCosts": [1,2] }, { "count":4, "colors": ["red"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, { "count":2, "colors": ["green","black"], "rarity": ["Uncommon","Common"], - "manaCosts": [3,4], + "manaCosts": [3,4] }, { - "count":5, - "colors": ["red"], - "rarity": ["Uncommon","Common"], - "manaCosts": [5,6] - }, - { - "count":1, + "count":6, "colors": ["red"], "rarity": ["rare"], - "manaCosts": [7,8,9] + "manaCosts": [5,6,7,8,9] } ] } diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_e.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_e.json new file mode 100644 index 00000000000..155dcf65f37 --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_e.json @@ -0,0 +1,44 @@ +{ +"name":"White", + "mainDeck": [ + { + "count":12, + "cardName": "Plains" + }, + { + "count":6, + "cardName": "Forest" + }, + { + "count":6, + "colors": ["white"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["green"], + "rarity": ["Uncommon","Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["white"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["green"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["white"], + "rarity": ["rare"], + "manaCosts": [5,6,7,8,9] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_h.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_h.json new file mode 100644 index 00000000000..02401dbd940 --- /dev/null +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_h.json @@ -0,0 +1,48 @@ +{ +"name":"White", + "mainDeck": [ + { + "count":10, + "cardName": "Plains" + }, + { + "count":4, + "cardName": "Forest" + }, + { + "count":4, + "cardName": "Island" + }, + { + "count":6, + "colors": ["white"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["green","blue"], + "rarity": ["Common"], + "manaCosts": [1,2] + }, + { + "count":4, + "colors": ["white"], + "rarity": ["Common"], + "manaCosts": [3,4] + }, + { + "count":2, + "colors": ["green","blue"], + "rarity": ["Uncommon","Common"], + "manaCosts": [3,4] + }, + { + "count":6, + "colors": ["white"], + "rarity": ["Uncommon","Common"], + "manaCosts": [5,6] + } + ] +} + diff --git a/forge-gui/res/adventure/Shandalar/decks/starter/white.json b/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_n.json similarity index 83% rename from forge-gui/res/adventure/Shandalar/decks/starter/white.json rename to forge-gui/res/adventure/Shandalar/decks/starter/pile_white_n.json index a5d53a22cd0..f3ab309834b 100644 --- a/forge-gui/res/adventure/Shandalar/decks/starter/white.json +++ b/forge-gui/res/adventure/Shandalar/decks/starter/pile_white_n.json @@ -38,16 +38,10 @@ "manaCosts": [3,4] }, { - "count":5, - "colors": ["white"], - "rarity": ["Uncommon","Common"], - "manaCosts": [5,6] - }, - { - "count":1, + "count":6, "colors": ["white"], "rarity": ["rare"], - "manaCosts": [7,8,9] + "manaCosts": [5,6,7,8,9] } ] }