Search in sources :

Example 1 with XPTable

use of pcgen.core.XPTable in project pcgen by PCGen.

the class LevelLoader method validateLevelInfo.

private static boolean validateLevelInfo(GameMode gameMode, String xpTable, LevelInfo levelInfo, String inputLine, int lineNum, URI source) {
    String level = levelInfo.getLevelString();
    if (level == null) {
        Logging.errorPrint("LevelLoader got empty level value in '" + inputLine + "' at line " + lineNum + " of " + source + ". Line ignored.");
        return false;
    }
    XPTable existingTable = gameMode.getLevelInfo(xpTable);
    if (existingTable == null) {
        // No data on this table held yet, so it has to be right
        return true;
    }
    // Not a number so just check for a duplicate
    if (existingTable.getLevelInfo(level) != null) {
        Logging.errorPrint("LevelLoader got duplicate level value of '" + level + "' in '" + inputLine + "' at line " + lineNum + " of " + source + ". Line ignored.");
        return false;
    }
    if (!isNumeric(level)) {
        // Not a number so must be good now
        return true;
    }
    if (!existingTable.validateSequence(level)) {
        Logging.errorPrint("LevelLoader got out of sequence level value of '" + level + "' in '" + inputLine + "' at line " + lineNum + " of " + source + ". Line ignored.");
    }
    return true;
}
Also used : XPTable(pcgen.core.XPTable)

Example 2 with XPTable

use of pcgen.core.XPTable in project pcgen by PCGen.

the class XPTableFacetTest method testGetLevelInfoWrongLevel.

@Test
public void testGetLevelInfoWrongLevel() {
    XPTable t1 = getItem();
    LevelInfo li = new LevelInfo();
    t1.addLevelInfo("2", li);
    CharID id = getCharID();
    facet.set(id, t1);
    LevelInfo xpt = facet.getLevelInfo(id, 1);
    assertNull(xpt);
}
Also used : XPTable(pcgen.core.XPTable) LevelInfo(pcgen.core.LevelInfo) CharID(pcgen.cdom.enumeration.CharID) AbstractItemFacetTest(pcgen.cdom.testsupport.AbstractItemFacetTest) Test(org.junit.Test)

Example 3 with XPTable

use of pcgen.core.XPTable in project pcgen by PCGen.

the class XPTableFacetTest method testGetLevelInfoEmptyTable.

@Test
public void testGetLevelInfoEmptyTable() {
    XPTable t1 = getItem();
    CharID id = getCharID();
    facet.set(id, t1);
    assertNull(facet.getLevelInfo(id, 1));
}
Also used : XPTable(pcgen.core.XPTable) CharID(pcgen.cdom.enumeration.CharID) AbstractItemFacetTest(pcgen.cdom.testsupport.AbstractItemFacetTest) Test(org.junit.Test)

Example 4 with XPTable

use of pcgen.core.XPTable in project pcgen by PCGen.

the class XPTableFacetTest method testGetLevelInfoZeroLevel.

@Test
public void testGetLevelInfoZeroLevel() {
    XPTable t1 = getItem();
    CharID id = getCharID();
    facet.set(id, t1);
    assertNull(facet.getLevelInfo(id, 0));
}
Also used : XPTable(pcgen.core.XPTable) CharID(pcgen.cdom.enumeration.CharID) AbstractItemFacetTest(pcgen.cdom.testsupport.AbstractItemFacetTest) Test(org.junit.Test)

Example 5 with XPTable

use of pcgen.core.XPTable in project pcgen by PCGen.

the class XPTableFacetTest method testGetLevelInfoLevel.

@Test
public void testGetLevelInfoLevel() {
    XPTable t1 = getItem();
    LevelInfo li = new LevelInfo();
    t1.addLevelInfo("LEVEL", li);
    CharID id = getCharID();
    facet.set(id, t1);
    LevelInfo xpt = facet.getLevelInfo(id, 1);
    assertNotNull(xpt);
    assertSame(li, xpt);
}
Also used : XPTable(pcgen.core.XPTable) LevelInfo(pcgen.core.LevelInfo) CharID(pcgen.cdom.enumeration.CharID) AbstractItemFacetTest(pcgen.cdom.testsupport.AbstractItemFacetTest) Test(org.junit.Test)

Aggregations

XPTable (pcgen.core.XPTable)10 Test (org.junit.Test)6 CharID (pcgen.cdom.enumeration.CharID)6 AbstractItemFacetTest (pcgen.cdom.testsupport.AbstractItemFacetTest)6 LevelInfo (pcgen.core.LevelInfo)5 GameMode (pcgen.core.GameMode)1 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)1