Search in sources :

Example 1 with SourceEntry

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

the class PreVarTest method test2857848c.

public void test2857848c() {
    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");
    context.unconditionallyProcess(notawarrior, "PREVARGTEQ", "MyVar,1");
    Skill concentration = context.getReferenceContext().constructCDOMObject(Skill.class, "Concentration");
    context.unconditionallyProcess(notawarrior, "CSKILL", "Concentration");
    context.unconditionallyProcess(notawarrior, "BONUS", "SKILL|Concentration|5");
    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();
        assertFalse(notawarrior.qualifies(character, notawarrior));
        //Fails
        character.incrementClassLevel(1, notawarrior);
        assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
        character.incrementClassLevel(1, warrior);
        assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
        assertTrue(notawarrior.qualifies(character, notawarrior));
        character.incrementClassLevel(1, notawarrior);
        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 2 with SourceEntry

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

the class PreVarTest method test2857849and2862276.

public void test2857849and2862276() {
    LoadContext context = Globals.getContext();
    final PCClass spellcaster = new PCClass();
    spellcaster.setName("Spellcaster");
    context.getReferenceContext().importObject(spellcaster);
    context.unconditionallyProcess(spellcaster, "SPELLTYPE", "Arcane");
    context.unconditionallyProcess(spellcaster, "SPELLSTAT", "INT");
    context.unconditionallyProcess(spellcaster, "PREVARGTEQ", "BASESPELLSTAT,2");
    PCClassLoader loader = new PCClassLoader();
    try {
        SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        loader.completeObject(context, se, spellcaster);
        context.getReferenceContext().resolveReferences(null);
        PlayerCharacter character = this.getCharacter();
        setPCStat(character, intel, 16);
        assertTrue(spellcaster.qualifies(character, spellcaster));
    } catch (URISyntaxException | PersistenceLayerException e) {
        fail(e.getMessage());
    }
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) 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 3 with SourceEntry

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

the class PreVarTest method test2857849a.

public void test2857849a() {
    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");
    PCClassLoader loader = new PCClassLoader();
    try {
        SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        final PCClass notawarrior = loader.parseLine(context, null, "CLASS:NotAWarrior\tPREVARGTEQ:MyVar,1", se);
        loader.completeObject(context, se, warrior);
        loader.completeObject(context, se, notawarrior);
        PlayerCharacter character = this.getCharacter();
        assertFalse(notawarrior.qualifies(character, notawarrior));
        character.incrementClassLevel(1, warrior);
        assertTrue(notawarrior.qualifies(character, notawarrior));
    } catch (URISyntaxException | PersistenceLayerException e) {
        fail(e.getMessage());
    }
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) 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 4 with SourceEntry

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

the class PreVarTest method test2857848a.

public void test2857848a() {
    LoadContext context = Globals.getContext();
    final PCClass spellcaster = new PCClass();
    spellcaster.setName("Spellcaster");
    context.getReferenceContext().importObject(spellcaster);
    Skill concentration = context.getReferenceContext().constructCDOMObject(Skill.class, "Concentration");
    context.unconditionallyProcess(spellcaster, "SPELLTYPE", "Arcane");
    context.unconditionallyProcess(spellcaster, "SPELLSTAT", "INT");
    context.unconditionallyProcess(spellcaster, "CSKILL", "Concentration");
    context.unconditionallyProcess(spellcaster, "BONUS", "SKILL|Concentration|5|PREVARGT:BASESPELLSTAT,2");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    PlayerCharacter character = this.getCharacter();
    setPCStat(character, intel, 16);
    PCClassLoader loader = new PCClassLoader();
    try {
        SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        loader.completeObject(context, se, spellcaster);
        assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
        character.incrementClassLevel(1, spellcaster);
        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) 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) URISyntaxException(java.net.URISyntaxException) PCClass(pcgen.core.PCClass) URI(java.net.URI)

Example 5 with SourceEntry

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

the class SourceFileLoader method addDefaultEquipmentMods.

private void addDefaultEquipmentMods(LoadContext context) throws PersistenceLayerException {
    URI uri = URI.create("file:/" + eqModLoader.getClass().getName() + ".java");
    context.setSourceURI(uri);
    SourceEntry source = new CampaignSourceEntry(new Campaign(), uri);
    LoadContext subContext = context.dropIntoContext("EQUIPMENT");
    String aLine;
    aLine = "Add Type\tKEY:ADDTYPE\tTYPE:ALL\tCOST:0\tNAMEOPT:NONAME\tSOURCELONG:PCGen Internal\tCHOOSE:EQBUILDER.EQTYPE|COUNT=ALL|TITLE=desired TYPE(s)";
    eqModLoader.parseLine(subContext, null, aLine, source);
    //
    // Add internal equipment modifier for adding weapon/armor types to
    // equipment
    //
    aLine = Constants.INTERNAL_EQMOD_WEAPON + "\tTYPE:Weapon\tVISIBLE:NO\tCHOOSE:NOCHOICE\tNAMEOPT:NONAME";
    eqModLoader.parseLine(subContext, null, aLine, source);
    aLine = Constants.INTERNAL_EQMOD_ARMOR + "\tTYPE:Armor\tVISIBLE:NO\tCHOOSE:NOCHOICE\tNAMEOPT:NONAME";
    eqModLoader.parseLine(subContext, null, aLine, source);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) LoadContext(pcgen.rules.context.LoadContext) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) SourceEntry(pcgen.persistence.lst.SourceEntry) URI(java.net.URI)

Aggregations

URI (java.net.URI)7 Campaign (pcgen.core.Campaign)7 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 LoadContext (pcgen.rules.context.LoadContext)7 URISyntaxException (java.net.URISyntaxException)6 PCClass (pcgen.core.PCClass)6 PlayerCharacter (pcgen.core.PlayerCharacter)6 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)6 PCClassLoader (pcgen.persistence.lst.PCClassLoader)6 Skill (pcgen.core.Skill)3 PCClassLevel (pcgen.cdom.inst.PCClassLevel)1 SpecialAbility (pcgen.core.SpecialAbility)1