/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.bindedobjects.gamecontent;
import transientlibs.objects.general.Node;
import transientlibs.tex.StringAnalyst;
import java.util.ArrayList;
import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.Binding;
/**
*
* @author kibertoad
*/
public class Nation extends Node {
public String LName;
public String desc;
public static ArrayList<Nation> nations = new ArrayList<Nation>();
public static Nation lastNation;
public static void loadNations() {
if (StringAnalyst.isFileExist("nations.dat")) {
StringAnalyst reader = new StringAnalyst();
reader.openFile("nations.dat");
while (!reader.eof) {
reader.readRow();
analyzeStringForNations(reader);
}
reader.closeFile();
}
}
public static void analyzeStringForNations(StringAnalyst analyst) {
analyzeStringForNations("-NO-", analyst);
}
public static void analyzeStringForNations(String getString, StringAnalyst analyst) {
if (!"-NO-".equals(getString)) {
analyst.fullStr = getString;
}
analyst.checkForAliases();
analyst.getNextString();
String nowStr = analyst.lastStr;
boolean withResult = false;
if (nowStr.equals("nation")) {
nations.add(new Nation());
lastNation = nations.get(nations.size() - 1);
lastNation.ID = analyst.getBinding(Binding.nationBinding);
lastNation.LName = analyst.lastStr;
withResult = true;
//ReqList.lastReqList = lastNation.trainReqs;
}
if (nowStr.equals("name")) {
lastNation.LName = analyst.restOfRow();
withResult = true;
}
if (nowStr.equals("desc")) {
lastNation.desc = analyst.restOfRow();
withResult = true;
}
if ((withResult == false) && (nowStr.length() > 2) && (!nowStr.startsWith("//"))) {
Log.error("Unknown string: " + nowStr);
}
}
@Override
public String name() {
return LName;
}
}