package catchemrpg.persistency;
import catchemrpg.base.BaseVars;
import catchemrpg.base.CharacterData;
import catchemrpg.gameobjects.Monster;
/**
* A simple test to see if loading and saving .properties is working correctly.
* @author Toby Pinder (Gigitrix)
*/
public class MonsterIO extends PropertiesFileIO
{
//TODO USE MAP METADATA
/**
* Constructor.
*/
public MonsterIO()
{
}
@Override
/**
* Load a map metadata file
*/
public boolean loadProperties()
{
loadLocation = "/crpgdata/save/" + BaseVars.saveFile + "/monsterTeam.properties";
Boolean success = super.loadProperties();
try
{
for (int i = 0; i < 5; i++)
{
//Get creature ID, for use with language queries for Monster metadata.
int ID = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$id", "0"));
CharacterData.monsterList[i] = new Monster();
CharacterData.monsterList[i].NAME = BaseVars.lang.monsterNames.get(ID);
CharacterData.monsterList[i].imagePath = properties.getProperty("monsters$current$" + (i + 1) + "$imgpath", "");
CharacterData.monsterList[i].CATEGORY1 = BaseVars.lang.monsterCat1s.get(ID);
CharacterData.monsterList[i].CATEGORY2 = BaseVars.lang.monsterCat2s.get(ID);
CharacterData.monsterList[i].DESCRIPTION = BaseVars.lang.monsterDescs.get(ID);
//CharacterData.monsterList[i].TYPE=null;
CharacterData.monsterList[i].att = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$att", "0"));
CharacterData.monsterList[i].attBase = CharacterData.monsterList[i].att;
CharacterData.monsterList[i].def = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$def", "0"));
CharacterData.monsterList[i].defBase = CharacterData.monsterList[i].def;
CharacterData.monsterList[i].HP = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$HP", "1"));
CharacterData.monsterList[i].HPmax = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$HPmax", "1"));
CharacterData.monsterList[i].HPregen = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$HPregen", "0"));
CharacterData.monsterList[i].MP = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$MP", "1"));
CharacterData.monsterList[i].MPmax = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$MPmax", "1"));
CharacterData.monsterList[i].MPregen = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$MPregen", "0"));
CharacterData.monsterList[i].MPstart = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$MPstart", "0"));
CharacterData.monsterList[i].exp = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$exp", "0"));
//
CharacterData.monsterList[i].attachment = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$attachment", "0"));
CharacterData.monsterList[i].attachmentmax = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$attachment$max", "0"));
CharacterData.monsterList[i].happiness = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$happiness", "0"));
CharacterData.monsterList[i].happinessmax = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$happiness$max", "0"));
//
CharacterData.monsterList[i].blockPercent = Double.parseDouble(properties.getProperty("monsters$current$" + (i + 1) + "$block", "0"));
CharacterData.monsterList[i].critPercent = Double.parseDouble(properties.getProperty("monsters$current$" + (i + 1) + "$critical", "0"));
CharacterData.monsterList[i].evadePercent = Double.parseDouble(properties.getProperty("monsters$current$" + (i + 1) + "$evade", "0"));
//
CharacterData.monsterList[i].killCount = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$kills", "0"));
CharacterData.monsterList[i].deathCount = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$deaths", "0"));
//
CharacterData.monsterList[i].size = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$size", "0"));
CharacterData.monsterList[i].weight = Integer.parseInt(properties.getProperty("monsters$current$" + (i + 1) + "$weight", "0"));
}
} catch (IndexOutOfBoundsException ioobe)
{
System.err.println("Missing language files causing Monster to load incorrectly.");
ioobe.printStackTrace();
}
//now tidy up getting creature language data.
return success;
}
@Override
/**
* Save a map metadata file
*/
public boolean saveProperties()
{
saveLocation = "/crpgdata/save/" + BaseVars.saveFile + "/monster.properties";
//stuff to do
Boolean success = super.saveProperties();
return success;
}
}