Java Universal Role Playing Engine Version 0.3.9

jurpe.items
Class Weapon

java.lang.Object
  extended by jurpe.items.AbstractItem
      extended by jurpe.items.Weapon
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AbstractItem>

public class Weapon
extends AbstractItem

Weapon Type Class. Every weapon must have a skill (Skill) to use it. Also, every weapons has Swing and Thrust damage for each type of Attack: Cutting, Impalling, Crushing.

See Also:
AbstractItem, Serialized Form

Constructor Summary
Weapon(java.lang.String name, int cost, int weight, Skill skl, int dCUT_SW, int dCUT_TH, int dCR_SW, int dCR_TH, int dIMP_SW, int dIMP_TH, int minStrength, int maxDamage, int wRange)
          Constructor
Weapon(java.lang.String name, WeaponAttack att, int cost, int weight, int maxDamage, int minStrength, int wRange, Skill skl)
          Constructor
 
Method Summary
 boolean canBeWorn(AbstractPC character)
          Return true if the character specified can wear the item (ie, has the required strength to lift the mace)
static Weapon createRandom(ItemValueType value, RandomNames rn, MasterShop ms, Skills sk)
          Creates a random generated Weapon
 java.lang.String[] getAttacks()
          Return an array of String determining a long description for each available Attack
 WeaponAttack getAttackTypes()
          Return Attack meta object
 int getBasicDamage(int characterStrength)
          Get Basic Damage for weapon
 int getDamageModifier()
          Returns modifier of damage based on weapon mode.
 DamageType getDamageType()
          Returns type of damage based on weapon mode.
 java.lang.String getDescription()
          Get long description of this weapon
 java.lang.String getDescription(java.lang.String divisor)
          Get a long description of weapon.
 int getIndexAttacks(DamageMode mode)
          If getAttacks returns 3 different types of attacks, when you pass the mode for this weapon, ie: Weapon.MODE_IMP, this method returns the position of that mode in that array.
 int getMaxDamage()
          Get Weapon's max damage.
 int getMaxDamage(int characterStrength)
          Get Maximum Damage for this weapon.
 int getMinimalStrength()
          Get Minimal Strength to wear this weapon
 DamageMode getMode()
          Get Selected Mode for this weapon.
 int getRange()
          The weapon range
 Skill getSkill()
          Get Skill required to use this weapon
 java.lang.String getStringMode()
          Get selected mode for this weapon as a string.
 boolean isBalanced()
          If this weapon need to get ready (not balanced).
 boolean isRanged()
          If this weapon is ranged
 boolean isReady()
          If this weapon is balanced, then returns true if it's also ready.
static void main(java.lang.String[] args)
          Deprecated.  
 void setMode(DamageMode mode)
          Set mode for this weapon (ie: cutting, crushing, impalling).
 void setWeaponReady(boolean isReady)
          If current weapon is unbalanced, you may set its status here.
 java.lang.String toString()
          Name of weapon
 void unwear(PCharacter pc)
          Unwear AbstractItem (polymorphic)
 boolean wear(PCharacter pc)
          Polymorphic method to wear this AbstractItem
 
Methods inherited from class jurpe.items.AbstractItem
clone, compareTo, getCommonDescription, getCost, getName, getType, getWeight, isItemRandom, isItemUsable, isItemWearable, setRandom, toStringWCost, use, warningMessage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Weapon

public Weapon(java.lang.String name,
              WeaponAttack att,
              int cost,
              int weight,
              int maxDamage,
              int minStrength,
              int wRange,
              Skill skl)
Constructor

Parameters:
name - Weapon's name
att - Available Attack types for this weapon
cost - Weapon's Cost
weight - Weapon's Weight
skl - Required Skill to use this weapon
minStrength - Minimal Strength (ST) to use Weapon
maxDamage - Max Damage this weapon can do, if any
wRange - Weapon's range (if ranged)

Weapon

public Weapon(java.lang.String name,
              int cost,
              int weight,
              Skill skl,
              int dCUT_SW,
              int dCUT_TH,
              int dCR_SW,
              int dCR_TH,
              int dIMP_SW,
              int dIMP_TH,
              int minStrength,
              int maxDamage,
              int wRange)
Constructor

Parameters:
name - Weapon's name
cost - Weapon's Cost
weight - Weapon's Weight
skl - Required Skill to use this weapon
dCUT_SW - Amount of damage made by Cutting/Swing.
dCUT_TH - Amount of damage made by Cutting/Thrust
dCR_SW - Amount of damage made by Crushing/Swing
dCR_TH - Amount of damage made by Crushing/Thrust
dIMP_SW - Amount of damage made by Impalling/Swing
dIMP_TH - Amount of damage made by Impalling/Thrust
minStrength - Minimal Strength (ST) to use Weapon
maxDamage - Max Damage this weapon can do, if any
wRange - Weapon's range (if ranged)
Method Detail

createRandom

public static Weapon createRandom(ItemValueType value,
                                  RandomNames rn,
                                  MasterShop ms,
                                  Skills sk)
                           throws JurpeException
Creates a random generated Weapon

Parameters:
value - ItemValueType indicating rarity of Item
rn - Handle to Random Names
ms - Handle to MasterShop
sk - Handle to Skills for this world
Returns:
newly created Weapon
Throws:
JurpeException

setMode

public void setMode(DamageMode mode)
Set mode for this weapon (ie: cutting, crushing, impalling). Use Weapon.MODE_IMP Weapon.MODE_CRU Weapon.MODE_CUT

Parameters:
mode - It can be
  • Weapon.MODE_IMP -> Impaling
  • Weapon.MODE_CRU -> Crushing
  • Weapon.MODE_CUT -> Cutting

getStringMode

public java.lang.String getStringMode()
Get selected mode for this weapon as a string.

Returns:
weapon mode

getRange

public int getRange()
The weapon range

Returns:
Weapon's range

getMode

public DamageMode getMode()
Get Selected Mode for this weapon.

Returns:
selected mode, ie:
  • cutting
  • impaling
  • crushing

getMinimalStrength

public int getMinimalStrength()
Get Minimal Strength to wear this weapon

Returns:
PCharacter must have at least this strength (ST) to wear this weapon

getAttacks

public java.lang.String[] getAttacks()
Return an array of String determining a long description for each available Attack

Returns:
Strings describing available attacks

getIndexAttacks

public int getIndexAttacks(DamageMode mode)
If getAttacks returns 3 different types of attacks, when you pass the mode for this weapon, ie: Weapon.MODE_IMP, this method returns the position of that mode in that array.

Parameters:
mode - The weapon mode as in Weapon (MODE_CRU, MODE_CUT, MODE_IMP)
Returns:
index of given weapon mode.

getSkill

public Skill getSkill()
Get Skill required to use this weapon

Returns:
An Skill object

isRanged

public boolean isRanged()
If this weapon is ranged

Returns:

isBalanced

public boolean isBalanced()
If this weapon need to get ready (not balanced).

Returns:
true, if this weapon is balanced.

isReady

public boolean isReady()
If this weapon is balanced, then returns true if it's also ready. Otherwise it's always ready.

Returns:
true, if this weapon is ready to use.

setWeaponReady

public void setWeaponReady(boolean isReady)
If current weapon is unbalanced, you may set its status here.

Parameters:
isReady - to set for this weapon

getAttackTypes

public WeaponAttack getAttackTypes()
Return Attack meta object

Returns:
Attack meta object

getDescription

public java.lang.String getDescription(java.lang.String divisor)
Get a long description of weapon.

Parameters:
divisor - Divisor character
Returns:
long description

canBeWorn

public boolean canBeWorn(AbstractPC character)
Description copied from class: AbstractItem
Return true if the character specified can wear the item (ie, has the required strength to lift the mace)

Overrides:
canBeWorn in class AbstractItem
Parameters:
character - that must wear the item
Returns:
true if the character specified can wear the item

getDescription

public java.lang.String getDescription()
Get long description of this weapon

Overrides:
getDescription in class AbstractItem
Returns:
detailed description of this weapon

wear

public boolean wear(PCharacter pc)
Polymorphic method to wear this AbstractItem

Overrides:
wear in class AbstractItem
Parameters:
pc - PCharacter that is going to wear this AbstractItem
Returns:
True if oggetto can be worn by PCharacter

unwear

public void unwear(PCharacter pc)
Unwear AbstractItem (polymorphic)

Overrides:
unwear in class AbstractItem
Parameters:
pc - PCharacter that is going to unwear this AbstractItem

getDamageType

public DamageType getDamageType()
Returns type of damage based on weapon mode.

Returns:
Either WeaponDamage.SWING or WeaponDamage.THRUST
See Also:
WeaponDamage

getDamageModifier

public int getDamageModifier()
Returns modifier of damage based on weapon mode.

Returns:
modifier of damage, given weapon mode

getBasicDamage

public int getBasicDamage(int characterStrength)
Get Basic Damage for weapon

Parameters:
characterStrength - Strength (ST) of character who wears this weapon
Returns:
basic damage (always > 0)

getMaxDamage

public int getMaxDamage()
Get Weapon's max damage. This is an intrisic weapon attribute. To get effective maximum damage for a weapon wore by a character, use getMaxDamage(int).

Returns:
generic maximum weapon's damage

getMaxDamage

public int getMaxDamage(int characterStrength)
Get Maximum Damage for this weapon. If weapon has a maximum damage, return max between that and damage. Else return damage.

Parameters:
characterStrength - Strength (ST) of character who wears this weapon
Returns:
maximum damage (always >= basic damage)

toString

public java.lang.String toString()
Name of weapon

Overrides:
toString in class AbstractItem
Returns:
Name of weapon

main

public static void main(java.lang.String[] args)
Deprecated. 

Test random creation

Parameters:
args -

Java Universal Role Playing Engine Version 0.3.9

Copyright ? 2010 http://jurpe.sourceforge.net/ All Rights Reserved.