Search in sources :

Example 6 with CharacterDisplay

use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.

the class DeityToken method getToken.

/**
	 * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
	 */
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
    String retString = "";
    CharacterDisplay display = pc.getDisplay();
    Deity deity = display.getDeity();
    if (deity != null) {
        StringTokenizer aTok = new StringTokenizer(tokenSource, ".", false);
        String subTag = "OUTPUTNAME";
        if (aTok.countTokens() > 1) {
            aTok.nextToken();
            subTag = aTok.nextToken();
        }
        if ("NAME".equals(subTag)) {
            if (!display.getSuppressBioField(BiographyField.DEITY)) {
                retString = deity.getDisplayName();
            }
        } else if ("OUTPUTNAME".equals(subTag)) {
            if (!display.getSuppressBioField(BiographyField.DEITY)) {
                retString = OutputNameFormatting.getOutputName(deity);
            }
        } else if ("DOMAINLIST".equals(subTag)) {
            retString = getDomainListToken(deity);
        } else if ("FOLLOWERALIGNMENT".equals(subTag)) {
            Logging.errorPrint("Output Sheet uses DEITY.FOLLOWERALIGN: " + "Function has been removed from PCGen");
        } else if ("ALIGNMENT".equals(subTag)) {
            CDOMSingleRef<PCAlignment> al = deity.get(ObjectKey.ALIGNMENT);
            retString = al == null ? "" : al.get().getKeyName();
        } else if ("APPEARANCE".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Appearance");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        } else if ("DESCRIPTION".equals(subTag)) {
            retString = pc.getDescription(deity);
        } else if ("HOLYITEM".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Symbol");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        } else if ("FAVOREDWEAPON".equals(subTag)) {
            List<CDOMReference<WeaponProf>> dwp = deity.getSafeListFor(ListKey.DEITYWEAPON);
            retString = ReferenceUtilities.joinLstFormat(dwp, Constants.PIPE, true);
        } else if ("PANTHEONLIST".equals(subTag)) {
            FactSetKey<String> fk = FactSetKey.valueOf("Pantheon");
            Set<String> pset = new TreeSet<>();
            for (Indirect<String> indirect : deity.getSafeSetFor(fk)) {
                pset.add(indirect.get());
            }
            retString = StringUtil.join(pset, ", ");
        } else if ("SOURCE".equals(subTag)) {
            retString = SourceFormat.getFormattedString(deity, Globals.getSourceDisplay(), true);
        } else if ("SA".equals(subTag)) {
            retString = getSAToken(deity, display);
        } else if ("TITLE".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Title");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        } else if ("WORSHIPPERS".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Worshippers");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        }
    }
    return retString;
}
Also used : Deity(pcgen.core.Deity) TreeSet(java.util.TreeSet) Set(java.util.Set) CharacterDisplay(pcgen.core.display.CharacterDisplay) Indirect(pcgen.base.util.Indirect) FactKey(pcgen.cdom.enumeration.FactKey) StringTokenizer(java.util.StringTokenizer) PCAlignment(pcgen.core.PCAlignment) FactSetKey(pcgen.cdom.enumeration.FactSetKey) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 7 with CharacterDisplay

use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.

the class PreSkillMultTester method passes.

/**
	 * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
	 */
@Override
public int passes(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source) {
    CharacterDisplay display = character.getDisplay();
    int runningTotal = 0;
    final int requiredRanks = Integer.parseInt(prereq.getOperand());
    String requiredSkillKey = prereq.getKey().toUpperCase();
    final boolean isType = //$NON-NLS-1$ //$NON-NLS-2$
    (requiredSkillKey.startsWith("TYPE.") || requiredSkillKey.startsWith("TYPE="));
    if (isType) {
        requiredSkillKey = requiredSkillKey.substring(5);
    }
    final String skillKey = requiredSkillKey;
    final int percentageSignPosition = skillKey.lastIndexOf('%');
    boolean foundMatch = false;
    for (Skill aSkill : display.getSkillSet()) {
        final String aSkillKey = aSkill.getKeyName().toUpperCase();
        if (isType) {
            if (percentageSignPosition >= 0) {
                for (Type type : aSkill.getTrueTypeList(false)) {
                    if (type.toString().toUpperCase().startsWith(skillKey.substring(0, percentageSignPosition))) {
                        foundMatch = true;
                        break;
                    }
                }
            } else if (aSkill.isType(skillKey)) {
                foundMatch = true;
            }
            if (foundMatch) {
                final int result = prereq.getOperator().compare(SkillRankControl.getTotalRank(character, aSkill).intValue(), requiredRanks);
                if (result == 0) {
                    foundMatch = false;
                } else {
                    runningTotal = result;
                }
            }
        } else if (aSkillKey.equals(skillKey) || ((percentageSignPosition >= 0) && aSkillKey.startsWith(skillKey.substring(0, percentageSignPosition)))) {
            final int result = prereq.getOperator().compare(SkillRankControl.getTotalRank(character, aSkill).intValue(), requiredRanks);
            if (result > 0) {
                foundMatch = true;
                runningTotal = result;
            }
        }
        if (foundMatch) {
            break;
        }
    }
    return countedTotal(prereq, runningTotal);
}
Also used : Skill(pcgen.core.Skill) Type(pcgen.cdom.enumeration.Type) CharacterDisplay(pcgen.core.display.CharacterDisplay)

Example 8 with CharacterDisplay

use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.

the class BioSetTest method testAgeSet.

/**
	 * Test the age set
	 */
public void testAgeSet() {
    final PlayerCharacter pc = getCharacter();
    CharacterDisplay display = pc.getDisplay();
    final Race human = new Race();
    human.setName("Human");
    pc.setRace(human);
    pc.setPCAttribute(NumericPCAttribute.AGE, 12);
    int idx = display.getAgeSetIndex();
    assertEquals("Ageset for " + display.getAge() + ".", 0, idx);
    pc.setPCAttribute(NumericPCAttribute.AGE, 17);
    idx = display.getAgeSetIndex();
    assertEquals("Ageset for " + display.getAge() + ".", 0, idx);
    pc.setPCAttribute(NumericPCAttribute.AGE, 36);
    idx = display.getAgeSetIndex();
    assertEquals("Ageset for " + display.getAge() + ".", 1, idx);
    pc.setPCAttribute(NumericPCAttribute.AGE, 54);
    idx = display.getAgeSetIndex();
    assertEquals("Ageset for " + display.getAge() + ".", 2, idx);
    pc.setPCAttribute(NumericPCAttribute.AGE, 72);
    idx = display.getAgeSetIndex();
    assertEquals("Ageset for " + display.getAge() + ".", 3, idx);
    SettingsHandler.getGame().getBioSet().getAgeSet(Region.getConstant(pc.getDisplay().getRegionString()), idx);
}
Also used : CharacterDisplay(pcgen.core.display.CharacterDisplay)

Example 9 with CharacterDisplay

use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.

the class FollowerOfToken method getFollowerOfToken.

/**
	 * Get FOLLOWEROF Token
	 *
	 * @param pc
	 * @return Token
	 */
public static String getFollowerOfToken(PlayerCharacter pc) {
    String retString = "";
    PlayerCharacter masterPC = pc.getMasterPC();
    if (masterPC != null) {
        CharacterDisplay masterDisplay = masterPC.getDisplay();
        for (Follower aFollower : masterDisplay.getFollowerList()) {
            if (aFollower.getFileName().equals(pc.getDisplay().getFileName())) {
                retString = aFollower.getType() + " of " + masterDisplay.getName();
            }
        }
    }
    return retString;
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) CharacterDisplay(pcgen.core.display.CharacterDisplay) Follower(pcgen.core.character.Follower)

Example 10 with CharacterDisplay

use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.

the class HPRollToken method getRollToken.

/**
	 * Get the HPROLL.ROLL token
	 * @param pc
	 * @param level
	 * @return the HPROLL.ROLL token
	 */
public static int getRollToken(PlayerCharacter pc, int level) {
    CharacterDisplay display = pc.getDisplay();
    int classLevel = display.getLevelInfoClassLevel(level) - 1;
    int hpRoll = 0;
    PCClass pcClass = pc.getClassKeyed(display.getLevelInfoClassKeyName(level));
    if (pcClass != null) {
        PCClassLevel pcl = display.getActiveClassLevel(pcClass, classLevel);
        Integer hp = display.getHP(pcl);
        hpRoll = hp == null ? 0 : hp;
    }
    return hpRoll;
}
Also used : CharacterDisplay(pcgen.core.display.CharacterDisplay) PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Aggregations

CharacterDisplay (pcgen.core.display.CharacterDisplay)32 StringTokenizer (java.util.StringTokenizer)9 PCClass (pcgen.core.PCClass)9 Equipment (pcgen.core.Equipment)5 ArrayList (java.util.ArrayList)4 PlayerCharacter (pcgen.core.PlayerCharacter)4 Skill (pcgen.core.Skill)4 Set (java.util.Set)3 CDOMReference (pcgen.cdom.base.CDOMReference)3 PCClassLevel (pcgen.cdom.inst.PCClassLevel)3 PCTemplate (pcgen.core.PCTemplate)3 Follower (pcgen.core.character.Follower)3 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 Type (pcgen.cdom.enumeration.Type)2 SpecialAbility (pcgen.core.SpecialAbility)2 Dice (gmgen.plugin.dice.Dice)1 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1