Class Character


public class Character extends Monster
One character (player or non-player personae).
Since:
2014-05-20
  • Field Details

    • BASE_AGE

      static final int BASE_AGE
      Base age in years.
      See Also:
    • BASE_ARMOR_CLASS

      static final int BASE_ARMOR_CLASS
      Base armor class.
      See Also:
    • BASE_MOVEMENT

      static final int BASE_MOVEMENT
      Base movement.
      See Also:
    • BASE_HD

      static final Dice BASE_HD
      Base hit dice.
    • BASE_MAGIC_PER_LEVEL

      static final int BASE_MAGIC_PER_LEVEL
      Base percent per level for magic items.
      See Also:
    • ABILITY_DICE

      static final Dice[] ABILITY_DICE
      Dice for ability scores.
    • APPLY_BONUS_XP

      static final boolean APPLY_BONUS_XP
      Whether we apply the prime-requisite XP bonus.
      See Also:
    • age

      int age
      Age in years.
    • name

      String name
      Personal name of the character.
    • abilityScores

      AbstractMap<Ability,Integer> abilityScores
      The six ability scores.
    • abilityScoreDamage

      AbstractMap<Ability,Integer> abilityScoreDamage
      Ability score damage.
    • classList

      List<ClassRecord> classList
      List of classes with XP scores.
    • armorWorn

      Armor armorWorn
      Armor worn.
    • shieldHeld

      Armor shieldHeld
      Shield held.
    • weaponInHand

      Weapon weaponInHand
      Weapon in hand.
    • ringWorn

      Equipment ringWorn
      Magic ring.
    • wandHeld

      Equipment wandHeld
      Magic wand.
    • equipList

      List<Equipment> equipList
      Equipment carried.
    • primaryPersonality

      Primary personality trait.
    • secondaryPersonality

      Secondary personality trait.
    • sweepRate

      int sweepRate
      Rate of sweep attacks (vs. 1 HD targets)
    • pctMagicPerLevel

      static int pctMagicPerLevel
      Percent chance per level for magic items.
    • useFeats

      static boolean useFeats
      Assign feats to characters?
    • useSweepAttacks

      static boolean useSweepAttacks
      Give attacks by fighter level vs. 1 HD creatures?
    • printFeats

      static boolean printFeats
      Print feats in string descriptor?
    • printAbilities

      static boolean printAbilities
      Print abilities in string descriptor?
    • printEquipment

      static boolean printEquipment
      Print equipment in string descriptor?
    • printPersonality

      static boolean printPersonality
      Print personality in string descriptor?
    • printSpells

      static boolean printSpells
      Print spells in string descriptor?
    • boostInitialAbilities

      static boolean boostInitialAbilities
      Boost abilities & hit points at time of creation?
    • applyAgingEffects

      static boolean applyAgingEffects
      Apply aging effects?
  • Constructor Details

    • Character

      public Character(String race, String classn, int level, String align)
      Constructor (single class).
    • Character

      public Character(String race, String class1, int level1, String class2, int level2, String align)
      Constructor (double class).
  • Method Details

    • getName

      public String getName()
    • getArmor

      public Armor getArmor()
      Overrides:
      getArmor in class Monster
    • getShield

      public Armor getShield()
      Overrides:
      getShield in class Monster
    • getWeapon

      public Weapon getWeapon()
      Overrides:
      getWeapon in class Monster
    • getEquipmentCount

      public int getEquipmentCount()
    • getEquipment

      public Equipment getEquipment(int i)
    • addEquipment

      public void addEquipment(Equipment equip)
    • dropAllEquipment

      public void dropAllEquipment()
    • isFighter

      public boolean isFighter()
    • isThief

      public boolean isThief()
    • isWizard

      public boolean isWizard()
    • rollAbilityScores

      private void rollAbilityScores(ClassType type, int level)
      Roll random ability scores for single-class character.
    • rollAbilityScoresDblClass

      private void rollAbilityScoresDblClass(ClassType type1, int level1, ClassType type2, int level2)
      Roll random ability scores for double-class character. (This is ugly b/c it needs to happen before we add class records.)
    • rollPriorityAbilityScores

      private void rollPriorityAbilityScores(Ability[] priorityList, int level)
      Roll boosted random ability scores as per given priority.
    • getBoostedAbilityDice

      private Dice getBoostedAbilityDice(int level, int priority)
      Get ability dice boosted by level and priority. This is as per OED rule observed from Monte Carlo analysis.
    • getAbilityScore

      public int getAbilityScore(Ability a)
      Get an ability score.
      Overrides:
      getAbilityScore in class Monster
    • takeAbilityDamage

      protected void takeAbilityDamage(Ability a, int damage)
      Overrides:
      takeAbilityDamage in class Monster
    • zeroAbilityDamage

      public void zeroAbilityDamage()
      Overrides:
      zeroAbilityDamage in class Monster
    • adjustAllAbilityScores

      private void adjustAllAbilityScores(int... modifiers)
    • handleConChange

      private void handleConChange(int oldCon)
      Handle a Constitution change to hit points.
    • hasNullAbilityScore

      protected boolean hasNullAbilityScore()
      Are any of our ability scores zero? Because then we are dead.
      Overrides:
      hasNullAbilityScore in class Monster
    • updateStats

      private void updateStats()
      Update derived statistics after any character changes.
    • hasPrimeReqClass

      private boolean hasPrimeReqClass(Ability prime)
      Do we have any class with the given prime requisite?
    • getTopClass

      public ClassRecord getTopClass()
      Get highest level class.
    • getLevel

      public int getLevel()
      Get highest class level.
      Overrides:
      getLevel in class Monster
    • getHitDiceNum

      public int getHitDiceNum()
      Get raw number of hit dice. When "HD" referenced in RPG rules, it means "level" for PC/NPCs. E.g.: Attacks, saves, magic effects, XP awards.
      Overrides:
      getHitDiceNum in class Monster
    • computeArmorClass

      private int computeArmorClass()
      Get adjusted armor class.
    • computeMoveInches

      private int computeMoveInches()
      Get movement based on armor.
    • getEncumbrance

      public float getEncumbrance()
      Get total encumbrance of equipment.
    • computeAttack

      private Attack computeAttack()
      Get weapon-based melee attack routine.
    • baseAttackBonus

      private int baseAttackBonus()
      Returns base attack bonus (max over all classes).
    • getMagicHitLevel

      protected int getMagicHitLevel()
      Find what level of magic-to-hit we can strike.
      Overrides:
      getMagicHitLevel in class Monster
    • setArmor

      public void setArmor(Armor armor)
      Set armor worn.
    • setShield

      public void setShield(Armor shield)
      Set shield carried.
    • drawWeapon

      public void drawWeapon(Weapon weapon)
      Draw a particular weapon.
    • findShieldInEquip

      private Armor findShieldInEquip()
      Find shield in equipment list, if any
    • drawNextWeapon

      public void drawNextWeapon()
      Draw next weapon in equipment iteratively.
    • drawBestWeapon

      public void drawBestWeapon(Monster monster)
      Draw best weapon against a given monster.
      Overrides:
      drawBestWeapon in class Monster
    • loseEquipment

      protected void loseEquipment(Equipment equip)
      Lose a given piece of equipment.
      Overrides:
      loseEquipment in class Monster
    • maxDamageVsMonster

      private int maxDamageVsMonster(Monster monster)
      Compute max damage against a given monster.
    • totalXP

      public int totalXP()
      Returns total XP (sum over all classes).
    • addXP

      public void addXP(int xp)
      Add XP to the first character class.
      Overrides:
      addXP in class Monster
    • addXP

      public void addXP(int XP, int classIdx)
      Add XP to a specified character class.
    • adjustForPrimeReq

      private int adjustForPrimeReq(int XP, ClassRecord cr)
      Adjust XP award for the class prime requisite.
    • loseLevel

      protected void loseLevel()
      Lose a level (e.g., energy drain).
      Overrides:
      loseLevel in class Monster
    • findSupMaxHitPoints

      private int findSupMaxHitPoints()
      Find maximum hit points (supremum over all classes).
    • evilNPCFromTitle

      public static Character evilNPCFromTitle(String title)
      Create evil human NPC with equipment from class title.
    • setBasicEquipment

      public void setBasicEquipment()
      Set basic equipment by top class.
    • boostMagicItemsOneLevel

      public void boostMagicItemsOneLevel()
      Make rolls to boost magic items for one level.
      Overrides:
      boostMagicItemsOneLevel in class Monster
    • boostMagicItemsToLevel

      public void boostMagicItemsToLevel()
      Boost all magic items to the character's top level.
    • getMagicBoost

      boolean getMagicBoost()
      Check if a magic item boost is gained.
    • incrementRing

      void incrementRing()
      Increment magic ring worn.
    • incrementWand

      void incrementWand()
      Increment magic wand carried.
    • rollSave

      protected boolean rollSave(SavingThrows.Type type, int modifier)
      Roll a saving throw with modifier.
      Overrides:
      rollSave in class Monster
    • bestClassForSave

      private ClassRecord bestClassForSave(SavingThrows.Type saveType)
      Find the best class to use for a given saving throw.
    • setFeatUsage

      public static void setFeatUsage(boolean permit)
      Set if we should be using optional feats.
    • useFeats

      public static boolean useFeats()
      Are we using optional feats?
    • hasFeat

      protected boolean hasFeat(Feat feat)
      Does this character have a given feat?
      Overrides:
      hasFeat in class Monster
    • setSweepAttacks

      public static void setSweepAttacks(boolean permit)
      Set if we should be using sweep attacks.
    • useSweepAttacks

      public static boolean useSweepAttacks()
      Are we using sweep attacks?
    • computeSweepRate

      private int computeSweepRate()
      How many attacks does this character get against 1 HD opponents? Give this fighter bonus to any class with BAB 1 or above.
    • getSweepRate

      protected int getSweepRate()
      Get this character's recorded sweep rate.
      Overrides:
      getSweepRate in class Monster
    • getAge

      public int getAge()
      Get the age of the character.
    • incrementAge

      public void incrementAge()
      Increment the age of the character.
    • getAgeCategory

      Character.AgeCategory getAgeCategory()
      Get the age category of the character. Caution: Works for Humans only.
    • ageAdjustAbilities

      private void ageAdjustAbilities()
      Adjust ability scores on reaching a new age category.
    • ageAdjustLevels

      private void ageAdjustLevels()
      Adjust levels on advancing age. Prevents fighters from living indefinitely long; follows pattern Gygax showed for Conan in Dragon #36.
    • getTreasureValue

      public int getTreasureValue()
      Generate random treasure value by men type "A", scaled by level and nominal men number appearing. (Recommended for wilderness encounters only.)
      Overrides:
      getTreasureValue in class Monster
    • getAlignmentFromString

      Alignment getAlignmentFromString(String s)
      Convert string to alignment (random if null).
    • setBoostInitialAbilities

      public static void setBoostInitialAbilities(boolean boost)
      Mutator to initial ability/hp boost switch.
    • getBoostInitialAbilities

      public static boolean getBoostInitialAbilities()
      Accessor to initial ability/hp boost switch.
    • setApplyAgingEffects

      public static void setApplyAgingEffects(boolean aging)
      Mutator to aging effect switch.
    • setPctMagicPerLevel

      public static void setPctMagicPerLevel(int pct)
      Mutator to percent magic per level.
    • isPerson

      public boolean isPerson()
      Is this character a person? (redefines Monster method)
      Overrides:
      isPerson in class Monster
    • getSpellMemory

      public SpellMemory getSpellMemory()
      Get the character's spell memory, if any. Warning: This assumes a character has at most one spellcasting class. If multiple spell classes supported, this system needs reworking.
      Overrides:
      getSpellMemory in class Monster
    • setPrintFeats

      public static void setPrintFeats(boolean p)
    • setPrintAbilities

      public static void setPrintAbilities(boolean p)
    • setPrintEquipment

      public static void setPrintEquipment(boolean p)
    • setPrintPersonality

      public static void setPrintPersonality(boolean p)
    • setPrintSpells

      public static void setPrintSpells(boolean p)
    • toString

      public String toString()
      Identify this object as a string.
      Overrides:
      toString in class Monster
    • shortString

      public String shortString()
      Short String representation of this character.
      Overrides:
      shortString in class Monster
    • classString

      private String classString(boolean slashes)
      String representation of all class and levels.
    • abilityString

      private String abilityString()
      String representation of all ability scores.
    • personalityString

      private String personalityString()
      String representation of alignment and personality.
    • equipString

      private String equipString()
      String representation of equipment.
    • featString

      public String featString()
      String representation of feats.
    • skillString

      public String skillString()
      String representation of skills.
    • spellString

      public String spellString()
      String representation of spells.
    • addItem

      private String addItem(String s, Object item)
      Add item to a string if not null.
    • addClause

      private String addClause(String s, String clause)
      Add an independent clause to a string, if nonempty.
    • addClause

      private String addClause(String s, String label, String clause)
      Add a label & clause to a string, if nonempty.
    • toSentenceCase

      public static String toSentenceCase(String s)
      Convert a string to sentence case.
    • getRaceClassDesc

      public String getRaceClassDesc()
      Create a short race/class descriptor.
    • getFilename

      public String getFilename()
      Create a filename identifier.
    • main

      public static void main(String[] args)
      Main test method.