use of pcgen.core.EquipmentModifier in project pcgen by PCGen.
the class CharacterFacadeImpl method hasBeenAdjusted.
private boolean hasBeenAdjusted(Equipment equipItemToAdjust) {
Set<EquipmentModifier> allEqMods = new HashSet<>(equipItemToAdjust.getEqModifierList(true));
allEqMods.addAll(equipItemToAdjust.getEqModifierList(false));
for (EquipmentModifier eqMod : allEqMods) {
if (!eqMod.isType(Constants.EQMOD_TYPE_BASEMATERIAL)) {
return true;
}
}
return false;
}
use of pcgen.core.EquipmentModifier in project pcgen by PCGen.
the class CharacterFacadeImpl method isQualifiedFor.
@Override
public boolean isQualifiedFor(EquipmentFacade equipFacade, EquipModFacade eqModFacade) {
if (!(equipFacade instanceof Equipment) || !(eqModFacade instanceof EquipmentModifier)) {
return false;
}
Equipment equip = (Equipment) equipFacade;
EquipmentModifier eqMod = (EquipmentModifier) eqModFacade;
//TODO: Handle second head
return equip.canAddModifier(theCharacter, eqMod, true);
}
use of pcgen.core.EquipmentModifier in project pcgen by PCGen.
the class BonusLst method unparse.
@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
if (obj instanceof EquipmentModifier) {
// EquipmentModifier bonuses are handled by plugin.lsttokens.equipmentmodifier.BonusToken
return null;
}
Changes<BonusObj> changes = context.getObjectContext().getListChanges(obj, ListKey.BONUS);
if (changes == null || changes.isEmpty()) {
// Empty indicates no token present
return null;
}
// CONSIDER need to deal with removed...
Collection<BonusObj> added = changes.getAdded();
String tokenName = getTokenName();
Set<String> bonusSet = new TreeSet<>();
for (BonusObj bonus : added) {
if (tokenName.equals(bonus.getTokenSource())) {
String bonusString = bonus.getLSTformat();
bonusSet.add(bonusString);
}
}
if (bonusSet.isEmpty()) {
// This is okay - just no BONUSes from this token
return null;
}
return bonusSet.toArray(new String[bonusSet.size()]);
}
use of pcgen.core.EquipmentModifier in project pcgen by PCGen.
the class ChooseLst method parseNonEmptyToken.
@Override
protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
if (obj instanceof Ungranted) {
return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName(), context);
}
if (obj instanceof NonInteractive) {
return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Non-Interactive object type: " + obj.getClass().getSimpleName(), context);
}
String key;
String val;
int pipeLoc = value.indexOf(Constants.PIPE);
if (value.startsWith("FEAT=")) {
key = "FEATEQ";
val = value.substring(5);
} else if (value.startsWith("LANGAUTO:")) {
key = "LANGAUTO";
val = value.substring(9);
} else if (pipeLoc == -1) {
key = value;
val = null;
} else {
key = value.substring(0, pipeLoc);
val = value.substring(pipeLoc + 1);
}
if (!((obj instanceof Ability) || (obj instanceof Domain) || (obj instanceof Race) || (obj instanceof PCTemplate) || (obj instanceof Skill) || (obj instanceof EquipmentModifier))) {
//Allow TEMPBONUS related choose
if (!"NUMBER".equals(key)) {
return new ParseResult.Fail(getTokenName() + " is not supported for " + obj.getClass().getSimpleName(), context);
}
}
if (key.startsWith("NUMCHOICES=")) {
String maxCount = key.substring(11);
if (maxCount == null || maxCount.isEmpty()) {
return new ParseResult.Fail("NUMCHOICES in CHOOSE must be a formula: " + value, context);
}
Formula f = FormulaFactory.getFormulaFor(maxCount);
if (!f.isValid()) {
return new ParseResult.Fail("Number of Choices in " + getTokenName() + " was not valid: " + f.toString(), context);
}
context.getObjectContext().put(obj, FormulaKey.NUMCHOICES, f);
pipeLoc = val.indexOf(Constants.PIPE);
if (pipeLoc == -1) {
key = val;
val = null;
} else {
key = val.substring(0, pipeLoc);
val = val.substring(pipeLoc + 1);
}
}
return context.processSubToken(obj, getTokenName(), key, val);
}
use of pcgen.core.EquipmentModifier in project pcgen by PCGen.
the class ActiveEqModFacetTest method getSourceObject.
@Override
protected Equipment getSourceObject() {
Equipment e = new Equipment();
e.setName("e" + n++);
EquipmentModifier mod = getObject();
e.addToEqModifierList(mod, true);
return e;
}
Aggregations