Search in sources :

Example 76 with Race

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

the class StatIntegrationTest method testUnlockOverrideLockSimple.

@Test
public void testUnlockOverrideLockSimple() {
    Race r1 = new Race();
    causeLock(r1, stat2, 14);
    causeUnlock(r1, stat2);
    rfacet.set(id, r1);
    testNonAbilityUnset();
    testLockUnsetConditional();
}
Also used : Race(pcgen.core.Race) Test(org.junit.Test)

Example 77 with Race

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

the class StatIntegrationTest method testLockInRace.

@Test
public void testLockInRace() {
    Race r = new Race();
    causeLock(r, stat1, 14);
    rfacet.set(id, r);
    testNonAbilityUnset();
    assertEquals(14, lockFacet.getLockedStat(id, stat1));
    assertNull(lockFacet.getLockedStat(id, stat2));
    // Make sure cleans up when race changed
    rfacet.set(id, new Race());
    testNonAbilityUnset();
    testLockUnset();
}
Also used : Race(pcgen.core.Race) Test(org.junit.Test)

Example 78 with Race

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

the class RaceTargetSaveRestoreTest method testRaceFavClass.

@Test
public void testRaceFavClass() {
    PCClass monclass = create(PCClass.class, "MonClass");
    new TypeLst().parseToken(context, monclass, "Monster");
    Race monster = create(Race.class, "Monster");
    Race other = create(Race.class, "Other");
    create(PCClass.class, "MyClass");
    new FavclassToken().parseToken(context, monster, "%LIST");
    new ClassToken().parseToken(context, monster, "MonClass|MyClass");
    finishLoad();
    pc.setRace(monster);
    runRoundRobin(getPreEqualityCleanup());
    assertTrue(pc.getDisplay().getFavoredClasses().contains(monclass));
    assertTrue(reloadedPC.getDisplay().getFavoredClasses().contains(monclass));
    reloadedPC.setRace(other);
    reloadedPC.setDirty(true);
    assertFalse(reloadedPC.getDisplay().getFavoredClasses().contains(monclass));
}
Also used : ClassToken(plugin.lsttokens.choose.ClassToken) Race(pcgen.core.Race) PCClass(pcgen.core.PCClass) TypeLst(plugin.lsttokens.TypeLst) FavclassToken(plugin.lsttokens.race.FavclassToken) Test(org.junit.Test) AbstractGlobalTargetedSaveRestoreTest(pcgen.io.testsupport.AbstractGlobalTargetedSaveRestoreTest)

Example 79 with Race

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

the class RaceToken method getRaceToken.

private static String getRaceToken(PlayerCharacter pc) {
    String retString = Constants.EMPTY_STRING;
    Race race = pc.getDisplay().getRace();
    String tempRaceName = OutputNameFormatting.getOutputName(race);
    if (tempRaceName == null || tempRaceName.isEmpty()) {
        tempRaceName = race.getDisplayName();
    }
    StringBuilder extraRaceInfo = new StringBuilder(40);
    String subRace = pc.getDisplay().getSubRace();
    if (subRace != null) {
        extraRaceInfo.append(subRace);
    }
    if (SettingsHandler.hideMonsterClasses()) {
        LevelCommandFactory lcf = race.get(ObjectKey.MONSTER_CLASS);
        if (lcf != null) {
            PCClass monsterClass = lcf.getPCClass();
            final PCClass aClass = pc.getClassKeyed(monsterClass.getKeyName());
            if (aClass != null) {
                int minHD = lcf.getLevelCount().resolve(pc, "").intValue();
                int monsterHD = pc.getDisplay().getLevel(aClass);
                if (monsterHD != minHD) {
                    if (extraRaceInfo.length() != 0) {
                        extraRaceInfo.append(' ');
                    }
                    extraRaceInfo.append(monsterHD).append(//$NON-NLS-1$
                    LanguageBundle.getString("in_hdLabel"));
                }
            }
        }
    }
    retString = tempRaceName;
    if (extraRaceInfo.length() != 0) {
        //$NON-NLS-1$
        retString += " (" + extraRaceInfo + ')';
    }
    return retString;
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) Race(pcgen.core.Race) PCClass(pcgen.core.PCClass)

Example 80 with Race

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

the class RaceToken method getSubToken.

private static String getSubToken(final String subToken, CharacterDisplay display) {
    if (!subToken.equals(SUBTOKENLIST[0])) {
        return Constants.EMPTY_STRING;
    }
    final List<SpecialAbility> saList = new ArrayList<>();
    Race race = display.getRace();
    saList.addAll(display.getResolvedUserSpecialAbilities(race));
    saList.addAll(display.getResolvedSpecialAbilities(race));
    if (saList.isEmpty()) {
        return Constants.EMPTY_STRING;
    }
    StringBuilder returnString = new StringBuilder();
    boolean firstLine = true;
    for (SpecialAbility sa : saList) {
        if (!firstLine) {
            //$NON-NLS-1$
            returnString.append(", ");
        }
        firstLine = false;
        returnString.append(sa.getDisplayName());
    }
    return returnString.toString();
}
Also used : Race(pcgen.core.Race) ArrayList(java.util.ArrayList) SpecialAbility(pcgen.core.SpecialAbility)

Aggregations

Race (pcgen.core.Race)167 Test (org.junit.Test)78 PCTemplate (pcgen.core.PCTemplate)66 PlayerCharacter (pcgen.core.PlayerCharacter)28 CDOMObject (pcgen.cdom.base.CDOMObject)16 LoadContext (pcgen.rules.context.LoadContext)16 PCClass (pcgen.core.PCClass)15 ArrayList (java.util.ArrayList)10 SizeAdjustment (pcgen.core.SizeAdjustment)10 ParseResult (pcgen.rules.persistence.token.ParseResult)10 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)10 PCStat (pcgen.core.PCStat)9 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)8 Equipment (pcgen.core.Equipment)8 BonusObj (pcgen.core.bonus.BonusObj)7 Formula (pcgen.base.formula.Formula)6 WieldCategory (pcgen.core.character.WieldCategory)6 GameMode (pcgen.core.GameMode)5 Skill (pcgen.core.Skill)5 CompanionList (pcgen.cdom.list.CompanionList)4