org.haphazard.character
Class Character

java.lang.Object
  extended byorg.haphazard.gui.engine.GraphicalObject
      extended byorg.haphazard.gui.engine.MoveableGraphicalObject
          extended byorg.haphazard.character.Character
Direct Known Subclasses:
Monster, Warrior

public class Character
extends MoveableGraphicalObject

A character handles everything with a person in the world


Field Summary
 
Fields inherited from class org.haphazard.gui.engine.MoveableGraphicalObject
mFacing, mLocation, mMap, mSpeedVector, mUseFogOfWar
 
Fields inherited from class org.haphazard.gui.engine.GraphicalObject
id, mDefaultSprite, mDescription, mDescriptionColor, mDescriptionDisplayTime, mDescriptionStartTime, mDimension, mLink, mName, mSpriteDisplayed, mSprites, mWeight
 
Constructor Summary
Character()
          Creates a new instance of Character
Character(java.lang.String name)
          Creates a new instance of Character
 
Method Summary
 void addBodyPart(BodyPart part)
          Adds a bodypart to the character
 void addSkill(Skill skill)
          Adds a skill to the characters repertoire
 void addSprite(Sprite sprite)
          Adds a sprite to this object
 boolean canCarry(Item item)
          Checks if a character can carry an item
 boolean canEquip(Item item)
          Tests if a character can equip an item (wield if weapon, wear if clothes
 boolean carry(Item item)
          Makes a character carry an item (adds it to the characters inventory) Hands are not included in the inventory, you'll have to "equip" the item to carry it in the hands.
 void createSkillNodes(java.util.Vector list, javax.swing.tree.DefaultMutableTreeNode node, Skill parent)
          Creates and adds all children to a certain node
 Item drop(Item item)
          Finds an item in the inventory and drops it
 javax.swing.tree.DefaultTreeModel getBodyTree()
          Gets a treeview of the body
 CharacterAction getController()
          Gets the controller of this character
 int getEquipmentWeight()
          Gets the weight of the characters equipment
 java.lang.String getGender()
          Gets the gender of the character
 javax.swing.tree.DefaultTreeModel getInventoryTree()
          Gets a treeview of the inventory
 int getInventoryWeight()
          Gets this characters inventory weight
 int getInventoryVolume()
          Gets the free volume of the characters inventory
 java.util.Vector getItemsOnGround()
          Gets the items on the tile the character is standing on
 int getPenalty()
          Gets the characters penalty on rolls depending on wounds, weight etc
 Item getPrimaryWeapon()
          Gets the characters primary weapon
 java.lang.String getPronoun()
          Returns a proper pronoun to use in any textual references
 java.util.Vector getSkillList()
           
 javax.swing.tree.DefaultTreeModel getSkillTree()
          Gets a tree of skills
 int getValue(java.lang.String skill)
          Gets a value of a skill
 int getWoundPenalty()
          Gets the total penalty from wounds
 float getWoundStatus()
          Gets a percentage of just how wounded the character is 1.0 is perfectly healthy, 0 is atleast unconscious
 java.lang.String heal(int bonus)
          Checks the healing process of the character This function should be changed when time is introduced, wounds should then be marked with a timestamp and logged how healing proceeds
 boolean isDead()
          Checks if the character is dead
 boolean isIncapacitated()
          Checks if the character is incapacitated
 void load(java.io.InputStream stream)
          Loads a character from a file
 boolean paintComponent(java.awt.Graphics2D g, Map map, java.awt.Point middleTileCoordinate)
          paints the component on the screen.
 void remove()
          Removes this character from play.
 void resolveExperience(java.lang.String skill, int delta)
          Resolves eventual experience
 java.lang.String resolveHit(int attack, boolean critical)
          Resolves the hit location and returns the BodyPart hit
 int roll(java.lang.String skill, int penalty, boolean applyWoundPenalty)
          Rolls a skill, removing eventual penalties
 void save(java.io.OutputStream stream)
          Saves the character in an XML-file
 void say(java.lang.String message)
          Makes the character say something
 void setController(CharacterAction controller)
          Sets the controller of this character
 void setGender(java.lang.String gender)
          Sets the gender of the character
 void setNaturalWeapon(Item weapon)
          Sets the characters natural weapon
 java.lang.String toXML(int indent)
          Translates this object into an XML notation
 boolean wearHold(Item item)
          Makes a character wear or hold an item
 
Methods inherited from class org.haphazard.gui.engine.MoveableGraphicalObject
getFacing, getLocation, getMap, loadInstance, paintComponent, setFacing, setLocation, setSpeed, update
 
Methods inherited from class org.haphazard.gui.engine.GraphicalObject
combineSprites, displayDescription, displaySprite, getAvailableSprites, getBoundingBox, getDescription, getDimension, getName, getNotResettedSprite, getResettedSprite, getWeight, isDefaultSpriteDisplayed, optimize, resetDisplayedSprite, setDefaultSprite, setDefaultSprite, setDescription, setDimension, setName, setWeight, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Character

public Character()
Creates a new instance of Character


Character

public Character(java.lang.String name)
Creates a new instance of Character

Parameters:
name - The name of the character
Method Detail

getGender

public java.lang.String getGender()
Gets the gender of the character

Returns:
A gender

setGender

public void setGender(java.lang.String gender)
Sets the gender of the character

Parameters:
gender - The gender to set

getPronoun

public java.lang.String getPronoun()
Returns a proper pronoun to use in any textual references

Returns:
his if male, her if female, its in any other case.

setController

public void setController(CharacterAction controller)
Sets the controller of this character


getController

public CharacterAction getController()
Gets the controller of this character


getPenalty

public int getPenalty()
Gets the characters penalty on rolls depending on wounds, weight etc

Returns:
The total penalty received

getWoundPenalty

public int getWoundPenalty()
Gets the total penalty from wounds

Returns:
The penalty from wounds

resolveHit

public java.lang.String resolveHit(int attack,
                                   boolean critical)
Resolves the hit location and returns the BodyPart hit

Parameters:
critical - If the most critical part was hit
Returns:
The bodypart hit

isIncapacitated

public boolean isIncapacitated()
Checks if the character is incapacitated

Returns:
True if so.

isDead

public boolean isDead()
Checks if the character is dead

Returns:
True if dead.

remove

public void remove()
Removes this character from play.


heal

public java.lang.String heal(int bonus)
Checks the healing process of the character This function should be changed when time is introduced, wounds should then be marked with a timestamp and logged how healing proceeds

Parameters:
bonus - Any bonuses that exists for the healing
Returns:
A string that describes the healing

addBodyPart

public void addBodyPart(BodyPart part)
Adds a bodypart to the character

Parameters:
part - The part to add

getBodyTree

public javax.swing.tree.DefaultTreeModel getBodyTree()
Gets a treeview of the body

Returns:
A JTree with a view over the body and equipped things down to container-level

getWoundStatus

public float getWoundStatus()
Gets a percentage of just how wounded the character is 1.0 is perfectly healthy, 0 is atleast unconscious

Returns:
A value between 0 and 1 denoting how hurt the character is

setNaturalWeapon

public void setNaturalWeapon(Item weapon)
Sets the characters natural weapon

Parameters:
weapon - The weapon to use

getPrimaryWeapon

public Item getPrimaryWeapon()
Gets the characters primary weapon

Returns:
The item used as a weapon, the natural weapon if none held

getValue

public int getValue(java.lang.String skill)
Gets a value of a skill

Parameters:
skill - The name of the skill
Returns:
The value of the skill

addSkill

public void addSkill(Skill skill)
Adds a skill to the characters repertoire

Parameters:
skill - The skill to add

roll

public int roll(java.lang.String skill,
                int penalty,
                boolean applyWoundPenalty)
Rolls a skill, removing eventual penalties

Parameters:
skill - The skill to roll
penalty - The penalty to apply
applyWoundPenalty - If eventual wounds make a difference
Returns:
The total number rolled (with all penalties applied)

resolveExperience

public void resolveExperience(java.lang.String skill,
                              int delta)
Resolves eventual experience

Parameters:
skill - The skill that is in question
delta - The delta value towards the difficulty

getSkillTree

public javax.swing.tree.DefaultTreeModel getSkillTree()
Gets a tree of skills

Returns:
A tree with the characters skills

getSkillList

public java.util.Vector getSkillList()

canEquip

public boolean canEquip(Item item)
Tests if a character can equip an item (wield if weapon, wear if clothes

Parameters:
item - The item to equip
Returns:
True if the character can equip the item, false if not so

canCarry

public boolean canCarry(Item item)
Checks if a character can carry an item

Parameters:
item - The item to carry
Returns:
True if the character has the means to carry the item, false if not so

wearHold

public boolean wearHold(Item item)
Makes a character wear or hold an item

Parameters:
item - The item to wear/hold
Returns:
true if successful

carry

public boolean carry(Item item)
Makes a character carry an item (adds it to the characters inventory) Hands are not included in the inventory, you'll have to "equip" the item to carry it in the hands. To carry a weapon, you'll need a scabbard that fits.

Parameters:
item - The item to carry
Returns:
True if the character could carry the item

drop

public Item drop(Item item)
Finds an item in the inventory and drops it

Parameters:
item - The item to drop
Returns:
The dropped item

getInventoryTree

public javax.swing.tree.DefaultTreeModel getInventoryTree()
Gets a treeview of the inventory

Returns:
A Treeview of the inventory

getInventoryWeight

public int getInventoryWeight()
Gets this characters inventory weight

Returns:
The characters inventory weight

getInventoryVolume

public int getInventoryVolume()
Gets the free volume of the characters inventory

Returns:
The free volume in cm3

getEquipmentWeight

public int getEquipmentWeight()
Gets the weight of the characters equipment

Returns:
The equipment weight in grams

save

public void save(java.io.OutputStream stream)
Saves the character in an XML-file

Overrides:
save in class GraphicalObject
Parameters:
stream - The stream to save to

load

public void load(java.io.InputStream stream)
Loads a character from a file

Overrides:
load in class MoveableGraphicalObject
Parameters:
stream - The input stream to load from

toXML

public java.lang.String toXML(int indent)
Translates this object into an XML notation

Overrides:
toXML in class MoveableGraphicalObject
Parameters:
indent - The level of indentation to use
Returns:
The object in XML notation

say

public void say(java.lang.String message)
Makes the character say something

Parameters:
message - The thing to say

getItemsOnGround

public java.util.Vector getItemsOnGround()
Gets the items on the tile the character is standing on

Returns:
The items on the tile the character is standing on

paintComponent

public boolean paintComponent(java.awt.Graphics2D g,
                              Map map,
                              java.awt.Point middleTileCoordinate)
paints the component on the screen.

Overrides:
paintComponent in class MoveableGraphicalObject
Parameters:
g - The graphics to use to paint with
map - the ground that "draw" this DGO. This is needed for displacement

addSprite

public void addSprite(Sprite sprite)
Adds a sprite to this object

Overrides:
addSprite in class GraphicalObject
Parameters:
sprite - The sprite to add

createSkillNodes

public void createSkillNodes(java.util.Vector list,
                             javax.swing.tree.DefaultMutableTreeNode node,
                             Skill parent)
Creates and adds all children to a certain node

Parameters:
list - All skills to choose from (Strings)
node - The parent node of the skill
parent - The parent skill