use of pcgen.core.Equipment in project pcgen by PCGen.
the class AbstractGlobalTargetedSaveRestoreTest method testAutoArmorProf.
@Test
public void testAutoArmorProf() {
T target = create(getObjectClass(), "Target");
ArmorProf granted = create(ArmorProf.class, "Granted");
create(ArmorProf.class, "Ignored");
new plugin.lsttokens.auto.ArmorProfToken().parseToken(context, target, "Granted");
Object o = prepare(target);
finishLoad();
Equipment e = new Equipment();
e.addToListFor(ListKey.TYPE, Type.ARMOR);
e.put(ObjectKey.ARMOR_PROF, CDOMDirectSingleRef.getRef(granted));
assertFalse(pc.isProficientWith(e));
applyObject(target);
assertTrue(pc.isProficientWith(e));
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.isProficientWith(e));
assertTrue(reloadedPC.isProficientWith(e));
remove(o);
reloadedPC.setDirty(true);
assertFalse(reloadedPC.isProficientWith(e));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class AbstractGlobalTargetedSaveRestoreTest method testAutoShieldProfList.
@Test
public void testAutoShieldProfList() {
ShieldProf granted = create(ShieldProf.class, "Granted");
create(ShieldProf.class, "Ignored");
T target = create(getObjectClass(), "Target");
new plugin.lsttokens.auto.ShieldProfToken().parseToken(context, target, "%LIST");
new plugin.lsttokens.choose.ShieldProficiencyToken().parseToken(context, target, "Granted|Ignored");
additionalChooseSet(target);
Object o = prepare(target);
finishLoad();
Equipment e = new Equipment();
e.addToListFor(ListKey.TYPE, Type.SHIELD);
e.put(ObjectKey.SHIELD_PROF, CDOMDirectSingleRef.getRef(granted));
assertFalse(pc.isProficientWith(e));
applyObject(target);
assertTrue(pc.isProficientWith(e));
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.isProficientWith(e));
assertTrue(reloadedPC.isProficientWith(e));
remove(o);
reloadedPC.setDirty(true);
if (isSymmetric()) {
assertFalse(reloadedPC.isProficientWith(e));
}
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class AbstractGlobalTargetedSaveRestoreTest method testAutoShieldProf.
@Test
public void testAutoShieldProf() {
ShieldProf granted = create(ShieldProf.class, "Granted");
create(ShieldProf.class, "Ignored");
T target = create(getObjectClass(), "Target");
new plugin.lsttokens.auto.ShieldProfToken().parseToken(context, target, "Granted");
Object o = prepare(target);
finishLoad();
Equipment e = new Equipment();
e.addToListFor(ListKey.TYPE, Type.SHIELD);
e.put(ObjectKey.SHIELD_PROF, CDOMDirectSingleRef.getRef(granted));
assertFalse(pc.isProficientWith(e));
applyObject(target);
assertTrue(pc.isProficientWith(e));
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.isProficientWith(e));
assertTrue(reloadedPC.isProficientWith(e));
remove(o);
reloadedPC.setDirty(true);
assertFalse(reloadedPC.isProficientWith(e));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class AbstractGlobalTargetedSaveRestoreTest method testAutoArmorProfList.
@Test
public void testAutoArmorProfList() {
T target = create(getObjectClass(), "Target");
ArmorProf granted = create(ArmorProf.class, "Granted");
create(ArmorProf.class, "Ignored");
new plugin.lsttokens.auto.ArmorProfToken().parseToken(context, target, "%LIST");
new plugin.lsttokens.choose.ArmorProficiencyToken().parseToken(context, target, "Granted|Ignored");
additionalChooseSet(target);
Object o = prepare(target);
finishLoad();
Equipment e = new Equipment();
e.addToListFor(ListKey.TYPE, Type.ARMOR);
e.put(ObjectKey.ARMOR_PROF, CDOMDirectSingleRef.getRef(granted));
assertFalse(pc.isProficientWith(e));
applyObject(target);
assertTrue(pc.isProficientWith(e));
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.isProficientWith(e));
assertTrue(reloadedPC.isProficientWith(e));
remove(o);
reloadedPC.setDirty(true);
if (isSymmetric()) {
assertFalse(reloadedPC.isProficientWith(e));
}
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class CharacterFacadeImpl method addPurchasedEquipment.
/**
* @see pcgen.core.facade.CharacterFacade#addPurchasedEquipment(pcgen.core.facade.EquipmentFacade, int)
*/
@Override
public void addPurchasedEquipment(EquipmentFacade equipment, int quantity, boolean customize, boolean free) {
if (equipment == null || quantity <= 0) {
return;
}
// int nextOutputIndex = 1;
Equipment equipItemToAdjust = (Equipment) equipment;
if (customize) {
equipItemToAdjust = openCustomizer(equipItemToAdjust);
if (equipItemToAdjust == null) {
return;
}
} else {
if (equipItemToAdjust.getSafe(ObjectKey.MOD_CONTROL).getModifiersRequired()) {
if (!hasBeenAdjusted(equipItemToAdjust)) {
delegate.showErrorMessage(Constants.APPLICATION_NAME, LanguageBundle.getString(//$NON-NLS-1$
"in_igBuyMustCustomizeItemFirst"));
return;
}
}
}
Equipment updatedItem = theCharacter.getEquipmentNamed(equipItemToAdjust.getName());
if (!free && !canAfford(equipItemToAdjust, quantity, (GearBuySellScheme) gearBuySellSchemeRef.get())) {
delegate.showInfoMessage(Constants.APPLICATION_NAME, //$NON-NLS-1$
LanguageBundle.getFormattedString(//$NON-NLS-1$
"in_igBuyInsufficientFunds", //$NON-NLS-1$
quantity, equipItemToAdjust.getName()));
return;
}
if (updatedItem != null) {
// item is already in inventory; update it
final double prevQty = (updatedItem.qty() < 0) ? 0 : updatedItem.qty();
final double newQty = prevQty + quantity;
theCharacter.updateEquipmentQty(updatedItem, prevQty, newQty);
Float qty = new Float(newQty);
updatedItem.setQty(qty);
purchasedEquip.setQuantity(equipment, qty.intValue());
} else {
// item is not in inventory; add it
updatedItem = equipItemToAdjust.clone();
if (updatedItem != null) {
// Set the number carried and add it to the character
Float qty = new Float(quantity);
updatedItem.setQty(qty);
theCharacter.addEquipment(updatedItem);
}
purchasedEquip.addElement(updatedItem, quantity);
}
// Update the PC and equipment
if (!free) {
double itemCost = calcItemCost(updatedItem, quantity, (GearBuySellScheme) gearBuySellSchemeRef.get());
theCharacter.adjustGold(itemCost * -1);
}
theCharacter.setCalcEquipmentList();
theCharacter.setDirty(true);
updateWealthFields();
}
Aggregations