Search in sources :

Example 61 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class AttackTokenTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    PlayerCharacter character = getCharacter();
    setPCStat(character, str, 14);
    str.removeListFor(ListKey.BONUS);
    LoadContext context = Globals.getContext();
    final BonusObj aBonus = Bonus.newBonus(context, "COMBAT|TOHIT.Melee|STR|TYPE=Ability");
    if (aBonus != null) {
        str.addToListFor(ListKey.BONUS, aBonus);
    }
    //		// Ignoring max dex
    //		stat.addBonusList("COMBAT|AC|DEX|TYPE=Ability");
    EquipSet def = new EquipSet("0.1", "Default");
    character.addEquipSet(def);
    character.setCalcEquipmentList();
    character.calcActiveBonuses();
    myClass.setName("My Class");
    myClass.put(FormulaKey.START_SKILL_POINTS, FormulaFactory.getFormulaFor(3));
    final BonusObj babClassBonus = Bonus.newBonus(context, "COMBAT|BASEAB|CL+5");
    myClass.getOriginalClassLevel(1).addToListFor(ListKey.BONUS, babClassBonus);
    Globals.getContext().getReferenceContext().importObject(myClass);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) EquipSet(pcgen.core.character.EquipSet) LoadContext(pcgen.rules.context.LoadContext)

Example 62 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class PlayerCharacter method setCalcEquipSetId.

/**
	 * Set the current EquipSet that is used to Bonus/Equip calculations.
	 *
	 * @param eqSetId The equipSet to be used for Bonus Calculations and output
	 */
public void setCalcEquipSetId(final String eqSetId) {
    if (calcEquipSetId != eqSetId) {
        calcEquipSetId = eqSetId;
        EquipSet equipSet = getEquipSetByIdPath(eqSetId);
        if (equipSet != null) {
            setCurrentEquipSetName(equipSet.getName());
        }
        setDirty(true);
    }
}
Also used : EquipSet(pcgen.core.character.EquipSet)

Example 63 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testGetRequiredLoc.

/**
	 * Verify the getRequiredLoc method. 
	 */
public void testGetRequiredLoc() {
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, getCharacter(), es, dataset, equipmentList, todoManager, null);
    assertNull("Null equipment should give null location", esfi.getNaturalWeaponLoc(null));
    Equipment eq = new Equipment();
    eq.addType(Type.MELEE);
    eq.addType(Type.WEAPON);
    EquipNode requiredLoc = esfi.getNaturalWeaponLoc(eq);
    assertNull("Melee weapon should not have required location.", requiredLoc);
    eq.addType(Type.NATURAL);
    eq.put(IntegerKey.SLOTS, 0);
    eq.setName("Sting");
    requiredLoc = esfi.getNaturalWeaponLoc(eq);
    assertNotNull("Natural weapon should have required location.", requiredLoc);
    assertEquals("Incorrect name for secondary natural weapon", "Natural-Secondary", requiredLoc.toString());
    assertEquals("Natural weapom should replace hands.", "HANDS", requiredLoc.getBodyStructure().toString());
    eq.setModifiedName("Natural/Primary");
    requiredLoc = esfi.getNaturalWeaponLoc(eq);
    assertNotNull("Natural weapon should have required location.", requiredLoc);
    assertEquals("Incorrect name for primary natural weapon", "Natural-Primary", requiredLoc.toString());
    assertEquals("Natural weapom should replace hands.", "HANDS", requiredLoc.getBodyStructure().toString());
}
Also used : Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 64 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testAddRemove.

/**
	 * Check that EquipmentSetFacadeImpl can manage addition and removal of equipment.  
	 */
public void testAddRemove() {
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    CharacterFacadeImpl charFacade = new CharacterFacadeImpl(getCharacter(), uiDelegate, dataset);
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, getCharacter(), es, dataset, equipmentList, todoManager, charFacade);
    EquipNode root = esfi.getNodes().getElementAt(0);
    Equipment item = new Equipment();
    item.setName("Dart");
    assertEquals("Initial num carried", 0, item.getCarried(), 0.01);
    assertEquals("Initial num equipped", 0, item.getNumberEquipped());
    assertEquals("Initial node list size", NUM_BASE_NODES, esfi.getNodes().getSize());
    Equipment addedEquip = (Equipment) esfi.addEquipment(root, item, 2);
    assertEquals("First add num carried", 2, addedEquip.getCarried(), 0.01);
    assertEquals("First add num equipped", 2, addedEquip.getNumberEquipped());
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertEquals("First add node list size", NUM_BASE_NODES + 1, esfi.getNodes().getSize());
    assertEquals("generated equip set id", "0.1.01", ((EquipNodeImpl) esfi.getNodes().getElementAt(NUM_BASE_NODES)).getIdPath());
    Equipment secondEquip = (Equipment) esfi.addEquipment(root, item, 1);
    assertEquals("Second add num carried", 3, secondEquip.getCarried(), 0.01);
    assertEquals("Second add num equipped", 3, secondEquip.getNumberEquipped());
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertTrue("Same equipment item should have been used", addedEquip == secondEquip);
    assertEquals("First add node list size", NUM_BASE_NODES + 1, esfi.getNodes().getSize());
    EquipNode target = esfi.getNodes().getElementAt(NUM_BASE_NODES);
    Equipment removedEquip = (Equipment) esfi.removeEquipment(target, 2);
    assertEquals("First add num carried", 1, removedEquip.getCarried(), 0.01);
    assertEquals("First add num equipped", 1, removedEquip.getNumberEquipped());
    assertTrue("Same equipment item should have been used", addedEquip == removedEquip);
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertEquals("First add node list size", NUM_BASE_NODES + 1, esfi.getNodes().getSize());
    esfi.removeEquipment(target, 1);
    assertEquals("First add num carried", 0, addedEquip.getCarried(), 0.01);
    assertEquals("First add num equipped", 0, addedEquip.getNumberEquipped());
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertEquals("First add node list size", NUM_BASE_NODES, esfi.getNodes().getSize());
}
Also used : Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 65 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method addEquipToEquipSet.

/**
	 * Add the equipment item to the equipset.
	 * 
	 * @param pc The character owning the set
	 * @param es The set to add the item to
	 * @param item The item of equipment
	 * @param qty The number to be placed in the location.
	 * @return The new EquipSet object for the item.
	 */
private EquipSet addEquipToEquipSet(PlayerCharacter pc, EquipSet es, Equipment item, float qty, String locName) {
    String id = EquipmentSetFacadeImpl.getNewIdPath(pc.getDisplay(), es);
    EquipSet newSet = new EquipSet(id, locName, item.getName(), item);
    item.setQty(qty);
    newSet.setQty(1.0f);
    pc.addEquipSet(newSet);
    return newSet;
}
Also used : EquipSet(pcgen.core.character.EquipSet)

Aggregations

EquipSet (pcgen.core.character.EquipSet)79 PlayerCharacter (pcgen.core.PlayerCharacter)32 Equipment (pcgen.core.Equipment)22 ArrayList (java.util.ArrayList)12 BonusObj (pcgen.core.bonus.BonusObj)11 HashMap (java.util.HashMap)9 LoadContext (pcgen.rules.context.LoadContext)8 EquipNode (pcgen.facade.core.EquipmentSetFacade.EquipNode)7 DecimalFormat (java.text.DecimalFormat)4 NumberFormat (java.text.NumberFormat)4 List (java.util.List)4 Map (java.util.Map)4 EquipmentList (pcgen.core.EquipmentList)4 PCTemplate (pcgen.core.PCTemplate)4 EquipSlot (pcgen.core.character.EquipSlot)4 LinkedHashMap (java.util.LinkedHashMap)3 Ability (pcgen.core.Ability)3 EquipmentModifier (pcgen.core.EquipmentModifier)3 StringTokenizer (java.util.StringTokenizer)2 CNAbility (pcgen.cdom.content.CNAbility)2