/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.bindedobjects.gamecontent;
import java.util.ArrayList;
import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.Binding;
import transientlibs.bindedobjects.core.datasets.LesserBindedValue;
import transientlibs.tex.StringAnalyst;
/**
*
* @author kibertoad
*/
public class CardGroups extends LesserBindedValue {
public static ArrayList<CardGroups> cardGroups = new ArrayList<CardGroups>();
public static CardGroups lastCardGroups;
public static void loadCardGroups (){
if (StringAnalyst.isFileExist("cardgroups.dat")) {
StringAnalyst reader = new StringAnalyst();
reader.openFile("cardgroups.dat");
while (!reader.eof) {
reader.readRow();
analyzeStringForCardGroups (reader);
}
reader.closeFile();
}
}
public static void analyzeStringForCardGroups (StringAnalyst analyst) {
analyzeStringForCardGroups ("-NO-", analyst);
}
public static void analyzeStringForCardGroups (String getString, StringAnalyst analyst) {
if (!"-NO-".equals(getString)) {analyst.fullStr = getString;}
analyst.getNextString();
String nowStr = analyst.lastStr;
boolean withResult = false;
if (nowStr.equals("cardgroup")) {
cardGroups.add (new CardGroups ());
lastCardGroups = cardGroups.get(cardGroups.size()-1);
lastCardGroups.ID = analyst.getBinding (Binding.cardTypeBinding);
//ReqList.lastReqList = lastItemGroups.trainReqs;
withResult = true;
}
if (nowStr.equals("name")) {
lastCardGroups.LName.value = analyst.getNextString();
withResult = true;
}
if (nowStr.equals("desc")) {
lastCardGroups.desc = analyst.restOfRow();
withResult = true;
}
if ((withResult == false) && (nowStr.length()>2) && (!nowStr.startsWith("//"))) {
Log.error("Unknown string: "+nowStr); }
}
@Override
public String name (){
return LName.value;
}
public static CardGroups getCardGroupsByID (int getCode) {
for (CardGroups i : cardGroups) {
if (i.ID == getCode) {
return i;
}
}
return null;
}
public static CardGroups getCardGroupsByCode(String byCode) {
return getCardGroupsByID(Binding.readBinding(Binding.cardTypeBinding, byCode.toLowerCase()));
}
}