/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.bindedobjects.core.loaders;
import transientlibs.bindedobjects.core.Binding;
import transientlibs.bindedobjects.core.datasets.GameCharacter;
import static transientlibs.bindedobjects.core.datasets.GameCharacter.container;
import transientlibs.bindedobjects.core.datasets.LesserBindedValueContainer;
import transientlibs.slick2d.util.Log;
import transientlibs.tex.StringAnalyst;
/**
*
* @author kibertoad
*/
public class GameCharacterLoader extends LesserBindedValueLoader {
public GameCharacterLoader(LesserBindedValueContainer container) {
super(container);
}
public void loadNpc() {
loadFromFile("characters.dat");
}
public GameCharacter lastCharacter(){
return (GameCharacter) container.lastElement;
}
@Override
public boolean analyzeString(String getString, StringAnalyst analyst) {
if (!"-NO-".equals(getString)) {
analyst.fullStr = getString;
}
analyst.getNextString();
String nowStr = analyst.lastStr;
boolean withResult = false;
if (nowStr.equals("npc")) {
container.add(new GameCharacter());
container.getID(analyst);
//ReqList.lastReqList = lastNpc.trainReqs;
withResult = true;
}
if (nowStr.equals("skill")) {
nowStr = analyst.getNextString();
int value = analyst.getNextNumber();
lastCharacter().skillSet.add(Binding.readBinding(Binding.skillBinding, nowStr), value);
withResult = true;
}
/*
if (nowStr.equals("name")) {
lastNpc.LName.value = analyst.getNextString();
withResult = true;
}
if (nowStr.equals("desc")) {
lastNpc.desc = analyst.restOfRow();
withResult = true;
}
*/
/*
if (nowStr.equals("trait")) {
LinkedValue<PersonalityTraits> trait = lastNpc.person.personality.get(analyst.readBinding(Binding.personalityTraitBinding));
trait.valueReference.value = analyst.getNextNumber();
withResult = true;
}
if (nowStr.equals("interest")) {
LinkedValue<Domain> trait = lastNpc.person.interests.get(analyst.readBinding(Binding.domainBinding));
trait.valueReference.value = analyst.getNextNumber();
withResult = true;
}
*/
if (withResult == false) {
withResult = super.analyzeString(analyst.fullStr, analyst);
}
if ((withResult == false) && (nowStr.length() > 2) && (!nowStr.startsWith("//"))) {
Log.error("Unknown string: " + nowStr);
}
return withResult;
}
}