Search in sources :

Example 21 with PlayerCharacter

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

the class AddedTemplateFacet method remove.

/**
	 * Returns a list of Templates to be removed from the Player Character as
	 * defined by TEMPLATE:REMOVE
	 * 
	 * @param id
	 *            The CharID identifying the PlayerCharacter being processed.
	 * @param po
	 *            The owning CDOMObject being processed to determine if there is
	 *            any content defined by TEMPLATE:REMOVE:
	 * 
	 * @return The Collection of objects defined in TEMPLATE:REMOVE: of the
	 *         given CDOMObject
	 */
public Collection<PCTemplate> remove(CharID id, CDOMObject po) {
    List<PCTemplate> list = new ArrayList<>();
    PlayerCharacter pc = trackingFacet.getPC(id);
    if (!pc.isImporting()) {
        for (CDOMReference<PCTemplate> ref : po.getSafeListFor(ListKey.REMOVE_TEMPLATES)) {
            for (PCTemplate pct : ref.getContainedObjects()) {
                list.add(pct);
            }
        }
    }
    return list;
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) ArrayList(java.util.ArrayList) PCTemplate(pcgen.core.PCTemplate)

Example 22 with PlayerCharacter

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

the class AbstractTokenModelTest method finishLoad.

protected void finishLoad() {
    context.commit();
    SourceFileLoader.processFactDefinitions(context);
    context.getReferenceContext().buildDeferredObjects();
    context.getReferenceContext().buildDerivedObjects();
    context.resolveDeferredTokens();
    assertTrue(context.getReferenceContext().resolveReferences(null));
    context.resolvePostValidationTokens();
    context.resolvePostDeferredTokens();
    context.loadCampaignFacets();
    pc = new PlayerCharacter();
    id = pc.getCharID();
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter)

Example 23 with PlayerCharacter

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

the class TempBonusHelper method removeBonusFromCharacter.

static void removeBonusFromCharacter(PlayerCharacter pc, Equipment aEq, CDOMObject aCreator) {
    for (Map.Entry<BonusObj, BonusManager.TempBonusInfo> me : pc.getTempBonusMap().entrySet()) {
        BonusObj aBonus = me.getKey();
        TempBonusInfo tbi = me.getValue();
        Object aC = tbi.source;
        if (aCreator != aC) {
            continue;
        }
        Object aT = tbi.target;
        if ((aT instanceof Equipment) && (aEq != null)) {
            if (aEq.equals(aT)) {
                pc.removeTempBonus(aBonus);
                pc.removeTempBonusItemList((Equipment) aT);
                ((Equipment) aT).removeTempBonus(aBonus);
                ((Equipment) aT).setAppliedName(EMPTY_STRING);
            }
        } else if ((aT instanceof PlayerCharacter) && (aEq == null)) {
            pc.removeTempBonus(aBonus);
        }
    }
}
Also used : TempBonusInfo(pcgen.core.BonusManager.TempBonusInfo) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) Map(java.util.Map)

Example 24 with PlayerCharacter

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

the class AbilitySelectionApplication method dataAdded.

@Override
public void dataAdded(DataFacetChangeEvent<CharID, CNAbilitySelection> dfce) {
    CharID id = dfce.getCharID();
    PlayerCharacter pc = pcFacet.getPC(id);
    CNAbilitySelection cnas = dfce.getCDOMObject();
    CNAbility cna = cnas.getCNAbility();
    Ability ability = cna.getAbility();
    String selection = cnas.getSelection();
    if (selection != null) {
        ChooseInformation<?> chooseInfo = ability.get(ObjectKey.CHOOSE_INFO);
        if (chooseInfo != null) {
            applySelection(pc, chooseInfo, cna, selection);
        }
    }
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) PlayerCharacter(pcgen.core.PlayerCharacter) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) CharID(pcgen.cdom.enumeration.CharID)

Example 25 with PlayerCharacter

use of pcgen.core.PlayerCharacter 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

PlayerCharacter (pcgen.core.PlayerCharacter)438 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)89 PCClass (pcgen.core.PCClass)61 LoadContext (pcgen.rules.context.LoadContext)58 Ability (pcgen.core.Ability)54 Equipment (pcgen.core.Equipment)41 PCTemplate (pcgen.core.PCTemplate)38 EquipSet (pcgen.core.character.EquipSet)32 BonusObj (pcgen.core.bonus.BonusObj)29 Race (pcgen.core.Race)28 CharID (pcgen.cdom.enumeration.CharID)25 ExportHandler (pcgen.io.ExportHandler)24 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)16 PreClassTester (plugin.pretokens.test.PreClassTester)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 Skill (pcgen.core.Skill)14 CNAbility (pcgen.cdom.content.CNAbility)13 URI (java.net.URI)11 URISyntaxException (java.net.URISyntaxException)11