Merge branch 'master' into 'master'

Adventure fixes.

See merge request core-developers/forge!6509
This commit is contained in:
Anthony Calosa
2022-04-10 03:41:47 +00:00
5 changed files with 16 additions and 9 deletions

View File

@@ -5,6 +5,9 @@ import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Json;
import forge.adventure.util.Config;
import forge.adventure.util.Paths;
import forge.util.MyRandom;
import java.util.ArrayList;
/**
* Data class that will be used to read Json configuration files
@@ -37,10 +40,12 @@ public class PointOfInterestData {
return pointOfInterestList;
}
public static PointOfInterestData getPointOfInterest(String name) {
for(PointOfInterestData data: new Array.ArrayIterator<>(getAllPointOfInterest()))
{
if(data.name.equals(name))
return data;
ArrayList<PointOfInterestData> candidates = new ArrayList<PointOfInterestData>();
for(PointOfInterestData data: new Array.ArrayIterator<>(getAllPointOfInterest())){
if(data.name.equals(name)) candidates.add(data); //Populate candidates with specified name.
}
if(candidates.size() > 0){ //If we got any candidates, return a random one.
return candidates.get(MyRandom.getRandom().nextInt(candidates.size()));
}
return null;
}

View File

@@ -44,7 +44,7 @@ public class Config {
adventures = new File(GuiBase.isAndroid() ? ForgeConstants.ADVENTURE_DIR : path + "/res/adventure").list();
try
{
settingsData = new Json().fromJson(SettingData.class, new FileHandle(ForgeConstants.USER_DIR + "/adventure/settings.json"));
settingsData = new Json().fromJson(SettingData.class, new FileHandle(ForgeConstants.USER_ADVENTURE_DIR + "settings.json"));
}
catch (Exception e)

View File

@@ -8,6 +8,7 @@ import forge.adventure.util.Config;
import forge.adventure.util.SaveFileData;
import forge.adventure.util.SignalList;
import forge.deck.Deck;
import forge.localinstance.properties.ForgeConstants;
import forge.localinstance.properties.ForgeProfileProperties;
import forge.player.GamePlayerUtil;
@@ -110,11 +111,11 @@ public class WorldSave {
}
public static String getSaveDir() {
return ForgeProfileProperties.getUserDir() + File.separator + "Adventure" + File.separator + Config.instance().getPlane();
return ForgeConstants.USER_ADVENTURE_DIR + Config.instance().getPlane();
}
public static String getSaveFile(int slot) {
return ForgeProfileProperties.getUserDir() + File.separator + "Adventure" + File.separator + Config.instance().getPlane() + File.separator + filename(slot);
return ForgeConstants.USER_ADVENTURE_DIR + Config.instance().getPlane() + File.separator + filename(slot);
}
public static WorldSave getCurrentSave() {

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.5" tiledversion="1.7.1" orientation="orthogonal" renderorder="right-down" width="30" height="30" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="53">
<map version="1.8" tiledversion="1.8.4" orientation="orthogonal" renderorder="right-down" width="30" height="30" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="53">
<editorsettings>
<export target="wastetown..tmx" format="tmx"/>
</editorsettings>
@@ -43,7 +43,7 @@
</object>
<object id="52" template="../../obj/enemy.tx" x="200" y="151" width="32" height="32">
<properties>
<property name="enemy" value="Lathliss"/>
<property name="enemy" value="Ghalta"/>
</properties>
</object>
</objectgroup>

View File

@@ -251,6 +251,7 @@ public final class ForgeConstants {
public static final String USER_CUSTOM_CARDS_DIR = USER_CUSTOM_DIR + "cards" + PATH_SEPARATOR;
public static final String USER_CUSTOM_TOKENS_DIR = USER_CUSTOM_DIR + "tokens" + PATH_SEPARATOR;
public static final String USER_FORMATS_DIR = USER_CUSTOM_DIR + "formats" + PATH_SEPARATOR;
public static final String USER_ADVENTURE_DIR = USER_DIR + "adventure" + PATH_SEPARATOR;
public static final String DECK_DRAFT_DIR = DECK_BASE_DIR + "draft" + PATH_SEPARATOR;
public static final String DECK_WINSTON_DIR = DECK_BASE_DIR + "winston" + PATH_SEPARATOR;
public static final String DECK_SEALED_DIR = DECK_BASE_DIR + "sealed" + PATH_SEPARATOR;