Class Weapon
java.lang.Object
org.progettoedids.entities.Entity
org.progettoedids.entities.items.Item
org.progettoedids.entities.items.weapons.Weapon
- Direct Known Subclasses:
BrokenSword,FancySword,Rock
A Weapon is an instance of an Item additionally characterized by the damage the Weapon can deal and its usability level
which represents the maximum amount of times the Weapon can be used.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the Weapon can be collected from a Room of the LabyrinthintDecreases the usability level of the weapon by one.intReturns the amount of damage the Weapon deals on each attackintReturns the current usability level of the Weapon.toString()Methods inherited from class org.progettoedids.entities.Entity
getName, getSystemName, getUUID, setName
-
Field Details
-
damage
protected int damage -
usabilityLevel
protected int usabilityLevel
-
-
Constructor Details
-
Weapon
Initializes a Weapon.- Parameters:
systemName- The system name is used to uniquely identify a certain type of Weapon. Must not be nullname- The name is displayed to the user and is used to identify an instance of a Weapon by the user. Must not be nullweight- The weight of the Weapon. It must be a positive or zero integerdamage- The amount of damage dealt by a single use of the Weapon. Must be a positive or zero integerusabilityLevel- The amount of times the Weapon can be used. Must be a positive integer
-
-
Method Details
-
canBeCollected
public boolean canBeCollected()Returns whether the Weapon can be collected from a Room of the Labyrinth- Specified by:
canBeCollectedin classItem- Returns:
- Always true, unless overridden in a subclass
-
getDamage
public int getDamage()Returns the amount of damage the Weapon deals on each attack- Returns:
- The amount of damage
-
getUsabilityLevel
public int getUsabilityLevel()Returns the current usability level of the Weapon.- Returns:
- The usability level of the Weapon
-
decreaseUsabilityLevel
Decreases the usability level of the weapon by one.- Returns:
- The new usability level after the decrement
- Throws:
ExhaustedUsabilityException- when the weapon is completely worn
-
toString
-