jurpe.items
Class Weapon

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

public class Weapon
extends BasicItem

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:
BasicItem, Serialized Form

Constructor Summary
Weapon(java.lang.String name, jurpe.items.Attack att, int cost, int weight, int maxDamage, int minStrength, Skill skl)
          Constructor
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)
          Constructor
 
Method Summary
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
 jurpe.items.Attack 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.
 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 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 BasicItem (polymorphic)
 boolean wear(PCharacter pc)
          Polymorphic method to wear this BasicItem
 
Methods inherited from class jurpe.items.BasicItem
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,
              jurpe.items.Attack att,
              int cost,
              int weight,
              int maxDamage,
              int minStrength,
              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

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)
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
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

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

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 jurpe.items.Attack 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

getDescription

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

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

wear

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

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

unwear

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

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

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 BasicItem
Returns:
Name of weapon

main

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

Test random creation

Parameters:
args -

Jurpe - Java Universal Role Playing Engine - http://jurpe.sourceforge.net