org.starhope.appius.game.intangible
Class AvatarBase

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.util.BaseDatum
          extended by org.starhope.appius.game.intangible.AvatarBase
All Implemented Interfaces:
com.sun.sgs.app.ManagedObject, Externalizable, Serializable, CastsToJSON

public class AvatarBase
extends BaseDatum

Author:
brpocock
See Also:
Serialized Form

Field Summary
private  com.sun.sgs.app.ManagedReference<Domain> domain
          The domain in which this type of avatar can exist
private  String filename
          The filename of the model (e.g.
private  HashSet<ItemTemplate> itemsApply
          This is a set of items which apply to this type of avatar, regardless of other limitations.
private static long serialVersionUID
           
private  boolean specialEquipmentRequired
          Most avatars in a domain are assumed to have common equipment.
 
Fields inherited from class org.starhope.appius.util.BaseDatum
database_id
 
Constructor Summary
AvatarBase()
          Create a neutral, empty object.
AvatarBase(org.json.JSONObject object)
          Instantiate this object based upon a JSON object
 
Method Summary
 boolean canEquip(SpecificItem which)
          Identify whether an item could potentially be worn by avatars with this AvatarBase.
static AvatarBase get(String id)
           
 Domain getDomain()
          Gets the domain in which this avatar base model can be instantiated (e.g.
 String getFilename()
           
protected  String[] getUniqueBoundName()
           
 boolean isSpecialEquipmentRequired()
          -- avatar_bases.special_equip means: This avatar base does not follow the usual pattern for other avatars in this domain, so items that are otherwise capable of being universally equipped, cannot be.
 void set(org.json.JSONObject o)
          This method will attempt to set the data contents of this object to the values derived from the JSON object being passed-in.
 void setDomain(Domain domain)
          Sets the domain in which this avatar base model can be instantiated.
 void setFilename(String filename)
           
 void setItemEquippable(ItemTemplate item)
          Inform the AvatarBase that it is now allowed to equip items following the given template.
 void setSpecialEquipmentRequired(boolean specialEquipmentRequired)
          -- avatar_bases.special_equip means: This avatar base does not follow the usual pattern for other avatars in this domain, so items that are otherwise capable of being universally equipped, cannot be.
 org.json.JSONObject toJSON()
          This returns a copy of the object's data cast into a JSON form.
 
Methods inherited from class org.starhope.appius.util.BaseDatum
changed, commitToDatabase, delete, equals, flush, get, get, getID, readExternal, refJSON, setID, sqlDateTime, writeExternal
 
Methods inherited from class org.starhope.appius.util.ManagedReferenceHolder
deref, setRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

domain

private com.sun.sgs.app.ManagedReference<Domain> domain
The domain in which this type of avatar can exist


filename

private String filename
The filename of the model (e.g. flash file) for this type of avatar. Note: 50 char limit.


itemsApply

private HashSet<ItemTemplate> itemsApply
This is a set of items which apply to this type of avatar, regardless of other limitations.


specialEquipmentRequired

private boolean specialEquipmentRequired
Most avatars in a domain are assumed to have common equipment. If this isn't true, this base of avatars can set this flag and use the itemsApply list to enumerate which items can actually be equipped.

Constructor Detail

AvatarBase

public AvatarBase()
Create a neutral, empty object.


AvatarBase

public AvatarBase(org.json.JSONObject object)
Instantiate this object based upon a JSON object

Parameters:
object - the JSON data to use
See Also:
set(JSONObject)
Method Detail

get

public static AvatarBase get(String id)
                      throws RuntimeException,
                             NotFoundException
Parameters:
id - database ID
Returns:
AvatarBase object
Throws:
NotFoundException - if the object couldn't be loaded
RuntimeException - if something strange and bad happens

canEquip

public boolean canEquip(SpecificItem which)
                 throws GameLogicException
Identify whether an item could potentially be worn by avatars with this AvatarBase.

Parameters:
which - the item which we want to know whether it can be worn
Returns:
true, if this AvatarBase can wear the specified item
Throws:
GameLogicException - if the item comes from another Domain

getDomain

public Domain getDomain()
Gets the domain in which this avatar base model can be instantiated (e.g. Tootsville)

Returns:
the Braque domain object

getFilename

public String getFilename()
Returns:
the filename (URL part) of the avatar base model

getUniqueBoundName

protected String[] getUniqueBoundName()
Overrides:
getUniqueBoundName in class BaseDatum
Returns:
A string array of names which uniquely identify this data object. There may be only one name, if that is appropriate for this class (as it usually is)
See Also:
BaseDatum.getUniqueBoundName()

isSpecialEquipmentRequired

public boolean isSpecialEquipmentRequired()
-- avatar_bases.special_equip means: This avatar base does not follow the usual pattern for other avatars in this domain, so items that are otherwise capable of being universally equipped, cannot be. Only items which are specifically mentioned for equipping to this avatar in avatar_items_apply will be permitted. For example: in Tootsville, non-elephant avatars would require this flag.

Returns:
true if this avatar requires special equipment

set

public void set(org.json.JSONObject o)
Description copied from interface: CastsToJSON
This method will attempt to set the data contents of this object to the values derived from the JSON object being passed-in. All exceptions are ignored, but any errors in the JSON data could cause the command to fail, completely or partially.

Specified by:
set in interface CastsToJSON
Overrides:
set in class BaseDatum
Parameters:
o - The JSON object containing a the new data for this object.
See Also:
BaseDatum.set(org.json.JSONObject)

setDomain

public void setDomain(Domain domain)
Sets the domain in which this avatar base model can be instantiated.

Parameters:
domain - the server domain (e.g. Tootsville)

setFilename

public void setFilename(String filename)
                 throws DataException
Parameters:
filename - the filename (URL part) of the avatar base model
Throws:
DataException - if the filename is over 50 characters

setItemEquippable

public void setItemEquippable(ItemTemplate item)
Inform the AvatarBase that it is now allowed to equip items following the given template.

Parameters:
item - The item template

setSpecialEquipmentRequired

public void setSpecialEquipmentRequired(boolean specialEquipmentRequired)
-- avatar_bases.special_equip means: This avatar base does not follow the usual pattern for other avatars in this domain, so items that are otherwise capable of being universally equipped, cannot be. Only items which are specifically mentioned for equipping to this avatar in avatar_items_apply will be permitted. For example: in Tootsville, non-elephant avatars would require this flag.

Parameters:
specialEquipmentRequired - whether this avatar requires special items/costumes/&c. in order to equip them.

toJSON

public org.json.JSONObject toJSON()
Description copied from interface: CastsToJSON
This returns a copy of the object's data cast into a JSON form.

Specified by:
toJSON in interface CastsToJSON
Overrides:
toJSON in class BaseDatum
Returns:
The string representing this object in JSON format
See Also:
CastsToJSON.toJSON()