2018-09-03 06:19:33 +00:00
|
|
|
package com.seodisparate.TurnBasedMinecraft.common;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
2018-09-07 07:41:22 +00:00
|
|
|
import java.io.FileNotFoundException;
|
2018-09-03 06:19:33 +00:00
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
2018-09-07 07:41:22 +00:00
|
|
|
import java.time.LocalDateTime;
|
2018-09-03 06:19:33 +00:00
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import javax.xml.stream.FactoryConfigurationError;
|
|
|
|
import javax.xml.stream.XMLInputFactory;
|
|
|
|
import javax.xml.stream.XMLStreamException;
|
|
|
|
import javax.xml.stream.XMLStreamReader;
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
public class Config
|
|
|
|
{
|
2018-09-04 06:21:49 +00:00
|
|
|
private Map<String, EntityInfo> entityInfoMap;
|
2018-09-13 05:12:04 +00:00
|
|
|
private Set<String> ignoreBattleTypes;
|
2018-09-03 06:19:33 +00:00
|
|
|
private Logger logger;
|
2018-09-06 08:08:36 +00:00
|
|
|
private int playerSpeed = 50;
|
|
|
|
private int playerHasteSpeed = 80;
|
|
|
|
private int playerSlowSpeed = 20;
|
2018-09-05 06:54:06 +00:00
|
|
|
private int playerAttackProbability = 100;
|
|
|
|
private int playerEvasion = 10;
|
|
|
|
private int defenseDuration = 1;
|
|
|
|
private int fleeGoodProbability = 90;
|
|
|
|
private int fleeBadProbability = 40;
|
2018-09-13 05:52:48 +00:00
|
|
|
private int minimumHitPercentage = 1;
|
2018-09-14 03:44:45 +00:00
|
|
|
private int maxInBattle = 8;
|
2018-09-14 05:14:10 +00:00
|
|
|
private Set<String> musicBattleTypes;
|
|
|
|
private Set<String> musicSillyTypes;
|
2018-09-18 06:56:06 +00:00
|
|
|
private boolean freezeCombatantsInBattle = false;
|
2018-09-28 03:02:39 +00:00
|
|
|
private int sillyMusicThreshold = 40;
|
2018-09-03 06:19:33 +00:00
|
|
|
|
|
|
|
public Config(Logger logger)
|
|
|
|
{
|
2018-09-04 06:21:49 +00:00
|
|
|
entityInfoMap = new HashMap<String, EntityInfo>();
|
2018-09-13 05:12:04 +00:00
|
|
|
ignoreBattleTypes = new HashSet<String>();
|
2018-09-03 06:19:33 +00:00
|
|
|
this.logger = logger;
|
2018-09-14 05:14:10 +00:00
|
|
|
musicBattleTypes = new HashSet<String>();
|
|
|
|
musicSillyTypes = new HashSet<String>();
|
2018-09-03 06:19:33 +00:00
|
|
|
|
2018-09-07 07:41:22 +00:00
|
|
|
int internalVersion = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
InputStream is = getClass().getResourceAsStream(TurnBasedMinecraftMod.CONFIG_INTERNAL_PATH);
|
|
|
|
if(is == null)
|
|
|
|
{
|
|
|
|
logger.error("Internal resource is null");
|
|
|
|
}
|
2018-09-25 05:55:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
internalVersion = getConfigFileVersion(is);
|
|
|
|
}
|
|
|
|
} catch (Throwable t) {}
|
2018-09-07 07:41:22 +00:00
|
|
|
|
|
|
|
if(internalVersion == 0)
|
|
|
|
{
|
|
|
|
logger.error("Failed to check version of internal config file");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TurnBasedMinecraftMod.setConfigVersion(internalVersion);
|
|
|
|
}
|
|
|
|
|
2018-09-03 06:19:33 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
File testLoad = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
if(!testLoad.exists())
|
|
|
|
{
|
|
|
|
writeConfig();
|
|
|
|
}
|
|
|
|
}
|
2018-09-25 05:55:24 +00:00
|
|
|
catch (Throwable t)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
|
|
|
logger.error("Failed to check/create-new config file");
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse xml
|
|
|
|
File configFile = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
if(!configFile.exists() || !configFile.canRead())
|
|
|
|
{
|
|
|
|
logger.error("Failed to read/parse config file " + TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
return;
|
|
|
|
}
|
2018-09-07 07:41:22 +00:00
|
|
|
|
|
|
|
int configVersion = getConfigFileVersion(configFile);
|
|
|
|
if(configVersion < TurnBasedMinecraftMod.getConfigVersion())
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.warn("Config file " + TurnBasedMinecraftMod.CONFIG_FILENAME + " is older version, renaming...");
|
|
|
|
moveOldConfig();
|
|
|
|
try
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
|
|
|
writeConfig();
|
2018-09-25 05:55:24 +00:00
|
|
|
} catch (Throwable t)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.error("Failed to write config file!");
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
parseConfig(configFile);
|
2018-09-25 05:55:24 +00:00
|
|
|
} catch (Throwable t)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.error("Failed to parse config file!");
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void writeConfig() throws IOException
|
|
|
|
{
|
|
|
|
File configFile = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
File dirs = configFile.getParentFile();
|
|
|
|
dirs.mkdirs();
|
2018-09-07 07:41:22 +00:00
|
|
|
InputStream configStream = this.getClass().getResourceAsStream(TurnBasedMinecraftMod.CONFIG_INTERNAL_PATH);
|
2018-09-03 06:19:33 +00:00
|
|
|
FileOutputStream configOutput = new FileOutputStream(configFile);
|
|
|
|
byte[] buf = new byte[4096];
|
|
|
|
int read = 0;
|
|
|
|
while(read != -1)
|
|
|
|
{
|
|
|
|
read = configStream.read(buf);
|
|
|
|
if(read > 0)
|
|
|
|
{
|
|
|
|
configOutput.write(buf, 0, read);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
configStream.close();
|
|
|
|
configOutput.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void moveOldConfig()
|
|
|
|
{
|
|
|
|
File configFile = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
if(configFile.exists())
|
|
|
|
{
|
2018-09-04 06:21:49 +00:00
|
|
|
configFile.renameTo(new File(TurnBasedMinecraftMod.CONFIG_DIRECTORY
|
|
|
|
+ "TBM_Config_"
|
2018-09-07 07:41:22 +00:00
|
|
|
+ DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now())
|
2018-09-04 06:21:49 +00:00
|
|
|
+ ".xml"));
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-07 07:41:22 +00:00
|
|
|
private boolean parseConfig(File configFile) throws XMLStreamException, FactoryConfigurationError, IOException
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
|
|
|
FileInputStream fis = new FileInputStream(configFile);
|
|
|
|
XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(fis);
|
|
|
|
while(xmlReader.hasNext())
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
|
|
|
{
|
|
|
|
if(xmlReader.getLocalName().equals("TurnBasedMinecraftConfig"))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("Version"))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2018-09-14 03:44:45 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("MaxInBattle"))
|
|
|
|
{
|
|
|
|
maxInBattle = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
2018-09-18 06:56:06 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("FreezeBattleCombatants"))
|
|
|
|
{
|
|
|
|
freezeCombatantsInBattle = !xmlReader.getElementText().toLowerCase().equals("false");
|
|
|
|
}
|
2018-09-03 06:19:33 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("IgnoreBattleTypes"))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
|
|
|
{
|
2018-09-13 05:12:04 +00:00
|
|
|
ignoreBattleTypes.add(xmlReader.getLocalName().toLowerCase());
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("IgnoreBattleTypes")));
|
|
|
|
}
|
2018-09-14 05:14:10 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("BattleMusic"))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
|
|
|
{
|
|
|
|
if(xmlReader.getLocalName().equals("Normal"))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
|
|
|
{
|
|
|
|
musicBattleTypes.add(xmlReader.getLocalName().toLowerCase());
|
|
|
|
}
|
|
|
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("Normal")));
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("Silly"))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
|
|
|
{
|
|
|
|
musicSillyTypes.add(xmlReader.getLocalName().toLowerCase());
|
|
|
|
}
|
|
|
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("Silly")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("BattleMusic")));
|
|
|
|
}
|
2018-09-04 06:21:49 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("PlayerStats"))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
|
|
|
{
|
|
|
|
if(xmlReader.getLocalName().equals("Speed"))
|
|
|
|
{
|
|
|
|
playerSpeed = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("HasteSpeed"))
|
|
|
|
{
|
|
|
|
playerHasteSpeed = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("SlowSpeed"))
|
|
|
|
{
|
|
|
|
playerSlowSpeed = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
2018-09-05 06:54:06 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("AttackProbability"))
|
|
|
|
{
|
|
|
|
playerAttackProbability = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("Evasion"))
|
|
|
|
{
|
|
|
|
playerEvasion = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
2018-09-04 06:21:49 +00:00
|
|
|
}
|
|
|
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("PlayerStats")));
|
|
|
|
}
|
2018-09-05 06:54:06 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("DefenseDuration"))
|
|
|
|
{
|
|
|
|
defenseDuration = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("FleeGoodProbability"))
|
|
|
|
{
|
|
|
|
fleeGoodProbability = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("FleeBadProbability"))
|
|
|
|
{
|
|
|
|
fleeBadProbability = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
2018-09-13 05:52:48 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("MinimumHitPercentage"))
|
|
|
|
{
|
|
|
|
minimumHitPercentage = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
if(minimumHitPercentage < 1)
|
|
|
|
{
|
|
|
|
minimumHitPercentage = 1;
|
|
|
|
}
|
|
|
|
}
|
2018-09-25 05:55:24 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("BattleTurnTimeSeconds"))
|
|
|
|
{
|
|
|
|
int seconds = TurnBasedMinecraftMod.getBattleDurationSeconds();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
seconds = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
TurnBasedMinecraftMod.setBattleDurationSeconds(seconds);
|
|
|
|
} catch (Throwable t)
|
|
|
|
{
|
|
|
|
logger.warn("Unable to get value for \"BattleTurnTimeSeconds\" from config, using default");
|
|
|
|
TurnBasedMinecraftMod.setBattleDurationSeconds(TurnBasedMinecraftMod.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L);
|
|
|
|
}
|
|
|
|
}
|
2018-09-28 03:02:39 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("SillyMusicThreshold"))
|
|
|
|
{
|
|
|
|
sillyMusicThreshold = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
if(sillyMusicThreshold < 0)
|
|
|
|
{
|
|
|
|
sillyMusicThreshold = 0;
|
|
|
|
}
|
|
|
|
else if(sillyMusicThreshold > 100)
|
|
|
|
{
|
|
|
|
sillyMusicThreshold = 100;
|
|
|
|
}
|
|
|
|
}
|
2018-09-20 06:36:31 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("EntityEntry"))
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-20 06:36:31 +00:00
|
|
|
EntityInfo eInfo = new EntityInfo();
|
2018-09-03 06:19:33 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
|
|
|
{
|
2018-09-20 06:36:31 +00:00
|
|
|
if(xmlReader.getLocalName().equals("Name"))
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
eInfo.classType = Class.forName(xmlReader.getElementText());
|
|
|
|
} catch (ClassNotFoundException e)
|
|
|
|
{
|
|
|
|
logger.error("Failed to get class of name " + xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("AttackPower"))
|
|
|
|
{
|
|
|
|
for(int i = 0; i < xmlReader.getAttributeCount(); ++i)
|
|
|
|
{
|
|
|
|
if(xmlReader.getAttributeLocalName(i).equals("Probability"))
|
|
|
|
{
|
|
|
|
eInfo.attackProbability = Integer.parseInt(xmlReader.getAttributeValue(i));
|
|
|
|
}
|
|
|
|
else if(xmlReader.getAttributeLocalName(i).equals("Variance"))
|
|
|
|
{
|
|
|
|
eInfo.attackVariance = Integer.parseInt(xmlReader.getAttributeValue(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eInfo.attackPower = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("AttackEffect"))
|
|
|
|
{
|
|
|
|
for(int i = 0; i < xmlReader.getAttributeCount(); ++i)
|
|
|
|
{
|
|
|
|
if(xmlReader.getAttributeLocalName(i).equals("Probability"))
|
|
|
|
{
|
|
|
|
eInfo.attackEffectProbability = Integer.parseInt(xmlReader.getAttributeValue(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eInfo.attackEffect = EntityInfo.Effect.fromString(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("Evasion"))
|
|
|
|
{
|
|
|
|
eInfo.evasion = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("DefenseDamage"))
|
|
|
|
{
|
|
|
|
for(int i = 0; i < xmlReader.getAttributeCount(); ++i)
|
|
|
|
{
|
|
|
|
if(xmlReader.getAttributeLocalName(i).equals("Probability"))
|
|
|
|
{
|
|
|
|
eInfo.defenseDamageProbability = Integer.parseInt(xmlReader.getAttributeValue(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eInfo.defenseDamage = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("Category"))
|
|
|
|
{
|
|
|
|
eInfo.category = xmlReader.getElementText().toLowerCase();
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("IgnoreBattle"))
|
|
|
|
{
|
|
|
|
if(xmlReader.getElementText().toLowerCase().equals("true"))
|
|
|
|
{
|
|
|
|
eInfo.ignoreBattle = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("Speed"))
|
|
|
|
{
|
|
|
|
eInfo.speed = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
}
|
|
|
|
else if(xmlReader.getLocalName().equals("Decision"))
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-18 06:56:06 +00:00
|
|
|
do
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-18 06:56:06 +00:00
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement())
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-20 06:36:31 +00:00
|
|
|
if(xmlReader.getLocalName().equals("Attack"))
|
2018-09-18 06:56:06 +00:00
|
|
|
{
|
2018-09-20 06:36:31 +00:00
|
|
|
eInfo.decisionAttack = Integer.parseInt(xmlReader.getElementText());
|
2018-09-18 06:56:06 +00:00
|
|
|
}
|
2018-09-20 06:36:31 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("Defend"))
|
2018-09-18 06:56:06 +00:00
|
|
|
{
|
2018-09-20 06:36:31 +00:00
|
|
|
eInfo.decisionDefend = Integer.parseInt(xmlReader.getElementText());
|
2018-09-18 06:56:06 +00:00
|
|
|
}
|
2018-09-20 06:36:31 +00:00
|
|
|
else if(xmlReader.getLocalName().equals("Flee"))
|
2018-09-18 06:56:06 +00:00
|
|
|
{
|
2018-09-20 06:36:31 +00:00
|
|
|
eInfo.decisionFlee = Integer.parseInt(xmlReader.getElementText());
|
2018-09-18 06:56:06 +00:00
|
|
|
}
|
2018-09-06 08:08:36 +00:00
|
|
|
}
|
2018-09-20 06:36:31 +00:00
|
|
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("Decision")));
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
2018-09-20 06:36:31 +00:00
|
|
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("EntityEntry")));
|
|
|
|
if(eInfo.classType != null)
|
|
|
|
{
|
|
|
|
entityInfoMap.put(eInfo.classType.getName(), eInfo);
|
|
|
|
}
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xmlReader.close();
|
|
|
|
fis.close();
|
2018-09-07 07:41:22 +00:00
|
|
|
return true;
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
2018-09-04 06:21:49 +00:00
|
|
|
|
|
|
|
public int getPlayerSpeed()
|
|
|
|
{
|
|
|
|
return playerSpeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPlayerHasteSpeed()
|
|
|
|
{
|
|
|
|
return playerHasteSpeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPlayerSlowSpeed()
|
|
|
|
{
|
|
|
|
return playerSlowSpeed;
|
|
|
|
}
|
2018-09-05 06:54:06 +00:00
|
|
|
|
|
|
|
public int getPlayerAttackProbability()
|
|
|
|
{
|
|
|
|
return playerAttackProbability;
|
|
|
|
}
|
2018-09-04 06:21:49 +00:00
|
|
|
|
2018-09-05 06:54:06 +00:00
|
|
|
public int getPlayerEvasion()
|
|
|
|
{
|
|
|
|
return playerEvasion;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDefenseDuration()
|
|
|
|
{
|
|
|
|
return defenseDuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFleeGoodProbability()
|
|
|
|
{
|
|
|
|
return fleeGoodProbability;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFleeBadProbability()
|
|
|
|
{
|
|
|
|
return fleeBadProbability;
|
|
|
|
}
|
|
|
|
|
2018-09-04 06:21:49 +00:00
|
|
|
/**
|
|
|
|
* Returns a clone of an EntityInfo (to prevent editing it).
|
|
|
|
* @param classFullName
|
|
|
|
* @return a clone of the stored EntityInfo or null if invalid String
|
|
|
|
*/
|
|
|
|
public EntityInfo getEntityInfo(String classFullName)
|
|
|
|
{
|
|
|
|
return entityInfoMap.get(classFullName).clone();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected EntityInfo getEntityInfoReference(String classFullName)
|
|
|
|
{
|
|
|
|
return entityInfoMap.get(classFullName);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected EntityInfo getMatchingEntityInfo(Object entity)
|
|
|
|
{
|
2018-09-06 08:08:36 +00:00
|
|
|
if(entity == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2018-09-04 06:21:49 +00:00
|
|
|
EntityInfo matching = entityInfoMap.get(entity.getClass().getName());
|
2018-09-12 05:43:59 +00:00
|
|
|
if(matching != null && matching.classType.isInstance(entity))
|
2018-09-04 06:21:49 +00:00
|
|
|
{
|
|
|
|
return matching;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2018-09-07 07:41:22 +00:00
|
|
|
|
|
|
|
private int getConfigFileVersion(File configFile)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return getConfigFileVersion(new FileInputStream(configFile));
|
|
|
|
} catch(FileNotFoundException e)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private int getConfigFileVersion(InputStream configStream)
|
|
|
|
{
|
|
|
|
int configVersion = 1;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(configStream);
|
|
|
|
while(xmlReader.hasNext())
|
|
|
|
{
|
|
|
|
xmlReader.next();
|
|
|
|
if(xmlReader.isStartElement() && xmlReader.getLocalName().equals("Version"))
|
|
|
|
{
|
|
|
|
configVersion = Integer.parseInt(xmlReader.getElementText());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xmlReader.close();
|
2018-09-25 05:55:24 +00:00
|
|
|
} catch (Throwable t)
|
2018-09-07 07:41:22 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return configVersion;
|
|
|
|
}
|
2018-09-12 05:43:59 +00:00
|
|
|
|
2018-09-13 05:12:04 +00:00
|
|
|
public boolean isIgnoreBattleType(String type)
|
2018-09-12 05:43:59 +00:00
|
|
|
{
|
|
|
|
return ignoreBattleTypes.contains(type);
|
|
|
|
}
|
2018-09-13 05:52:48 +00:00
|
|
|
|
|
|
|
public int getMinimumHitPercentage()
|
|
|
|
{
|
|
|
|
return minimumHitPercentage;
|
|
|
|
}
|
2018-09-14 03:44:45 +00:00
|
|
|
|
|
|
|
public int getMaxInBattle()
|
|
|
|
{
|
|
|
|
return maxInBattle;
|
|
|
|
}
|
2018-09-14 05:14:10 +00:00
|
|
|
|
|
|
|
public boolean isBattleMusicType(String type)
|
|
|
|
{
|
|
|
|
return musicBattleTypes.contains(type.toLowerCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSillyMusicType(String type)
|
|
|
|
{
|
|
|
|
return musicSillyTypes.contains(type.toLowerCase());
|
|
|
|
}
|
2018-09-18 06:56:06 +00:00
|
|
|
|
|
|
|
public boolean isFreezeCombatantsEnabled()
|
|
|
|
{
|
|
|
|
return freezeCombatantsInBattle;
|
|
|
|
}
|
2018-09-28 03:02:39 +00:00
|
|
|
|
|
|
|
public int getSillyMusicThreshold()
|
|
|
|
{
|
|
|
|
return sillyMusicThreshold;
|
|
|
|
}
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|