*/
public void run() {
try {
Scanner reader = new Scanner(m_file);
NonPlayerChar npc = null;
WarpTile warp = null;
HMObject hmObject = null;
TradeChar t = null;
String line;
String [] details;
String direction = "Down";
while(reader.hasNextLine()) {
line = reader.nextLine();
if(line.equalsIgnoreCase("[npc]")) {
npc = new NonPlayerChar();
npc.setName(reader.nextLine());
direction = reader.nextLine();
if(direction.equalsIgnoreCase("UP")) {
npc.setFacing(Direction.Up);
} else if(direction.equalsIgnoreCase("LEFT")) {
npc.setFacing(Direction.Left);
} else if(direction.equalsIgnoreCase("RIGHT")) {
npc.setFacing(Direction.Right);
} else {
npc.setFacing(Direction.Down);
}
npc.setSprite(Integer.parseInt(reader.nextLine()));
npc.setX((Integer.parseInt(reader.nextLine())) * 32);
npc.setY(((Integer.parseInt(reader.nextLine())) * 32) - 8);
//Load possible Pokemons
line = reader.nextLine();
if(!line.equalsIgnoreCase("NULL")) {
details = line.split(",");
HashMap<String, Integer> pokes = new HashMap<String, Integer>();
for(int i = 0; i < details.length; i = i + 2) {
pokes.put(details[i], Integer.parseInt(details[i + 1]));
}
npc.setPossiblePokemon(pokes);
}
//Set minimum party level
npc.setPartySize(Integer.parseInt(reader.nextLine()));
npc.setBadge(Integer.parseInt(reader.nextLine()));
//Add all speech, if any
line = reader.nextLine();
if(!line.equalsIgnoreCase("NULL")) {
details = line.split(",");
for(int i = 0; i < details.length; i++) {
npc.addSpeech(Integer.parseInt(details[i]));
}
}
npc.setHealer(Boolean.parseBoolean(reader.nextLine().toLowerCase()));
npc.setBox(Boolean.parseBoolean(reader.nextLine().toLowerCase()));
//Setting ShopKeeper as an int.
String shop = reader.nextLine();
try {
npc.setShopKeeper(Integer.parseInt(shop.trim()));
} catch(Exception e) {
try {
/* Must be an old shop */
if(Boolean.parseBoolean(shop.trim().toLowerCase())){
npc.setShopKeeper(1); //Its an old shop! Yay!
} else {
npc.setShopKeeper(0); //Its an old npc. Not a shop.
}
} catch(Exception ex) {
npc.setShopKeeper(0);//Dunno what the hell it is, but its not a shop.
}
}
} else if(line.equalsIgnoreCase("[/npc]")) {
m_map.addChar(npc);
} else if(line.equalsIgnoreCase("[warp]")) {
warp = new WarpTile();
warp.setX(Integer.parseInt(reader.nextLine()));
warp.setY(Integer.parseInt(reader.nextLine()));
warp.setWarpX(Integer.parseInt(reader.nextLine()) * 32);
warp.setWarpY((Integer.parseInt(reader.nextLine()) * 32) - 8);
warp.setWarpMapX(Integer.parseInt(reader.nextLine()));
warp.setWarpMapY(Integer.parseInt(reader.nextLine()));
warp.setBadgeRequirement(Integer.parseInt(reader.nextLine()));
} else if(line.equalsIgnoreCase("[/warp]")) {
m_map.addWarp(warp);
} else if(line.equalsIgnoreCase("[hmobject]")) {
hmObject = new HMObject();
hmObject.setName(reader.nextLine());