Search in sources :

Example 16 with PCClassLoader

use of pcgen.persistence.lst.PCClassLoader in project pcgen by PCGen.

the class TestHelper method parsePCClassText.

public static PCClass parsePCClassText(String classPCCText, CampaignSourceEntry source) throws PersistenceLayerException {
    PCClassLoader pcClassLoader = new PCClassLoader();
    PCClass reconstClass = null;
    StringTokenizer tok = new StringTokenizer(classPCCText, "\n");
    while (tok.hasMoreTokens()) {
        String line = tok.nextToken();
        if (line.trim().length() > 0) {
            System.out.println("Processing line:'" + line + "'.");
            reconstClass = pcClassLoader.parseLine(Globals.getContext(), reconstClass, line, source);
        }
    }
    return reconstClass;
}
Also used : StringTokenizer(java.util.StringTokenizer) PCClassLoader(pcgen.persistence.lst.PCClassLoader) PCClass(pcgen.core.PCClass)

Example 17 with PCClassLoader

use of pcgen.persistence.lst.PCClassLoader in project pcgen by PCGen.

the class PreVarTest method test2857848b.

public void test2857848b() {
    final PCClass warrior = new PCClass();
    warrior.setName("Warrior");
    LoadContext context = Globals.getContext();
    context.unconditionallyProcess(warrior, "DEFINE", "MyVar|0");
    context.unconditionallyProcess(warrior, "BONUS", "VAR|MyVar|2");
    final PCClass notawarrior = new PCClass();
    notawarrior.setName("NotAWarrior");
    Skill concentration = context.getReferenceContext().constructCDOMObject(Skill.class, "Concentration");
    context.unconditionallyProcess(notawarrior, "CSKILL", "Concentration");
    context.unconditionallyProcess(notawarrior, "BONUS", "SKILL|Concentration|5|PREVARGT:MyVar,1");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    PCClassLoader loader = new PCClassLoader();
    try {
        SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        loader.completeObject(context, se, warrior);
        loader.completeObject(context, se, notawarrior);
        PlayerCharacter character = this.getCharacter();
        character.incrementClassLevel(1, notawarrior);
        assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
        character.incrementClassLevel(1, warrior);
        assertEquals(5, SkillModifier.modifier(concentration, character).intValue());
    } catch (URISyntaxException | PersistenceLayerException e) {
        fail(e.getMessage());
    }
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Skill(pcgen.core.Skill) Campaign(pcgen.core.Campaign) PlayerCharacter(pcgen.core.PlayerCharacter) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) SourceEntry(pcgen.persistence.lst.SourceEntry) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) URISyntaxException(java.net.URISyntaxException) PCClass(pcgen.core.PCClass) URI(java.net.URI)

Example 18 with PCClassLoader

use of pcgen.persistence.lst.PCClassLoader in project pcgen by PCGen.

the class PreVarTest method test2856626.

public void test2856626() {
    LoadContext context = Globals.getContext();
    final PCClass warrior = new PCClass();
    warrior.setName("Warrior");
    context.getReferenceContext().importObject(warrior);
    context.unconditionallyProcess(warrior, "SAB", "Test Works|PREVARGTEQ:CL,2");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    PlayerCharacter character = this.getCharacter();
    character.incrementClassLevel(1, warrior);
    PCClassLoader loader = new PCClassLoader();
    try {
        CampaignSourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        loader.completeObject(context, se, warrior);
        PCClass notawarrior = loader.getCopy(context, "Warrior", "NotAWarrior", se);
        List<SpecialAbility> sabList = notawarrior.getListFor(ListKey.SAB);
        assertNotNull(sabList);
        assertEquals(1, sabList.size());
        SpecialAbility sab = sabList.get(0);
        assertFalse(sab.qualifies(character, notawarrior));
        character.incrementClassLevel(1, notawarrior);
        assertFalse(sab.qualifies(character, notawarrior));
        character.incrementClassLevel(1, notawarrior);
        assertTrue(sab.qualifies(character, notawarrior));
    } catch (URISyntaxException | PersistenceLayerException e) {
        fail(e.getMessage());
    }
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) PlayerCharacter(pcgen.core.PlayerCharacter) Campaign(pcgen.core.Campaign) SpecialAbility(pcgen.core.SpecialAbility) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) URISyntaxException(java.net.URISyntaxException) PCClass(pcgen.core.PCClass) URI(java.net.URI)

Example 19 with PCClassLoader

use of pcgen.persistence.lst.PCClassLoader in project pcgen by PCGen.

the class PreVarTest method test2856622.

public void test2856622() {
    LoadContext context = Globals.getContext();
    final PCClass warrior = new PCClass();
    warrior.setName("Warrior");
    PCClassLevel level1 = warrior.getOriginalClassLevel(1);
    context.unconditionallyProcess(level1, "SAB", "Test Works|PREVARGTEQ:CL,3");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    PlayerCharacter character = this.getCharacter();
    character.incrementClassLevel(1, warrior);
    PCClassLoader loader = new PCClassLoader();
    try {
        SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        loader.completeObject(context, se, warrior);
        List<SpecialAbility> sabList = level1.getListFor(ListKey.SAB);
        assertNotNull(sabList);
        assertEquals(1, sabList.size());
        SpecialAbility sab = sabList.get(0);
        assertFalse(sab.qualifies(character, warrior));
        character.incrementClassLevel(1, warrior);
        assertFalse(sab.qualifies(character, warrior));
        character.incrementClassLevel(1, warrior);
        assertTrue(sab.qualifies(character, warrior));
    } catch (URISyntaxException | PersistenceLayerException e) {
        fail(e.getMessage());
    }
}
Also used : SpecialAbility(pcgen.core.SpecialAbility) URISyntaxException(java.net.URISyntaxException) PCClass(pcgen.core.PCClass) URI(java.net.URI) PCClassLevel(pcgen.cdom.inst.PCClassLevel) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) PlayerCharacter(pcgen.core.PlayerCharacter) Campaign(pcgen.core.Campaign) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) SourceEntry(pcgen.persistence.lst.SourceEntry) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Aggregations

PCClassLoader (pcgen.persistence.lst.PCClassLoader)19 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)15 LoadContext (pcgen.rules.context.LoadContext)14 URI (java.net.URI)13 URISyntaxException (java.net.URISyntaxException)11 PCClass (pcgen.core.PCClass)11 Campaign (pcgen.core.Campaign)10 PlayerCharacter (pcgen.core.PlayerCharacter)8 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)8 SourceEntry (pcgen.persistence.lst.SourceEntry)6 UnreachableError (pcgen.base.lang.UnreachableError)4 StringTokenizer (java.util.StringTokenizer)3 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)3 Skill (pcgen.core.Skill)3 GenericLoader (pcgen.persistence.lst.GenericLoader)3 StringManager (pcgen.base.format.StringManager)2 LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)2 Description (pcgen.core.Description)2 SizeAdjustment (pcgen.core.SizeAdjustment)2 SpecialAbility (pcgen.core.SpecialAbility)2