wyvern.lib.classes.town
Class Converter

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.lib.classes.StaticObject
              extended bywyvern.lib.classes.town.Converter
All Implemented Interfaces:
Broadcaster, GameObject, HookCallback, MethodHookable, PropertyList

public class Converter
extends StaticObject
implements HookCallback

A magical device that can convert currencies.

Version:
1.0, Sep 18, 2000
Author:
Steve Yegge

Field Summary
static int GOLD_PER_PLAT
           
static int SILVER_PER_GOLD
           
static int SILVER_PER_PLAT
           
 
Fields inherited from class wyvern.kernel.maps.MapObject
IN_MAP_EDITOR, listenerList_
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Constructor Summary
Converter()
           
 
Method Summary
 void buyGem(java.lang.String src_type, java.lang.String dest_type, GameObject source, GameObject dest)
          Buys a gem.
 void convertCoins(java.lang.String src_type, java.lang.String dest_type, GameObject source, GameObject dest)
          Does a currency conversion.
 void convertGold(java.lang.String dest_type, GameObject source, GameObject dest)
          Converts gold to silver or platinum.
 void convertPlatinum(java.lang.String dest_type, GameObject source, GameObject dest)
          Converts platinum to gold or silver.
 void convertSilver(java.lang.String dest_type, GameObject source, GameObject dest)
          Converts silver to X.
 int getValue(java.lang.String src_type, GameObject source)
          Returns the value of the source currency, in gold coins.
 void hookEvent(java.lang.String hookName, CommandEvent ev)
          Converts currencies when they're dropped.
 void initialize()
          Initializes the object's default properties.
 void setMap(GameMap map, int x, int y)
          When placed in a map, get on drop-hook.
 
Methods inherited from class wyvern.kernel.maps.MapObject
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMethodHook, addMotionTracker, addObjectTracker, addPrefix, addSuffix, addToMap, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, destroy, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getImageDescriptors, getLayer, getLocations, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getTile, getValue, getWeight, groupString, inContainer, initLocs, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMethodHook, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, runMethodHook, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDefaultBitmap, setDefaultCategory, setDefaultDesc, setDefaultImage, setDefaultIntProperty, setDefaultLayer, setDefaultMaterial, setDefaultProperty, setDefaultShortDesc, setDirection, setImage, setImage, setLayer, setLocations, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport, toString, updateMapLocation
 
Methods inherited from class wyvern.kernel.properties.PList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wyvern.lib.PropertyList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, getDoubleProperty, getInheritedProperty, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 

Field Detail

SILVER_PER_GOLD

public static final int SILVER_PER_GOLD
See Also:
Constant Field Values

GOLD_PER_PLAT

public static final int GOLD_PER_PLAT
See Also:
Constant Field Values

SILVER_PER_PLAT

public static final int SILVER_PER_PLAT
See Also:
Constant Field Values
Constructor Detail

Converter

public Converter()
Method Detail

initialize

public void initialize()
Description copied from interface: GameObject
Initializes the object's default properties. Any GameObject implementation that wishes to initialize itself should do so here, rather than in the constructor. This is because nearly all game objects inherit from an archetype, and the archetype parent pointer isn't set until the object's constructor finishes. This is a good place to add any class-default properties for an object - properties that the object gets regardless of which archetype it inherits from. WARNING: don't forget to call the superclass' initialize() method, or the object may not function properly. For instance, it won't become animated even if it specifies animation parameters in the archetype.

Specified by:
initialize in interface GameObject
Overrides:
initialize in class StaticObject

setMap

public void setMap(GameMap map,
                   int x,
                   int y)
When placed in a map, get on drop-hook.

Specified by:
setMap in interface GameObject
Overrides:
setMap in class MapObject

hookEvent

public void hookEvent(java.lang.String hookName,
                      CommandEvent ev)
Converts currencies when they're dropped.

Specified by:
hookEvent in interface HookCallback
Parameters:
hookName - e.g. "dropPostHook"
ev - the CommandEvent encapsulating the event parameters

convertCoins

public void convertCoins(java.lang.String src_type,
                         java.lang.String dest_type,
                         GameObject source,
                         GameObject dest)
Does a currency conversion.

Parameters:
src_type - the archetype path of the "from" currency
dest_type - the arch path of the thing we're converting to
source - the currency they dropped
dest - the replacement object

convertSilver

public void convertSilver(java.lang.String dest_type,
                          GameObject source,
                          GameObject dest)
Converts silver to X.

Parameters:
dest_type - the arch path of the thing we're converting to
source - the currency they dropped
dest - the replacement object to set the quantity on

convertGold

public void convertGold(java.lang.String dest_type,
                        GameObject source,
                        GameObject dest)
Converts gold to silver or platinum.

Parameters:
dest_type - the arch path of the coin type to convert to
source - the gold they dropped
dest - the destination object

convertPlatinum

public void convertPlatinum(java.lang.String dest_type,
                            GameObject source,
                            GameObject dest)
Converts platinum to gold or silver.

Parameters:
dest_type - gold or silver
source - the platinum
dest - the gold or silver

buyGem

public void buyGem(java.lang.String src_type,
                   java.lang.String dest_type,
                   GameObject source,
                   GameObject dest)
Buys a gem.

Parameters:
src_type - the archetype path of the "from" currency
dest_type - the arch path of the thing we're converting to
source - the currency they dropped
dest - the replacement object

getValue

public int getValue(java.lang.String src_type,
                    GameObject source)
Returns the value of the source currency, in gold coins.

Parameters:
src_type - the archetype of the source
source - coins of some sort
Returns:
the value in gold, rounded off (for silver)