use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class ACTokenTest method testMagic.
/**
* Test the character's AC calcs with armor with equipmods applied, including magic.
* @throws Exception
*/
public void testMagic() throws Exception {
PlayerCharacter character = getCharacter();
chainShirt.addEqModifiers("MWORKA.PLUS1A", true);
EquipSet es = new EquipSet("0.1.2", "Chain Shirt", chainShirt.getName(), chainShirt);
character.addEquipSet(es);
character.setCalcEquipmentList();
character.calcActiveBonuses();
assertEquals("Ability AC magic armor", "2", new ACToken().getToken("AC.Ability", getCharacter(), null));
assertEquals("Armor AC with magic armor", "5", new ACToken().getToken("AC.Armor", getCharacter(), null));
assertEquals("Total AC with magic armor", "17", new ACToken().getToken("AC.Total", getCharacter(), null));
}
use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class ACTokenTest method setUp.
/*
* @see TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
LoadContext context = Globals.getContext();
PlayerCharacter character = getCharacter();
setPCStat(character, dex, 14);
dex.removeListFor(ListKey.BONUS);
BonusObj aBonus = Bonus.newBonus(context, "COMBAT|AC|10|TYPE=Base");
if (aBonus != null) {
dex.addToListFor(ListKey.BONUS, aBonus);
}
// Ignoring max dex
aBonus = Bonus.newBonus(context, "COMBAT|AC|DEX|TYPE=Ability");
if (aBonus != null) {
dex.addToListFor(ListKey.BONUS, aBonus);
}
EquipSet def = new EquipSet("0.1", "Default");
character.addEquipSet(def);
character.setCalcEquipmentList();
character.calcActiveBonuses();
// Create non magic armor
chainShirt = new Equipment();
chainShirt.setName("Chain Shirt");
chainShirt.put(StringKey.KEY_NAME, "KEY_Chain_Shirt");
TestHelper.addType(chainShirt, "Armor.Light.Suit.Standard");
chainShirt.put(IntegerKey.AC_CHECK, -2);
aBonus = Bonus.newBonus(context, "COMBAT|AC|4|TYPE=Armor.REPLACE");
if (aBonus != null) {
chainShirt.addToListFor(ListKey.BONUS, aBonus);
}
// Create magic armor enhancement
masterwork = new EquipmentModifier();
masterwork.setName("Masterwork");
masterwork.put(StringKey.KEY_NAME, "MWORKA");
TestHelper.addType(masterwork, "Armor.Shield");
masterwork.addToListFor(ListKey.ITEM_TYPES, "Masterwork");
aBonus = Bonus.newBonus(context, "EQMARMOR|ACCHECK|1|TYPE=Enhancement");
if (aBonus != null) {
masterwork.addToListFor(ListKey.BONUS, aBonus);
}
context.getReferenceContext().importObject(masterwork);
plus1 = new EquipmentModifier();
plus1.setName("Plus 1 Enhancement");
plus1.put(StringKey.KEY_NAME, "PLUS1A");
TestHelper.addType(plus1, "Armor.Shield");
plus1.put(IntegerKey.PLUS, 1);
plus1.addToListFor(ListKey.ITEM_TYPES, "Enhancement");
plus1.addToListFor(ListKey.ITEM_TYPES, "Magic");
plus1.addToListFor(ListKey.ITEM_TYPES, "Plus1");
aBonus = Bonus.newBonus(context, "COMBAT|AC|1|TYPE=Armor.REPLACE");
if (aBonus != null) {
plus1.addToListFor(ListKey.BONUS, aBonus);
}
Globals.getContext().getReferenceContext().importObject(plus1);
// Load AC definitions - but only once
final GameMode gamemode = SettingsHandler.getGame();
if (!gamemode.isValidACType("Total")) {
gamemode.addACAdds("Total", Collections.singletonList(new ACControl("TOTAL")));
gamemode.addACAdds("Armor", Collections.singletonList(new ACControl("Armor")));
gamemode.addACAdds("Ability", Collections.singletonList(new ACControl("Ability")));
}
}
use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class BonusTest method testSkillPrereq.
/**
* Test the skill pre reqs
* @throws Exception
*/
public void testSkillPrereq() throws Exception {
LoadContext context = Globals.getContext();
final Skill rideSkill = new Skill();
rideSkill.setName("Ride");
rideSkill.put(StringKey.KEY_NAME, "Ride");
rideSkill.addToListFor(ListKey.TYPE, Type.getConstant("DEX"));
final Ability skillFocus = new Ability();
skillFocus.setName("Skill Focus");
skillFocus.put(StringKey.KEY_NAME, "Skill Focus");
final BonusObj saddleBonus = Bonus.newBonus(context, "SKILL|Ride|-5|!PREITEM:1,TYPE.Saddle");
rideSkill.addToListFor(ListKey.BONUS, saddleBonus);
final Equipment saddle = new Equipment();
saddle.setName("Saddle, Test");
saddle.addToListFor(ListKey.TYPE, Type.getConstant("SADDLE"));
final PlayerCharacter pc = getCharacter();
BonusActivation.activateBonuses(rideSkill, pc);
double iBonus = saddleBonus.resolve(pc, "").doubleValue();
assertEquals("Bonus value", -5.0, iBonus, 0.05);
assertTrue("No saddle, should have a penalty", pc.isApplied(saddleBonus));
pc.addEquipment(saddle);
final EquipSet eqSet = new EquipSet("Test", "Test", "", saddle);
pc.addEquipSet(eqSet);
pc.calcActiveBonuses();
BonusActivation.activateBonuses(rideSkill, pc);
assertFalse("Saddle, should not have a penalty", pc.isApplied(saddleBonus));
}
use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class BonusTest method testVarBonus.
/**
* Test the processing of bonusing variables using both
* abilities and equipment.
*/
public void testVarBonus() {
LoadContext context = Globals.getContext();
Ability dummyFeat = new Ability();
dummyFeat.setName("DummyFeat");
dummyFeat.setCDOMCategory(AbilityCategory.FEAT);
final PlayerCharacter pc = getCharacter();
// Create a variable
dummyFeat.put(VariableKey.getConstant("NegLevels"), FormulaFactory.ZERO);
// Create a bonus to it
Ability dummyFeat2 = new Ability();
dummyFeat2.setName("DummyFeat2");
dummyFeat2.setCDOMCategory(AbilityCategory.FEAT);
BonusObj aBonus = Bonus.newBonus(context, "VAR|NegLevels|7");
if (aBonus != null) {
dummyFeat2.addToListFor(ListKey.BONUS, aBonus);
}
Equipment equip = new Equipment();
equip.setName("DummyEquip");
aBonus = Bonus.newBonus(context, "VAR|NegLevels|2");
if (aBonus != null) {
equip.addToListFor(ListKey.BONUS, aBonus);
}
assertEquals("Variable value", 0.0, pc.getVariableValue("NegLevels", "").doubleValue(), 0.05);
addAbility(AbilityCategory.FEAT, dummyFeat);
assertEquals("Variable value", 0.0, pc.getVariableValue("NegLevels", "").doubleValue(), 0.05);
assertEquals("Variable value", -0.0, pc.getVariableValue("-1*NegLevels", "").doubleValue(), 0.05);
// Add a bonus to it
addAbility(AbilityCategory.FEAT, dummyFeat2);
assertEquals("Variable value", 7.0, pc.getVariableValue("NegLevels", "").doubleValue(), 0.05);
assertEquals("Variable value", -7.0, pc.getVariableValue("-1*NegLevels", "").doubleValue(), 0.05);
// Add the equipment that gives a bonus to NegLevels
EquipSet def = new EquipSet("0.1", "Default");
pc.addEquipSet(def);
final EquipSet eqSet = new EquipSet("0.1.1", "Equipped", "Test", equip);
pc.addEquipSet(eqSet);
pc.setCalcEquipmentList();
pc.calcActiveBonuses();
BonusActivation.activateBonuses(dummyFeat, pc);
assertEquals("Variable value", 9.0, pc.getVariableValue("NegLevels", "").doubleValue(), 0.05);
assertEquals("Variable value", -9.0, pc.getVariableValue("-1*NegLevels", "").doubleValue(), 0.05);
}
use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class EncounterPlugin method addEquipToTarget.
private EquipSet addEquipToTarget(PlayerCharacter aPC, EquipSet eSet, String locName, Equipment eqI, Float newQty) {
String location = getEquipLocation(aPC, eSet, locName, eqI);
// construct the new IdPath
// new id is one larger than any other id at this path level
String id = getNewIdPath(aPC, eSet);
Logging.debugPrint("--addEB-- IdPath:" + id + " Parent:" + eSet.getIdPath() + " Location:" + location + " eqName:" + eqI.getName() + " eSet:" + eSet.getName());
// now create a new EquipSet to add this Equipment item to
EquipSet newSet = new EquipSet(id, location, eqI.getName(), eqI);
// set the Quantity of equipment
eqI.setQty(newQty);
newSet.setQty(newQty);
aPC.addEquipSet(newSet);
aPC.setCurrentEquipSetName(eSet.getName());
return newSet;
}
Aggregations