wyvern.lib.classes.magic
Class Element

java.lang.Object
  extended bywyvern.lib.classes.magic.Element

public class Element
extends java.lang.Object

Typesafe enum that represents the eight spell Elements, as well as multi-Element combinations like "Fire and Water".

There are eight single Elements, and multi-Elements can be created with any combination of up to 8 different single Elements. There are:

So there are a total of 255 possible Element combos, including singles, that you can choose from when constructing a spell. This class defines public constants for all of the 1-element and 2-element combos; you have to call getCombo() to get an Element representing any combination of three or more.

Note that each Element has an opposite: FIRE and WATER are opposing elements, as are EARTH and AIR, LIFE and DEATH, and MIND and SPIRIT.

In practice, it's very rare to have spells that need more than two elements.

Version:
1.0, Nov 05, 2003
Author:
Steve Yegge

Field Summary
static Element AIR
           
static Element AIR_AND_DEATH
           
static Element AIR_AND_LIFE
           
static Element AIR_AND_MIND
           
static Element AIR_AND_SPIRIT
           
static Element DEATH
           
static Element DEATH_AND_MIND
           
static Element DEATH_AND_SPIRIT
           
static Element EARTH
           
static Element EARTH_AND_AIR
           
static Element EARTH_AND_DEATH
           
static Element EARTH_AND_LIFE
           
static Element EARTH_AND_MIND
           
static Element EARTH_AND_SPIRIT
           
static Element[] ELEMENTS
           
static Element FIRE
           
static Element FIRE_AND_AIR
           
static Element FIRE_AND_DEATH
           
static Element FIRE_AND_EARTH
           
static Element FIRE_AND_LIFE
           
static Element FIRE_AND_MIND
           
static Element FIRE_AND_SPIRIT
           
static Element FIRE_AND_WATER
           
static Element LIFE
           
static Element LIFE_AND_DEATH
           
static Element LIFE_AND_MIND
           
static Element LIFE_AND_SPIRIT
           
static Element MIND
           
static Element MIND_AND_SPIRIT
           
static Element SPIRIT
           
static Element WATER
           
static Element WATER_AND_AIR
           
static Element WATER_AND_DEATH
           
static Element WATER_AND_EARTH
           
static Element WATER_AND_LIFE
           
static Element WATER_AND_MIND
           
static Element WATER_AND_SPIRIT
           
 
Method Summary
 java.lang.String getCapName()
          Returns the capitalized name for this Element, e.g.
static Element getElement(java.lang.String[] names)
          Returns the single or combo element specified by a list of Element names.
 java.lang.String getName()
          Returns the Element name, lowercased.
 java.util.List getNames()
          Returns the List of names for this element.
 java.util.List getSkillNames()
          Returns the list of skill names for this Element.
 boolean includes(Element single)
          Returns true if the passed Element includes the specified single Elements.
 boolean isMulti()
          Returns true if this is a "multi" (i.e. combo) element, such as "Fire and Water", or "Air, Earth and Mind".
static boolean isValidName(java.lang.String name)
          Returns true if the passed element name is one of the eight valid single-element names.
static void main(java.lang.String[] args)
          Tests out creating and using multi-element combinations.
 java.lang.String toString()
          Returns the Element name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRE

public static final Element FIRE

WATER

public static final Element WATER

EARTH

public static final Element EARTH

AIR

public static final Element AIR

LIFE

public static final Element LIFE

DEATH

public static final Element DEATH

MIND

public static final Element MIND

SPIRIT

public static final Element SPIRIT

ELEMENTS

public static final Element[] ELEMENTS

FIRE_AND_WATER

public static final Element FIRE_AND_WATER

FIRE_AND_EARTH

public static final Element FIRE_AND_EARTH

FIRE_AND_AIR

public static final Element FIRE_AND_AIR

FIRE_AND_LIFE

public static final Element FIRE_AND_LIFE

FIRE_AND_DEATH

public static final Element FIRE_AND_DEATH

FIRE_AND_MIND

public static final Element FIRE_AND_MIND

FIRE_AND_SPIRIT

public static final Element FIRE_AND_SPIRIT

WATER_AND_EARTH

public static final Element WATER_AND_EARTH

WATER_AND_AIR

public static final Element WATER_AND_AIR

WATER_AND_LIFE

public static final Element WATER_AND_LIFE

WATER_AND_DEATH

public static final Element WATER_AND_DEATH

WATER_AND_MIND

public static final Element WATER_AND_MIND

WATER_AND_SPIRIT

public static final Element WATER_AND_SPIRIT

EARTH_AND_AIR

public static final Element EARTH_AND_AIR

EARTH_AND_LIFE

public static final Element EARTH_AND_LIFE

EARTH_AND_DEATH

public static final Element EARTH_AND_DEATH

EARTH_AND_MIND

public static final Element EARTH_AND_MIND

EARTH_AND_SPIRIT

public static final Element EARTH_AND_SPIRIT

AIR_AND_LIFE

public static final Element AIR_AND_LIFE

AIR_AND_DEATH

public static final Element AIR_AND_DEATH

AIR_AND_MIND

public static final Element AIR_AND_MIND

AIR_AND_SPIRIT

public static final Element AIR_AND_SPIRIT

LIFE_AND_DEATH

public static final Element LIFE_AND_DEATH

LIFE_AND_MIND

public static final Element LIFE_AND_MIND

LIFE_AND_SPIRIT

public static final Element LIFE_AND_SPIRIT

DEATH_AND_MIND

public static final Element DEATH_AND_MIND

DEATH_AND_SPIRIT

public static final Element DEATH_AND_SPIRIT

MIND_AND_SPIRIT

public static final Element MIND_AND_SPIRIT
Method Detail

toString

public java.lang.String toString()
Returns the Element name. (lowercase)


getName

public java.lang.String getName()
Returns the Element name, lowercased. For multi-Element pairs, returns the two names with "and" in between, e.g. "fire and water". For three or more multi-Elements, they take the form "fire, water, air, mind and death". The element names for combos are always sorted in this order: fire, water, earth, air, life, death, mind, spirit.


getNames

public java.util.List getNames()
Returns the List of names for this element.

Returns:
a read-only List of lowercased names like "fire" and "spirit". For single Elements, returns a list of length 1, 2 if there are 2 elements, up to eight.

getSkillNames

public java.util.List getSkillNames()
Returns the list of skill names for this Element.

Returns:
a read-only List containing one or more lowercased skill names, e.g. "sk-fire" and "sk-mind".

getCapName

public java.lang.String getCapName()
Returns the capitalized name for this Element, e.g. "Fire", "Water and Life", "Air, Earth and Death".


includes

public boolean includes(Element single)
Returns true if the passed Element includes the specified single Elements. Won't work properly if you pass in a combo Element like FIRE_AND_AIR.

Parameters:
single - a single element like FIRE, or MIND
Returns:
true if this Element is a single that's the same as the passed Element, or a combo that contains the passed Element.

isValidName

public static boolean isValidName(java.lang.String name)
Returns true if the passed element name is one of the eight valid single-element names.

Parameters:
name - a lowercased, single element name like "fire"
Returns:
true if it's a valid Element name

isMulti

public boolean isMulti()
Returns true if this is a "multi" (i.e. combo) element, such as "Fire and Water", or "Air, Earth and Mind".


getElement

public static Element getElement(java.lang.String[] names)
Returns the single or combo element specified by a list of Element names.

Parameters:
names - an array of element names. None of the names can be repeated, but they can be in any order. The array can have up to 8 names in it, and they must all be valid element names from this list: "fire", "water", "earth", "air", "life", "death", "mind", "spirit".
Throws:
java.lang.IllegalArgumentException - if any of the element names are invalid, or the array null or is of length zero, or if any of the names are repeated.

main

public static void main(java.lang.String[] args)
Tests out creating and using multi-element combinations.