Search in sources :

Example 81 with CampaignSourceEntry

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

the class CompanionmodToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
    if (cse == null) {
        //Error
        return ParseResult.INTERNAL_ERROR;
    }
    if (!cse.getIncludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not allow INCLUDE: " + value, context);
    }
    if (!cse.getExcludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not allow EXCLUDE: " + value, context);
    }
    context.getObjectContext().addToList(campaign, ListKey.FILE_COMPANION_MOD, cse);
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 82 with CampaignSourceEntry

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

the class CoverToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
    if (cse == null) {
        //Error
        return ParseResult.INTERNAL_ERROR;
    }
    if (!cse.getIncludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not allow INCLUDE: " + value, context);
    }
    if (!cse.getExcludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not allow EXCLUDE: " + value, context);
    }
    context.getObjectContext().addToList(campaign, ListKey.FILE_COVER, cse);
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 83 with CampaignSourceEntry

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

the class DataControlToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
    if (cse == null) {
        //Error
        return ParseResult.INTERNAL_ERROR;
    }
    if (!cse.getIncludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not support Include");
    }
    if (!cse.getExcludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not support Exclude");
    }
    if (!cse.getPrerequisites().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not support Prerequisites");
    }
    context.getObjectContext().addToList(campaign, ListKey.FILE_DATACTRL, cse);
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 84 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry 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 85 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry 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)

Aggregations

CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)95 URI (java.net.URI)54 Campaign (pcgen.core.Campaign)44 URISyntaxException (java.net.URISyntaxException)27 LoadContext (pcgen.rules.context.LoadContext)25 UnreachableError (pcgen.base.lang.UnreachableError)19 BeforeClass (org.junit.BeforeClass)16 PCClassLoader (pcgen.persistence.lst.PCClassLoader)15 TreeSet (java.util.TreeSet)12 PlayerCharacter (pcgen.core.PlayerCharacter)11 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 ArrayList (java.util.ArrayList)9 PCClass (pcgen.core.PCClass)9 File (java.io.File)8 GenericLoader (pcgen.persistence.lst.GenericLoader)8 CDOMReference (pcgen.cdom.base.CDOMReference)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 Ability (pcgen.core.Ability)6 FeatLoader (pcgen.persistence.lst.FeatLoader)6 AbilityList (pcgen.cdom.list.AbilityList)5