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;
}
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();
}
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);
}
}
}
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);
}
}
}
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);
}
}
Aggregations