org.globalse.arena.sword.engine
Class Adventurer

java.lang.Object
  |
  +--org.globalse.arena.frag.objects.FRAGObject
        |
        +--org.globalse.arena.sword.engine.Adventurer

public class Adventurer
extends FRAGObject

The Adventurer represents the player's SWORD Character.

See Also:
FRAGObject, Sword, Serialized Form

Fields inherited from class org.globalse.arena.frag.objects.FRAGObject
controller, gameName, influenceRange, objectName, owner, position, visibilityRange
 
Constructor Summary
Adventurer()
           
 
Method Summary
 void actionEvent(ObjectActionEvent event)
          Processes the ObjectActionEvents that the ObjectManager receives for this object.
 MathVector checkCollision(java.lang.String other, MathVector oldPos, MathVector delta)
          Called whenever another object has changed its position to allow the current object to react.
 void controlAcquired()
          Called whenever the current peer has acquired control over the object.
 void controlLost()
          Called when the peer decides or is forced to release control over an object.
 void draw(DrawManager drawManager)
          Draws the Adventurer on the map/screen, according to his current coordinates
 void drop(java.lang.String itemName)
          Drops the selected item on the map and removes it from the adventurer's inventory.
 double getCollisionSphere()
          Returns the collision sphere, the Adventurer has around him
 java.lang.String getFocusedObject()
          Returns the object, that the adventurer is currently looking at
 long getHealth()
          Returns the Adventurer's health value
 double getHealthMax()
          Returns the Adventurer's max health value
 java.awt.Image getImage()
          Returns the Adventurer's image, stored with all other object images in the IconLibrary
 java.util.Set getInventory()
          Returns the Adventurer's inventory property, a Set where all items are stored
 long getInventoryMax()
          Returns the max number of items that Adventurer may carry
 long getMagicPower()
          Returns the Adventurer's magic power value
 long getMana()
          Returns the Adventurer's mana value
 long getManaMax()
          Returns the Adventurer's max mana value
 long getStrength()
          Returns the Adventurer's strength value
 void increaseHealth(double value)
          Increases Adventurer's health according to the specified value
 void increaseHealthMax(double value)
          Increases Adventurer's max health according to the specified value
 void increaseInventoryMax(double value)
          Increases Adventurer's max number of allowed inventory items according to the specified value
 void increaseMagicPower(double value)
          Increases Adventurer's magic power according to the specified value
 void increaseMana(double value)
          Increases Adventurer's mana according to the specified value
 void increaseManaMax(double value)
          Increases Adventurer's max mana according to the specified value
 void increaseStrength(double value)
          Increases Adventurer's strength according to the specified value
 void init(java.lang.String gameName, java.lang.String objectName)
          The constructor creates a new adventurer object with the default properties
 void init(java.lang.String gameName, java.lang.String objectName, double health, double healthMax, double mana, double manaMax, int magicPower, int inventoryMax, double strength, double influenceRange, double visibilityRange)
          The constructor creates a new adventurer object, depending on the following parameters
 boolean isItemInInventory(java.lang.String itemName)
          Checks if the asked item is contained in the inventory.
 void lookAt(java.lang.String object)
          Gets information for the object the adventurer is looking at.
 void moveToPosition(MathVector pos)
          Causes the adventurer to start moving towards the specified position.
 boolean pickUp(java.lang.String itemName)
          Picks up an item for the adventurer and adds it to his/her inventory.
 void rotate(double speed)
          Causes the adventurer to start or stop rotating.
 void setHealth(long value)
          Sets Adventurer's health according to the specified value
 void setHealthMax(long value)
          Sets Adventurer's max health according to the specified value
 void setInventoryMax(long value)
          Sets max numer of items in Adventurer's inventory according to the specified value
 void setMagicPower(long value)
          Sets Adventurer's magic power according to the specified value
 void setMana(long value)
          Sets Adventurer's mana according to the specified value
 void setManaMax(long value)
          Sets Adventurer's max mana according to the specified value
 void setStrength(long value)
          Sets Adventurer's strength according to the specified value
 boolean useItem(java.lang.String item)
          Provides a service for the adventurer to use the selected item.
 boolean useItemWith(java.lang.String itemName, java.lang.String target)
          Provides a service for the adventurer to use the selected item with another item or adventurer.
 void walk(double speed)
          Causes the adventurer to start moving forward or backward, or to stop moving.
 
Methods inherited from class org.globalse.arena.frag.objects.FRAGObject
checkAndResetMark, checkMark, clone, getGameManager, getInfluenceRange, getObjectManager, getObjectName, getPosition, killed, mark, newerVersion, setInfluenceRange, setPosition
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Adventurer

public Adventurer()
Method Detail

init

public void init(java.lang.String gameName,
                 java.lang.String objectName,
                 double health,
                 double healthMax,
                 double mana,
                 double manaMax,
                 int magicPower,
                 int inventoryMax,
                 double strength,
                 double influenceRange,
                 double visibilityRange)
The constructor creates a new adventurer object, depending on the following parameters
Parameters:
health - adventurer's current health
healthMax - adventurer's curretn maximum health
mana - adventurer's current mana
manaMax - adventurer's current maximum mana
magicPower - adventurer's current magic power ability status
inventoryMax - max number of items allowed
strength - adventurer's strength

init

public void init(java.lang.String gameName,
                 java.lang.String objectName)
The constructor creates a new adventurer object with the default properties

moveToPosition

public void moveToPosition(MathVector pos)
Causes the adventurer to start moving towards the specified position. When the adventurer arrives at that position, he stops moving.
Parameters:
pos - the target position of the adventurer

walk

public void walk(double speed)
Causes the adventurer to start moving forward or backward, or to stop moving.
Parameters:
speed - the speed of motion of the adventurer. (>0: forward, <0: backward)
Preconditions:
Math.abs(speed) <= 1

rotate

public void rotate(double speed)
Causes the adventurer to start or stop rotating.
Parameters:
speed - the speed of rotation of the adventurer. (>0: counterclockwise, <0: clockwise)
Preconditions:
Math.abs(speed) <= 1

pickUp

public boolean pickUp(java.lang.String itemName)
Picks up an item for the adventurer and adds it to his/her inventory. Checks max number of all carried items before adding a new one.
Parameters:
itemName - the new item that the adventurer wants to pick up
Returns:
Returns false if the inventory is full.
Preconditions:
(item != null) && (! inventory.contains(item))
See Also:
Item, #inventory

lookAt

public void lookAt(java.lang.String object)
Gets information for the object the adventurer is looking at. This could be another adventurer or an item.
Parameters:
object - the object the adventurer is looking at
See Also:
FRAGObject

getFocusedObject

public java.lang.String getFocusedObject()
Returns the object, that the adventurer is currently looking at
Returns:
Returns focusesObject

drop

public void drop(java.lang.String itemName)
Drops the selected item on the map and removes it from the adventurer's inventory. After the item is dropped down, it becomes visible again to all other adventurers.
Parameters:
itemName - the item the adventurer wants to drop down
Preconditions:
inventory.contains(itemName) = true
See Also:
org.globalse.arena.frag.objects.Item, #inventory

useItem

public boolean useItem(java.lang.String item)
Provides a service for the adventurer to use the selected item. This calls item. useWith(self), i.e. the first argument is the active object and the Adventurer object is the passive object.
Parameters:
item - the item the adventurer wants to use
Returns:
Returns false if the item couldn't be used
See Also:
Item#useWith(FRAGObject object), FRAGObject

useItemWith

public boolean useItemWith(java.lang.String itemName,
                           java.lang.String target)
Provides a service for the adventurer to use the selected item with another item or adventurer. This calls item.useWith(object), i.e. the first argument is the active and the second argument is the passive object. This method checks wheter an attempt is made to use ConsumableItem on target other than this Adventurer and returns false in that case. It further checks if an attempt is made to use Weapon on a ConsumableItem returns false in that case too. In both cases the status of the target remains unaffected.
Parameters:
item - the item the adventurer wants to use
object - the object the adventurer selects to use the item with
Returns:
Returns false if the item couldn't be used with the selected object
See Also:
Item#useWith(FRAGObject object), FRAGObject

setHealth

public void setHealth(long value)
Sets Adventurer's health according to the specified value
Parameters:
value - Adventurer's new health value
Preconditions:
value >= 0 and value <= healthMax

increaseHealth

public void increaseHealth(double value)
Increases Adventurer's health according to the specified value
Parameters:
value - Adventurer's new health value
Postconditions:
0 < = health <= healthMax

getHealth

public long getHealth()
Returns the Adventurer's health value
Returns:
Adventurer's current health value

setHealthMax

public void setHealthMax(long value)
Sets Adventurer's max health according to the specified value
Parameters:
value - Adventurer's new max health value
Preconditions:
value >= 0

increaseHealthMax

public void increaseHealthMax(double value)
Increases Adventurer's max health according to the specified value
Parameters:
value - Adventurer's new health value
Postconditions:
0 <= healthMax

getHealthMax

public double getHealthMax()
Returns the Adventurer's max health value
Returns:
Adventurer's current max health value

setMana

public void setMana(long value)
Sets Adventurer's mana according to the specified value
Parameters:
value - Adventurer's new health value
Preconditions:
value >= 0 and value <= manaMax

increaseMana

public void increaseMana(double value)
Increases Adventurer's mana according to the specified value
Parameters:
value - Adventurer's new mana value
Postconditions:
0 < = mana <= manaMax

getMana

public long getMana()
Returns the Adventurer's mana value
Returns:
Adventurer's current mana value

setManaMax

public void setManaMax(long value)
Sets Adventurer's max mana according to the specified value
Parameters:
value - Adventurer's new max mana value
Preconditions:
value >= 0

increaseManaMax

public void increaseManaMax(double value)
Increases Adventurer's max mana according to the specified value
Parameters:
value - Adventurer's new max mana value
Postconditions:
0 < = mana

getManaMax

public long getManaMax()
Returns the Adventurer's max mana value
Returns:
Adventurer's current max mana value

setMagicPower

public void setMagicPower(long value)
Sets Adventurer's magic power according to the specified value
Parameters:
value - Adventurer's new magic power value
Preconditions:
value >= 0

increaseMagicPower

public void increaseMagicPower(double value)
Increases Adventurer's magic power according to the specified value
Parameters:
value - Adventurer's new magic power value
Postconditions:
0 < = magic power

getMagicPower

public long getMagicPower()
Returns the Adventurer's magic power value
Returns:
Adventurer's current magic power value

setInventoryMax

public void setInventoryMax(long value)
Sets max numer of items in Adventurer's inventory according to the specified value
Parameters:
value - Adventurer's new inventoryMax value
Preconditions:
value >= 0

increaseInventoryMax

public void increaseInventoryMax(double value)
Increases Adventurer's max number of allowed inventory items according to the specified value
Parameters:
value - Adventurer's new inventoryMax value
Postconditions:
0 < = inventoryMax

getInventoryMax

public long getInventoryMax()
Returns the max number of items that Adventurer may carry
Returns:
Adventurer's current inventoryMax value

setStrength

public void setStrength(long value)
Sets Adventurer's strength according to the specified value
Parameters:
value - Adventurer's new strength value
Preconditions:
value >= 0

increaseStrength

public void increaseStrength(double value)
Increases Adventurer's strength according to the specified value
Parameters:
value - Adventurer's new strength value
Postconditions:
0 < = strength

getStrength

public long getStrength()
Returns the Adventurer's strength value
Returns:
Adventurer's current strength value

getInventory

public java.util.Set getInventory()
Returns the Adventurer's inventory property, a Set where all items are stored
Returns:
Adventurer's current inventory Set

getImage

public java.awt.Image getImage()
Returns the Adventurer's image, stored with all other object images in the IconLibrary
Returns:
Adventurer's image from the IconLibrary
See Also:
IconLibrary

draw

public void draw(DrawManager drawManager)
Draws the Adventurer on the map/screen, according to his current coordinates
Parameters:
drawManager - an instance of the responisble DrawManager
Overrides:
draw in class FRAGObject
See Also:
DrawManager

isItemInInventory

public boolean isItemInInventory(java.lang.String itemName)
Checks if the asked item is contained in the inventory.
Parameters:
itemName - the item that is being checked
Returns:
false/true, depending on whether the item is contained in the inventory

checkCollision

public MathVector checkCollision(java.lang.String other,
                                 MathVector oldPos,
                                 MathVector delta)
Called whenever another object has changed its position to allow the current object to react.
Parameters:
object - the current instance of FRAGObject
other - the other instance of FRAGObject, that has changed its position
oldPos - the old Position (instanceOf MathVector)
delta - the delta vector, that the other instance has moved
Overrides:
checkCollision in class FRAGObject

controlAcquired

public void controlAcquired()
Called whenever the current peer has acquired control over the object.
Parameters:
object - the object that was taken in possession by the peer
Overrides:
controlAcquired in class FRAGObject
See Also:
FRAGObject

controlLost

public void controlLost()
Called when the peer decides or is forced to release control over an object.
Parameters:
object - the object that gets unbound from the peer
Overrides:
controlLost in class FRAGObject
See Also:
FRAGObject

getCollisionSphere

public double getCollisionSphere()
Returns the collision sphere, the Adventurer has around him
Returns:
collisionSphere the collisionSphere of this object

actionEvent

public void actionEvent(ObjectActionEvent event)
Processes the ObjectActionEvents that the ObjectManager receives for this object.
Parameters:
event - the event, that took place
Overrides:
actionEvent in class FRAGObject
See Also:
ObjectActionEvent



This page is hosted by the Chair for Applied Software Engineering of the Technische Universität München.
Imprint (Impressum)