use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class Equipment method getTypesForDisplay.
@Override
public List<String> getTypesForDisplay() {
List<Type> trueTypeList = getTrueTypeList(true);
List<String> result = new ArrayList<>(trueTypeList.size());
for (Type type : trueTypeList) {
result.add(type.toString());
}
return result;
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class TypeTokenTest method setUp.
@Override
public void setUp() throws PersistenceLayerException, URISyntaxException {
super.setUp();
TokenRegistration.register(TYPE_TOKEN);
Type med = Type.getConstant("Medium");
WeaponProf pls = primaryContext.getReferenceContext().constructCDOMObject(WeaponProf.class, "Longsword");
pls.addToListFor(ListKey.TYPE, med);
WeaponProf sls = secondaryContext.getReferenceContext().constructCDOMObject(WeaponProf.class, "Longsword");
sls.addToListFor(ListKey.TYPE, med);
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class ItemToken method unparse.
@Override
public String[] unparse(LoadContext context, Spell spell) {
Changes<Type> changes = context.getObjectContext().getListChanges(spell, ListKey.ITEM);
Changes<Type> proChanges = context.getObjectContext().getListChanges(spell, ListKey.PROHIBITED_ITEM);
Collection<Type> changeAdded = changes.getAdded();
Collection<Type> proAdded = proChanges.getAdded();
StringBuilder sb = new StringBuilder();
boolean needComma = false;
if (changeAdded != null) {
for (Type t : changeAdded) {
if (needComma) {
sb.append(Constants.COMMA);
}
sb.append(t.toString());
needComma = true;
}
}
if (proAdded != null) {
for (Type t : proAdded) {
if (needComma) {
sb.append(Constants.COMMA);
}
sb.append('[').append(t.toString()).append(']');
needComma = true;
}
}
if (sb.length() == 0) {
return null;
}
return new String[] { sb.toString() };
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class BonusSkillRankChangeFacet method reset.
/**
* Performs a check against the previously known values of the bonuses for
* the Player Character identified by the given CharID. If any Bonus values
* have changed, then this will throw a SkillRankChangeEvent to any
* SkillRankChangeListener objects which have subscribed to receive updates
* when values change.
*
* @param id
* The CharID identifying the Player Character for which the
* check for changes in bonus skillrank values should be
* performed
*/
public void reset(CharID id) {
Map<Skill, Double> map = getConstructingInfo(id);
for (Skill s : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(Skill.class)) {
double newValue = bonusCheckingFacet.getBonus(id, "SKILLRANK", s.getKeyName());
for (Type singleType : s.getTrueTypeList(false)) {
newValue += bonusCheckingFacet.getBonus(id, "SKILLRANK", "TYPE." + singleType);
}
Double oldValue = map.get(s);
if ((oldValue == null) || (newValue != oldValue.doubleValue())) {
map.put(s, newValue);
support.fireSkillRankChange(id, s, oldValue, newValue);
}
}
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class PlayerCharacter method getDC.
public int getDC(final Spell sp, PCClass aClass, int spellLevel, int metaDC, CDOMObject ow) {
String bonDomain = "";
if (ow instanceof Domain) {
bonDomain = "DOMAIN." + ow.getKeyName();
ClassSource source = getDomainSource((Domain) ow);
if (source != null) {
aClass = getClassKeyed(source.getPcclass().getKeyName());
}
}
boolean useStatFromSpell = false;
String bonClass = "";
String spellType = "";
String classKey = "";
if ((aClass != null) || (ow instanceof PCClass)) {
if ((aClass == null) || (ow instanceof PCClass)) {
aClass = (PCClass) ow;
}
bonClass = "CLASS." + aClass.getKeyName();
classKey = "CLASS:" + aClass.getKeyName();
spellType = aClass.getSpellType();
useStatFromSpell = aClass.getSafe(ObjectKey.USE_SPELL_SPELL_STAT);
}
if (!(ow instanceof PCClass) && !(ow instanceof Domain)) {
// get BASESPELLSTAT from spell itself
useStatFromSpell = true;
}
// set the spell Level used in aPC.getVariableValue()
// Explicitly should *not* set the dirty flag to true.
spellLevelTemp = spellLevel;
// must be done after spellLevel is set above
int dc = getVariableValue(SettingsHandler.getGame().getSpellBaseDC(), classKey).intValue() + metaDC;
dc += (int) getTotalBonusTo("DC", "ALLSPELLS");
if (useStatFromSpell) {
// get the BASESPELLSTAT from the spell itself
CDOMSingleRef<PCStat> stat = sp.get(ObjectKey.SPELL_STAT);
if (stat != null) {
dc += this.getStatModFor(stat.get());
}
}
if (!sp.getKeyName().isEmpty()) {
dc += (int) getTotalBonusTo("DC", "SPELL." + sp.getKeyName());
}
// DOMAIN.name
if (!bonDomain.isEmpty()) {
dc += (int) getTotalBonusTo("DC", bonDomain);
}
// CLASS.name
if (!bonClass.isEmpty()) {
dc += (int) getTotalBonusTo("DC", bonClass);
}
dc += (int) getTotalBonusTo("DC", "TYPE." + spellType);
if (spellType.equals("ALL")) {
for (Type aType : sp.getTrueTypeList(false)) {
dc += (int) getTotalBonusTo("DC", "TYPE." + aType);
}
}
for (SpellSchool aType : sp.getSafeListFor(ListKey.SPELL_SCHOOL)) {
dc += (int) getTotalBonusTo("DC", "SCHOOL." + aType.toString());
}
for (String aType : sp.getSafeListFor(ListKey.SPELL_SUBSCHOOL)) {
dc += (int) getTotalBonusTo("DC", "SUBSCHOOL." + aType);
}
for (String aType : sp.getSafeListFor(ListKey.SPELL_DESCRIPTOR)) {
dc += (int) getTotalBonusTo("DC", "DESCRIPTOR." + aType);
}
// Explicitly should *not* set the dirty flag to true.
spellLevelTemp = 0;
return dc;
}
Aggregations