/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.bindedobjects.gamecontent;
import java.util.ArrayList;
import transientlibs.bindedobjects.core.Binding;
import transientlibs.bindedobjects.core.datasets.LesserBindedValue;
import transientlibs.objects.general.Node;
import transientlibs.tex.StringAnalyst;
/**
*
* @author kibertoad
*/
public class Stats extends LesserBindedValue {
public static ArrayList<Stats> stats = new ArrayList<Stats>();
public static Stats lastStat;
public static void loadStats() {
if (StringAnalyst.isFileExist("stats.dat")) {
StringAnalyst reader = new StringAnalyst();
reader.openFile("stats.dat");
while (!reader.eof) {
reader.readRow();
analyzeStringForStats(reader);
}
reader.closeFile();
}
}
public static void analyzeStringForStats(StringAnalyst analyst) {
analyzeStringForStats("-NO-", analyst);
}
public static void analyzeStringForStats(String getString, StringAnalyst analyst) {
if (!"-NO-".equals(getString)) {
analyst.fullStr = getString;
}
analyst.checkForAliases();
analyst.getNextString();
String nowStr = analyst.lastStr;
if (nowStr.equals("stat")) {
stats.add(new Stats());
lastStat = stats.get(stats.size() - 1);
lastStat.ID = analyst.getBinding(Binding.statBinding);
}
if (nowStr.equals("name")) {
lastStat.LName.value = analyst.restOfRow();
}
if (nowStr.equals("desc")) {
lastStat.desc = analyst.restOfRow();
}
}
@Override
public String name() {
return LName.value;
}
public static Stats getStatsByCode(String getCode) {
return getStatsByID (Binding.getBinding(Binding.statBinding, getCode));
}
public static Stats getStatsByID(int getCode) {
for (Stats l : stats) {
if (l.ID == getCode) {
return l;
}
}
return null;
}
}