Search in sources :

Example 66 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class SkillSitTokenTest method setUp.

/**
	 * @see pcgen.AbstractCharacterTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    PlayerCharacter character = getCharacter();
    final LevelInfo levelInfo = new LevelInfo();
    levelInfo.setLevelString("LEVEL");
    levelInfo.setMaxClassSkillString("LEVEL+3");
    levelInfo.setMaxCrossClassSkillString("(LEVEL+3)/2");
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.addLevelInfo("Default", levelInfo);
    //Stats
    setPCStat(character, dex, 16);
    setPCStat(character, intel, 17);
    LoadContext context = Globals.getContext();
    BonusObj aBonus = Bonus.newBonus(context, "MODSKILLPOINTS|NUMBER|INT");
    if (aBonus != null) {
        intel.addToListFor(ListKey.BONUS, aBonus);
    }
    // Race
    Race testRace = new Race();
    testRace.setName("TestRace");
    character.setRace(testRace);
    // Class
    PCClass myClass = new PCClass();
    myClass.setName("My Class");
    myClass.put(FormulaKey.START_SKILL_POINTS, FormulaFactory.getFormulaFor(3));
    character.incrementClassLevel(5, myClass, true);
    //Skills
    knowledge = new Skill[2];
    knowledge[0] = new Skill();
    context.unconditionallyProcess(knowledge[0], "CLASSES", "MyClass");
    knowledge[0].setName("KNOWLEDGE (ARCANA)");
    TestHelper.addType(knowledge[0], "KNOWLEDGE.INT");
    CDOMDirectSingleRef<PCStat> intelRef = CDOMDirectSingleRef.getRef(intel);
    knowledge[0].put(ObjectKey.KEY_STAT, intelRef);
    context.getReferenceContext().importObject(knowledge[0]);
    aBonus = Bonus.newBonus(context, "SITUATION|Tumble=On Hot Concrete|2");
    if (aBonus != null) {
        knowledge[0].addToListFor(ListKey.BONUS, aBonus);
    }
    SkillRankControl.modRanks(8.0, myClass, true, character, knowledge[0]);
    knowledge[1] = new Skill();
    context.unconditionallyProcess(knowledge[1], "CLASSES", "MyClass");
    knowledge[1].setName("KNOWLEDGE (RELIGION)");
    TestHelper.addType(knowledge[1], "KNOWLEDGE.INT");
    knowledge[1].put(ObjectKey.KEY_STAT, intelRef);
    aBonus = Bonus.newBonus(context, "SITUATION|Balance=On a Ball|2");
    if (aBonus != null) {
        knowledge[1].addToListFor(ListKey.BONUS, aBonus);
    }
    context.getReferenceContext().importObject(knowledge[1]);
    SkillRankControl.modRanks(5.0, myClass, true, character, knowledge[1]);
    tumble = new Skill();
    context.unconditionallyProcess(tumble, "CLASSES", "MyClass");
    tumble.setName("Tumble");
    tumble.addToListFor(ListKey.TYPE, Type.getConstant("DEX"));
    tumble.addToListFor(ListKey.SITUATION, "On Hot Concrete");
    tumble.addToListFor(ListKey.SITUATION, "Down a Mountain");
    CDOMDirectSingleRef<PCStat> dexRef = CDOMDirectSingleRef.getRef(dex);
    tumble.put(ObjectKey.KEY_STAT, dexRef);
    context.getReferenceContext().importObject(tumble);
    SkillRankControl.modRanks(7.0, myClass, true, character, tumble);
    balance = new Skill();
    context.unconditionallyProcess(balance, "CLASSES", "MyClass");
    balance.setName("Balance");
    balance.addToListFor(ListKey.TYPE, Type.getConstant("DEX"));
    balance.addToListFor(ListKey.SITUATION, "On a Ball");
    balance.put(ObjectKey.KEY_STAT, dexRef);
    aBonus = Bonus.newBonus(context, "SKILL|Balance|2|PRESKILL:1,Tumble=5|TYPE=Synergy.STACK");
    if (aBonus != null) {
        balance.addToListFor(ListKey.BONUS, aBonus);
    }
    context.getReferenceContext().importObject(balance);
    SkillRankControl.modRanks(4.0, myClass, true, character, balance);
    context.getReferenceContext().buildDerivedObjects();
    context.getReferenceContext().resolveReferences(null);
    character.calcActiveBonuses();
}
Also used : GameMode(pcgen.core.GameMode) Skill(pcgen.core.Skill) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) LevelInfo(pcgen.core.LevelInfo) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass) PCStat(pcgen.core.PCStat)

Example 67 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class AddClassSkillsTest method testGetChoicesListWithClassSkill.

/**
	 * Test method for 'pcgen.core.levelability.LevelAbilityClassSkills.getChoicesList(String, PlayerCharacter)'
	 */
@Test
public void testGetChoicesListWithClassSkill() {
    CampaignSourceEntry source;
    try {
        source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    } catch (URISyntaxException e) {
        throw new UnreachableError(e);
    }
    String classPCCText = "CLASS:Cleric	HD:8		TYPE:Base.PC	ABB:Clr\n" + "CLASS:Cleric	STARTSKILLPTS:2	CSKILL:KEY_Knowledge (Dungeoneering)";
    PCClass po;
    try {
        po = parsePCClassText(classPCCText, source);
    } catch (PersistenceLayerException e) {
        throw new UnreachableError(e);
    }
    getCharacter().incrementClassLevel(1, po, false);
    PCTemplate pct = new PCTemplate();
    Skill bluff = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class, "KEY_Bluff");
    pct.addToListFor(ListKey.CSKILL, CDOMDirectSingleRef.getRef(bluff));
    getCharacter().addTemplate(pct);
    Globals.getContext().unconditionallyProcess(po, "ADD", "CLASSSKILLS|2|KEY_Bluff,KEY_Listen,KEY_Knowledge (Arcana)");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    List<PersistentTransitionChoice<?>> choiceList = po.getListFor(ListKey.ADD);
    assertEquals(1, choiceList.size());
    TransitionChoice<?> choice = choiceList.get(0);
    Collection<?> choiceSet = choice.getChoices().getSet(getCharacter());
    assertEquals(3, choiceSet.size());
    Set<Object> limitedSet = new HashSet<>();
    ClassSkillChoiceActor csca = new ClassSkillChoiceActor(po, 0);
    for (Object sc : choiceSet) {
        if (csca.allow((Skill) sc, getCharacter(), true)) {
            limitedSet.add(sc);
        }
    }
    assertEquals(2, limitedSet.size());
    assertEquals(2, choice.getCount().resolve(getCharacter(), ""));
    List<String> choiceStrings = new ArrayList<>();
    for (Object o : limitedSet) {
        choiceStrings.add(o.toString());
    }
    assertTrue(choiceStrings.contains("Listen"));
    assertTrue(choiceStrings.contains("Knowledge (Arcana)"));
}
Also used : PersistentTransitionChoice(pcgen.cdom.base.PersistentTransitionChoice) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) PCClass(pcgen.core.PCClass) URI(java.net.URI) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Skill(pcgen.core.Skill) Campaign(pcgen.core.Campaign) ClassSkillChoiceActor(pcgen.cdom.helper.ClassSkillChoiceActor) PCTemplate(pcgen.core.PCTemplate) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 68 with Skill

use of pcgen.core.Skill 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));
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) Skill(pcgen.core.Skill) PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) LoadContext(pcgen.rules.context.LoadContext)

Example 69 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class TestHelper method makeSkill.

/**
	 * Set the important info about a Skill
	 * @param name The skill name
	 * @param type The type info ("." separated)
	 * @param stat The key stat
	 * @param untrained Can this be used untrained
	 * @param armorCheck should an armor check penalty be applied
	 */
public static Skill makeSkill(final String name, final String type, final PCStat stat, final boolean untrained, final SkillArmorCheck armorCheck) {
    final Skill aSkill = new Skill();
    aSkill.setName(name);
    aSkill.put(StringKey.KEY_NAME, ("KEY_" + name));
    addType(aSkill, type);
    CDOMDirectSingleRef<PCStat> statRef = CDOMDirectSingleRef.getRef(stat);
    aSkill.put(ObjectKey.KEY_STAT, statRef);
    aSkill.put(ObjectKey.USE_UNTRAINED, untrained);
    aSkill.put(ObjectKey.ARMOR_CHECK, armorCheck);
    Globals.getContext().getReferenceContext().importObject(aSkill);
    return aSkill;
}
Also used : Skill(pcgen.core.Skill) PCStat(pcgen.core.PCStat)

Example 70 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class GlobalAddedSkillCostFacetTest method testAddNullSource.

@Test
public void testAddNullSource() {
    Skill t1 = getObject();
    assertFalse(getFacet().contains(id, SkillCost.CLASS, t1));
    getFacet().add(id, SkillCost.CLASS, t1, null);
    assertTrue(getFacet().contains(id, SkillCost.CLASS, t1));
    assertFalse(getFacet().contains(id, SkillCost.CROSS_CLASS, t1));
    //No cross pollution
    assertFalse(getFacet().contains(altid, SkillCost.CLASS, t1));
}
Also used : Skill(pcgen.core.Skill) Test(org.junit.Test)

Aggregations

Skill (pcgen.core.Skill)165 Test (org.junit.Test)60 PCClass (pcgen.core.PCClass)55 ArrayList (java.util.ArrayList)29 CDOMReference (pcgen.cdom.base.CDOMReference)24 CharID (pcgen.cdom.enumeration.CharID)23 SkillCost (pcgen.cdom.enumeration.SkillCost)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 PlayerCharacter (pcgen.core.PlayerCharacter)14 ChoiceSet (pcgen.cdom.base.ChoiceSet)13 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)13 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)13 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)13 StringTokenizer (java.util.StringTokenizer)10 ObjectMatchingReference (pcgen.cdom.reference.ObjectMatchingReference)10 Ability (pcgen.core.Ability)10 LoadContext (pcgen.rules.context.LoadContext)9 ClassSkillList (pcgen.cdom.list.ClassSkillList)8 HashSet (java.util.HashSet)7 CNAbility (pcgen.cdom.content.CNAbility)7