use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.
the class CasterLevelToken method getClassToken.
/**
* Get the class token
* @param pc
* @param classNumber
* @return token
*/
public String getClassToken(PlayerCharacter pc, int classNumber) {
String cString = "";
CharacterDisplay display = pc.getDisplay();
if (display.getClassCount() > classNumber) {
PCClass pcClass = display.getClassList().get(classNumber);
cString = "CLASS:" + pcClass.getKeyName();
}
return Float.toString(pc.getVariableValue(TOKENNAME, cString).intValue());
}
use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.
the class DefenseToken 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 = "";
StringTokenizer aTok = new StringTokenizer(tokenSource, ".");
aTok.nextToken();
if (aTok.hasMoreTokens()) {
String defenseType = aTok.nextToken();
CharacterDisplay display = pc.getDisplay();
String solverValue = pc.getControl("ACVAR" + defenseType);
if (solverValue != null) {
Object val = pc.getGlobal(solverValue);
int intValue = ((Number) val).intValue();
if ("EQUIPMENT".equals(defenseType)) {
val = pc.getGlobal(pc.getControl(CControl.ACVARARMOR));
intValue += ((Number) val).intValue();
}
retString = Integer.toString(intValue);
} else if (defenseType.equals("TOTAL")) {
retString = Integer.toString(display.calcACOfType("Total"));
} else if (defenseType.equals("FLATFOOTED")) {
retString = Integer.toString(display.calcACOfType("Flatfooted"));
} else if (defenseType.equals("TOUCH")) {
retString = Integer.toString(display.calcACOfType("Touch"));
} else if (defenseType.equals("BASE")) {
retString = Integer.toString(display.calcACOfType("Base"));
} else if (defenseType.equals("ABILITY")) {
retString = Integer.toString(display.calcACOfType("Ability"));
} else if (defenseType.equals("CLASS")) {
retString = Integer.toString(display.calcACOfType("ClassDefense"));
} else if (defenseType.equals("DODGE")) {
retString = Integer.toString(display.calcACOfType("Dodge"));
} else if (defenseType.equals("EQUIPMENT")) {
retString = Integer.toString(display.calcACOfType("Equipment") + display.calcACOfType("Armor"));
} else if (defenseType.equals("MISC")) {
retString = Integer.toString(display.calcACOfType("Misc"));
} else if (defenseType.equals("NATURAL")) {
retString = Integer.toString(display.calcACOfType("NaturalArmor"));
} else if (defenseType.equals("SIZE")) {
retString = Integer.toString(display.calcACOfType("Size"));
}
}
return retString;
}
use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.
the class EncounterPlugin method rollHP.
private static void rollHP(PlayerCharacter aPC) {
CharacterDisplay display = aPC.getDisplay();
for (PCClass pcClass : display.getClassSet()) {
for (int j = 0; j < display.getLevel(pcClass); j++) {
int bonus = (int) aPC.getTotalBonusTo("HD", "MIN") + (int) aPC.getTotalBonusTo("HD", "MIN;CLASS." + pcClass.getKeyName());
int size = display.getLevelHitDie(pcClass, j + 1).getDie();
PCClassLevel classLevel = display.getActiveClassLevel(pcClass, j);
aPC.setHP(classLevel, new Dice(1, size, bonus).roll());
}
}
aPC.setDirty(true);
}
use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.
the class PreSkillSitTester method passes.
@Override
public int passes(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source) {
CharacterDisplay display = character.getDisplay();
final int requiredRanks = Integer.parseInt(prereq.getOperand());
// Compute the skill name from the Prerequisite
String requiredSkill = prereq.getCategoryName();
String situation = prereq.getKey();
Map<Skill, Set<Skill>> serveAsSkills = getImitators(display);
int runningTotal = 0;
boolean foundMatch = false;
boolean foundSkill = false;
for (Skill aSkill : display.getSkillSet()) {
final String aSkillKey = aSkill.getKeyName().toUpperCase();
if (aSkillKey.equals(requiredSkill)) {
foundMatch = true;
foundSkill = true;
runningTotal = getRunningTotal(aSkill, character, prereq, foundMatch, runningTotal, requiredRanks, situation);
}
if (prereq.isCountMultiples() || prereq.isTotalValues()) {
// For counted totals we want to count all occurances, not just the first
foundMatch = false;
}
if (foundMatch) {
break;
}
}
if (!foundSkill) {
for (Skill mock : serveAsSkills.keySet()) {
Set<Skill> targets = serveAsSkills.get(mock);
for (Skill target : targets) {
if (foundSkill) {
break;
}
final String aSkillKey = target.getKeyName().toUpperCase();
if (aSkillKey.equals(requiredSkill)) {
foundSkill = true;
foundMatch = true;
int theTotal = getRunningTotal(mock, character, prereq, foundMatch, runningTotal, requiredRanks, situation);
runningTotal += theTotal;
}
}
}
}
// doesn't have the skill we have to return a match
if (foundSkill == false) {
if (prereq.getOperator() == PrerequisiteOperator.LT) {
runningTotal++;
}
}
return countedTotal(prereq, runningTotal);
}
use of pcgen.core.display.CharacterDisplay in project pcgen by PCGen.
the class PreSkillTester 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();
final int requiredRanks = Integer.parseInt(prereq.getOperand());
// Compute the skill name from the Prerequisite
String requiredSkillKey = prereq.getKey().toUpperCase();
if (prereq.getSubKey() != null) {
//$NON-NLS-1$ //$NON-NLS-2$
requiredSkillKey += " (" + prereq.getSubKey().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;
// Now locate all instances of this skillname and test them
final int percentageSignPosition = skillKey.lastIndexOf('%');
HashMap<Skill, Set<Skill>> serveAsSkills = new HashMap<>();
Set<Skill> imitators = new HashSet<>();
this.getImitators(serveAsSkills, imitators, display);
int runningTotal = 0;
boolean foundMatch = false;
boolean foundSkill = false;
for (Skill aSkill : display.getSkillSet()) {
final String aSkillKey = aSkill.getKeyName().toUpperCase();
if (isType) {
if (percentageSignPosition >= 0) {
foundMatch = matchesTypeWildCard(skillKey, percentageSignPosition, foundSkill, aSkill);
foundSkill = (foundMatch) ? true : false;
runningTotal = getRunningTotal(aSkill, character, prereq, foundMatch, runningTotal, requiredRanks);
} else if (aSkill.isType(skillKey)) {
foundMatch = true;
foundSkill = true;
runningTotal = getRunningTotal(aSkill, character, prereq, foundMatch, runningTotal, requiredRanks);
}
// If there wasn't a match, then check other skills of the type
if (runningTotal == 0) {
foundMatch = false;
}
} else if (aSkillKey.equals(skillKey) || ((percentageSignPosition >= 0) && aSkillKey.startsWith(skillKey.substring(0, percentageSignPosition)))) {
foundMatch = true;
foundSkill = true;
runningTotal = getRunningTotal(aSkill, character, prereq, foundMatch, runningTotal, requiredRanks);
}
if (prereq.isCountMultiples() || prereq.isTotalValues()) {
// For counted totals we want to count all occurances, not just the first
foundMatch = false;
}
if (foundMatch) {
break;
}
}
if (!isType && !foundSkill) {
for (Skill mock : serveAsSkills.keySet()) {
Set<Skill> targets = serveAsSkills.get(mock);
for (Skill target : targets) {
if (foundSkill) {
break;
}
final String aSkillKey = target.getKeyName().toUpperCase();
if (target.getDisplayName().equalsIgnoreCase(skillKey)) {
foundSkill = true;
foundMatch = true;
int theTotal = getRunningTotal(mock, character, prereq, foundMatch, runningTotal, requiredRanks);
runningTotal += theTotal;
} else if (aSkillKey.equals(skillKey) || ((percentageSignPosition >= 0) && aSkillKey.startsWith(skillKey.substring(0, percentageSignPosition)))) {
foundSkill = true;
foundMatch = true;
int theTotal = getRunningTotal(mock, character, prereq, foundMatch, runningTotal, requiredRanks);
runningTotal += theTotal;
}
}
}
} else if (isType && !foundSkill) {
for (Skill mock : serveAsSkills.keySet()) {
Set<Skill> targets = serveAsSkills.get(mock);
for (Skill target : targets) {
if (foundSkill) {
break;
}
if (target.isType(skillKey)) {
foundSkill = true;
foundMatch = true;
int theTotal = getRunningTotal(mock, character, prereq, foundMatch, runningTotal, requiredRanks);
runningTotal += theTotal;
} else if ((percentageSignPosition >= 0)) {
List<Type> mockTypes = target.getTrueTypeList(true);
for (Type mockType : mockTypes) {
foundMatch = matchesTypeWildCard(skillKey, percentageSignPosition, foundSkill, target);
foundSkill = (foundMatch) ? true : false;
runningTotal = getRunningTotal(mock, character, prereq, foundMatch, runningTotal, requiredRanks);
if (foundSkill) {
break;
}
}
}
}
}
}
// doesn't have the skill we have to return a match
if (foundSkill == false) {
if (prereq.getOperator() == PrerequisiteOperator.LT) {
runningTotal++;
}
}
return countedTotal(prereq, runningTotal);
}
Aggregations