Search in sources :

Example 11 with Race

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

the class AutoLangListTest method testFromRace.

@Test
public void testFromRace() throws PersistenceLayerException {
    Race source = create(Race.class, "Source");
    Language granted = createGrantedObject();
    processToken(source);
    assertEquals(0, getCount());
    raceFacet.directSet(id, source, getAssoc());
    assertTrue(containsExpected(granted));
    assertEquals(1, getCount());
    raceFacet.remove(id);
    assertEquals(0, getCount());
    assertTrue(cleanedSideEffects());
}
Also used : Language(pcgen.core.Language) Race(pcgen.core.Race) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 12 with Race

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

the class AbstractAddListTokenTest method testFromRace.

//Language not *supposed* to do things like this
@Test
public void testFromRace() throws PersistenceLayerException {
    Race source = create(Race.class, "Source");
    T granted = createGrantedObject();
    processToken(source);
    assertEquals(0, getCount());
    raceFacet.directSet(id, source, getAssoc());
    assertTrue(containsExpected(granted));
    assertEquals(1, getCount());
    raceFacet.remove(id);
    assertEquals(0, getCount());
    assertTrue(cleanedSideEffects());
}
Also used : Race(pcgen.core.Race) Test(org.junit.Test)

Example 13 with Race

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

the class SpellSupportFacadeImpl method buildKnownPreparedSpellsForCDOMObject.

private void buildKnownPreparedSpellsForCDOMObject(CDOMObject pObject) {
    Collection<? extends CharacterSpell> sp = charDisplay.getCharacterSpells(pObject);
    List<CharacterSpell> cSpells = new ArrayList<>(sp);
    // Add in the spells granted by objects
    pc.addBonusKnownSpellsToList(pObject, cSpells);
    PCClass pcClass = (PCClass) (pObject instanceof PCClass ? pObject : null);
    for (CharacterSpell charSpell : cSpells) {
        for (SpellInfo spellInfo : charSpell.getInfoList()) {
            // Create SpellNodeImpl for each spell
            String book = spellInfo.getBook();
            boolean isKnown = Globals.getDefaultSpellBook().equals(book);
            SpellFacadeImplem spellImplem = new SpellFacadeImplem(pc, charSpell.getSpell(), charSpell, spellInfo);
            SpellNodeImpl node;
            if (pcClass != null) {
                node = new SpellNodeImpl(spellImplem, pcClass, String.valueOf(spellInfo.getActualLevel()), getRootNode(book));
            } else {
                node = new SpellNodeImpl(spellImplem, String.valueOf(spellInfo.getActualLevel()), getRootNode(book));
            }
            if (spellInfo.getTimes() > 1) {
                node.addCount(spellInfo.getTimes() - 1);
            }
            boolean isSpellBook = charDisplay.getSpellBookByName(book).getType() == SpellBook.TYPE_SPELL_BOOK;
            // Add to list
            if (isKnown) {
                allKnownSpellNodes.addElement(node);
                knownSpellNodes.addElement(node);
            } else if (isSpellBook) {
                bookSpellNodes.addElement(node);
            } else if (pObject instanceof Race) {
                allKnownSpellNodes.addElement(node);
            } else {
                preparedSpellNodes.addElement(node);
            }
        }
    }
}
Also used : Race(pcgen.core.Race) ArrayList(java.util.ArrayList) CharacterSpell(pcgen.core.character.CharacterSpell) PCClass(pcgen.core.PCClass) SpellSupportForPCClass(pcgen.core.SpellSupportForPCClass) SpellInfo(pcgen.core.character.SpellInfo)

Example 14 with Race

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

the class Gui2InfoFactory method getStatAdjustments.

/**
	 * @see pcgen.core.facade.InfoFactory#getStatAdjustments(pcgen.core.facade.RaceFacade)
	 */
@Override
public String getStatAdjustments(RaceFacade raceFacade) {
    if (!(raceFacade instanceof Race)) {
        return EMPTY_STRING;
    }
    Race race = (Race) raceFacade;
    final StringBuilder retString = new StringBuilder(100);
    for (PCStat stat : charDisplay.getStatSet()) {
        if (charDisplay.isNonAbility(stat)) {
            if (retString.length() > 0) {
                retString.append(' ');
            }
            retString.append(stat.getKeyName() + ":Nonability");
        } else {
            if (BonusCalc.getStatMod(race, stat, pc) != 0) {
                if (retString.length() > 0) {
                    retString.append(' ');
                }
                retString.append(stat.getKeyName() + ":" + BonusCalc.getStatMod(race, stat, pc));
            }
        }
    }
    return retString.toString();
}
Also used : Race(pcgen.core.Race) PCStat(pcgen.core.PCStat)

Example 15 with Race

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

the class ActiveSpellsFacet method process.

/**
	 * Currently used as a global reset for the spell list, since
	 * ActiveSpellsFacet does not currently listen to all scenarios which can
	 * alter Spells granted to a Player Character.
	 * 
	 * Use of this method outside this facet is discouraged, as the long term
	 * goal is to get all of the processing for Spells into this Facet.
	 * Therefore, use of this global reset indicates incomplete implementation
	 * of Spells processing in this facet, and should be an indication that
	 * additional work is required in order to enhance the capability of this
	 * facet to appropriately update the Spells for a Player Character.
	 * 
	 * @param id
	 *            The CharID identifying the Player Character that requires a
	 *            reset on the list of spells granted to the Player Character.
	 */
public void process(CharID id) {
    Race race = raceFacet.get(id);
    removeAll(id, race);
    PlayerCharacter pc = trackingFacet.getPC(id);
    for (SpellLikeAbility sla : spellsFacet.getQualifiedSet(id)) {
        Formula times = sla.getCastTimes();
        int resolvedTimes = formulaResolvingFacet.resolve(id, times, sla.getQualifiedKey()).intValue();
        String book = sla.getSpellBook();
        final CharacterSpell cs = new CharacterSpell(race, sla.getSpell());
        cs.setFixedCasterLevel(sla.getFixedCasterLevel());
        SpellInfo si = cs.addInfo(0, resolvedTimes, book);
        si.setTimeUnit(sla.getCastTimeUnit());
        si.setFixedDC(sla.getDC());
        pc.addSpellBook(new SpellBook(book, SpellBook.TYPE_INNATE_SPELLS));
        add(id, cs, race);
    }
}
Also used : Formula(pcgen.base.formula.Formula) PlayerCharacter(pcgen.core.PlayerCharacter) SpellBook(pcgen.core.character.SpellBook) Race(pcgen.core.Race) SpellLikeAbility(pcgen.cdom.content.SpellLikeAbility) CharacterSpell(pcgen.core.character.CharacterSpell) SpellInfo(pcgen.core.character.SpellInfo)

Aggregations

Race (pcgen.core.Race)167 Test (org.junit.Test)78 PCTemplate (pcgen.core.PCTemplate)66 PlayerCharacter (pcgen.core.PlayerCharacter)28 CDOMObject (pcgen.cdom.base.CDOMObject)16 LoadContext (pcgen.rules.context.LoadContext)16 PCClass (pcgen.core.PCClass)15 ArrayList (java.util.ArrayList)10 SizeAdjustment (pcgen.core.SizeAdjustment)10 ParseResult (pcgen.rules.persistence.token.ParseResult)10 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)10 PCStat (pcgen.core.PCStat)9 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)8 Equipment (pcgen.core.Equipment)8 BonusObj (pcgen.core.bonus.BonusObj)7 Formula (pcgen.base.formula.Formula)6 WieldCategory (pcgen.core.character.WieldCategory)6 GameMode (pcgen.core.GameMode)5 Skill (pcgen.core.Skill)5 CompanionList (pcgen.cdom.list.CompanionList)4