Search in sources :

Example 16 with Type

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;
}
Also used : ChangeArmorType(pcgen.cdom.processor.ChangeArmorType) MessageType(pcgen.core.utils.MessageType) Type(pcgen.cdom.enumeration.Type) ArrayList(java.util.ArrayList)

Example 17 with Type

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);
}
Also used : Type(pcgen.cdom.enumeration.Type) WeaponProf(pcgen.core.WeaponProf)

Example 18 with Type

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() };
}
Also used : Type(pcgen.cdom.enumeration.Type)

Example 19 with Type

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);
        }
    }
}
Also used : Skill(pcgen.core.Skill) Type(pcgen.cdom.enumeration.Type)

Example 20 with Type

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;
}
Also used : SpellSchool(pcgen.cdom.identifier.SpellSchool) MessageType(pcgen.core.utils.MessageType) AttackType(pcgen.util.enumeration.AttackType) Type(pcgen.cdom.enumeration.Type) ClassSource(pcgen.cdom.helper.ClassSource)

Aggregations

Type (pcgen.cdom.enumeration.Type)27 ArrayList (java.util.ArrayList)6 MessageType (pcgen.core.utils.MessageType)6 EquipmentHead (pcgen.cdom.inst.EquipmentHead)4 Skill (pcgen.core.Skill)4 StringTokenizer (java.util.StringTokenizer)3 PCStat (pcgen.core.PCStat)3 BonusObj (pcgen.core.bonus.BonusObj)3 AttackType (pcgen.util.enumeration.AttackType)3 HashMap (java.util.HashMap)2 ClassSource (pcgen.cdom.helper.ClassSource)2 SpellSchool (pcgen.cdom.identifier.SpellSchool)2 ChangeArmorType (pcgen.cdom.processor.ChangeArmorType)2 ClassType (pcgen.core.ClassType)2 Equipment (pcgen.core.Equipment)2 WeaponProf (pcgen.core.WeaponProf)2 CharacterDisplay (pcgen.core.display.CharacterDisplay)2 ParseResult (pcgen.rules.persistence.token.ParseResult)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1