use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class PCClass method isMonster.
/*
* FINALPCCLASSANDLEVEL This is required in PCClassLevel and should be present in
* PCClass for PCClassLevel creation (in the factory)
*/
/*
* FUTUREREFACTOR This would really be nice to have initilized when the LST files
* are read in, which is possible because the ClassTypes are all defined as part
* of the GameMode... however the problem is that the order of the ISMONSTER tag
* and the TYPE tags cannot be defined - .MODs and .COPYs make it impossible to
* guarantee an order. Therefore, this must wait for a two-pass design in the
* import system - thpr 10/4/06
*/
public boolean isMonster() {
Boolean mon = get(ObjectKey.IS_MONSTER);
if (mon != null) {
return mon.booleanValue();
}
ClassType aClassType = SettingsHandler.getGame().getClassTypeByName(getClassType());
if ((aClassType != null) && aClassType.isMonster()) {
return true;
} else {
for (Type type : getTrueTypeList(false)) {
aClassType = SettingsHandler.getGame().getClassTypeByName(type.toString());
if ((aClassType != null) && aClassType.isMonster()) {
return true;
}
}
}
return false;
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class AbilityCategory method populate.
@Override
public boolean populate(ReferenceManufacturer<Ability> parentCrm, ReferenceManufacturer<Ability> rm, UnconstructedValidator validator) {
if (parentCrm == null) {
return true;
}
Collection<Ability> allObjects = parentCrm.getAllObjects();
// Don't add things twice or we'll get dupe messages :)
Set<Ability> added = new WrappedMapSet<>(IdentityHashMap.class);
/*
* Pull in all the base objects... note this skips containsDirectly
* because items haven't been resolved
*/
for (final Ability ability : allObjects) {
boolean use = isAllAbilityTypes;
if (!use && (types != null)) {
for (Type type : types) {
if (ability.isType(type.toString())) {
use = true;
break;
}
}
}
if (use) {
added.add(ability);
rm.addObject(ability, ability.getKeyName());
}
}
boolean returnGood = true;
if (containedAbilities != null) {
for (CDOMSingleRef<Ability> ref : containedAbilities) {
boolean res = doResolve(parentCrm, ref.getLSTformat(false), ref, validator);
if (res) {
Ability ability = ref.get();
if (added.add(ability)) {
rm.addObject(ability, ability.getKeyName());
}
}
returnGood &= res;
}
}
return returnGood;
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class TypeActor method process.
/**
* @see pcgen.output.base.OutputActor#process(pcgen.cdom.enumeration.CharID,
* java.lang.Object)
*/
@Override
public TemplateModel process(CharID id, CDOMObject d) throws TemplateModelException {
final List<Type> types = d.getSafeListFor(ListKey.TYPE);
List<String> strings = new ArrayList<>(types.size());
for (Type type : types) {
strings.add(type.toString());
}
return new CollectionModel(id, strings);
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class SkillRankControl method getSkillRankBonusTo.
/**
* Get the bonus to a skill rank
*
* @param aPC
* @return bonus to skill rank
*/
public static double getSkillRankBonusTo(PlayerCharacter aPC, Skill sk) {
double bonus = aPC.getTotalBonusTo("SKILLRANK", sk.getKeyName());
for (Type singleType : sk.getTrueTypeList(false)) {
bonus += aPC.getTotalBonusTo("SKILLRANK", "TYPE." + singleType);
}
updateAdds(aPC, sk, bonus);
return bonus;
}
use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.
the class NaturalattacksLst method createNaturalWeapon.
/**
* Create the Natural weapon equipment item aTok = primary weapon
* name,weapon type,num attacks,damage for Example:
* Tentacle,Weapon.Natural.Melee.Slashing,*4,1d6
*
* @param aTok
* @param size
* @return natural weapon
*/
private Equipment createNaturalWeapon(LoadContext context, CDOMObject obj, String wpn) {
StringTokenizer commaTok = new StringTokenizer(wpn, Constants.COMMA);
int numTokens = commaTok.countTokens();
if (numTokens < 4) {
Logging.errorPrint("Invalid Build of " + "Natural Weapon in " + getTokenName() + ": " + wpn);
return null;
}
String attackName = commaTok.nextToken();
if (attackName.equalsIgnoreCase(Constants.LST_NONE)) {
Logging.errorPrint("Attempt to Build 'None' as a " + "Natural Weapon in " + getTokenName() + ": " + wpn);
return null;
}
attackName = attackName.intern();
Equipment anEquip = new Equipment();
anEquip.setName(attackName);
anEquip.put(ObjectKey.PARENT, obj);
/*
* This really can't be raw equipment... It really never needs to be
* referred to, but this means that duplicates are never being detected
* and resolved... this needs to have a KEY defined, to keep it
* unique... hopefully this is good enough :)
*
* CONSIDER This really isn't that great, because it's String dependent,
* and may not remove identical items... it certainly works, but is ugly
*/
// anEquip.setKeyName(obj.getClass().getSimpleName() + ","
// + obj.getKeyName() + "," + wpn);
/*
* Perhaps the construction above should be through context just to
* guarantee uniqueness of the key?? - that's too paranoid
*/
EquipmentHead equipHead = anEquip.getEquipmentHead(1);
String profType = commaTok.nextToken();
if (hasIllegalSeparator('.', profType)) {
return null;
}
StringTokenizer dotTok = new StringTokenizer(profType, Constants.DOT);
while (dotTok.hasMoreTokens()) {
Type type = Type.getConstant(dotTok.nextToken());
anEquip.addToListFor(ListKey.TYPE, type);
}
String numAttacks = commaTok.nextToken();
boolean attacksFixed = !numAttacks.isEmpty() && numAttacks.charAt(0) == '*';
if (attacksFixed) {
numAttacks = numAttacks.substring(1);
}
anEquip.put(ObjectKey.ATTACKS_PROGRESS, !attacksFixed);
try {
int bonusAttacks = Integer.parseInt(numAttacks) - 1;
final BonusObj aBonus = Bonus.newBonus(context, "WEAPON|ATTACKS|" + bonusAttacks);
if (aBonus == null) {
Logging.errorPrint(getTokenName() + " was given invalid number of attacks: " + bonusAttacks);
return null;
}
anEquip.addToListFor(ListKey.BONUS, aBonus);
} catch (NumberFormatException exc) {
Logging.errorPrint("Non-numeric value for number of attacks in " + getTokenName() + ": '" + numAttacks + '\'');
return null;
}
equipHead.put(StringKey.DAMAGE, commaTok.nextToken());
// sage_sam 02 Dec 2002 for Bug #586332
// allow hands to be required to equip natural weapons
int handsrequired = 0;
while (commaTok.hasMoreTokens()) {
final String hString = commaTok.nextToken();
if (hString.startsWith("SPROP=")) {
anEquip.addToListFor(ListKey.SPECIAL_PROPERTIES, SpecialProperty.createFromLst(hString.substring(6)));
} else {
try {
handsrequired = Integer.parseInt(hString);
} catch (NumberFormatException exc) {
Logging.errorPrint("Non-numeric value for hands required: '" + hString + '\'');
return null;
}
}
}
anEquip.put(IntegerKey.SLOTS, handsrequired);
anEquip.put(ObjectKey.WEIGHT, BigDecimal.ZERO);
WeaponProf cwp = context.getReferenceContext().silentlyGetConstructedCDOMObject(WEAPONPROF_CLASS, attackName);
if (cwp == null) {
cwp = context.getReferenceContext().constructNowIfNecessary(WEAPONPROF_CLASS, attackName);
cwp.addToListFor(ListKey.TYPE, Type.NATURAL);
}
CDOMSingleRef<WeaponProf> wp = context.getReferenceContext().getCDOMReference(WEAPONPROF_CLASS, attackName);
anEquip.put(ObjectKey.WEAPON_PROF, wp);
anEquip.addToListFor(ListKey.IMPLIED_WEAPONPROF, wp);
if (!ControlUtilities.hasControlToken(context, CControl.CRITRANGE)) {
equipHead.put(IntegerKey.CRIT_RANGE, 1);
}
if (!ControlUtilities.hasControlToken(context, CControl.CRITMULT)) {
equipHead.put(IntegerKey.CRIT_MULT, 2);
}
return anEquip;
}
Aggregations