wyvern.lib.classes.random
Class RandomItem

java.lang.Object
  extended bywyvern.lib.classes.random.RandomItem

public class RandomItem
extends java.lang.Object

Class to generate random items of various types. Reads all the generatable archetypes in when the game starts up. Knows how to generate items of different levels, including adding enchantments.

Version:
1.0, Apr 26, 2001
Author:
Steve Yegge

Constructor Summary
RandomItem()
           
 
Method Summary
static void main(java.lang.String[] args)
          Tests the item generator.
static GameObject randomItem(int level)
          Generates a random item of the passed level, with the default chance of the item being cursed.
static GameObject randomItem(int level, int curseChance)
          Generates a random item of the passed level.
static GameObject randomItem(int level, java.lang.String stype)
          Generates a random item of the passed level, with the default chance of generating a cursed item.
static GameObject randomItem(int level, java.lang.String stype, int curseChance)
          Generates a random item of the passed level.
static Archetype randomItemOfLevelAndType(int level, java.lang.String type)
          Returns an archetype chosen from a specific list, given the type and level.
static Archetype randomItemOfLevelAndType(int level, java.lang.String stype, boolean useMagic)
          Returns an archetype chosen from a specific list, given the type and level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomItem

public RandomItem()
Method Detail

randomItem

public static GameObject randomItem(int level)
Generates a random item of the passed level, with the default chance of the item being cursed.

Parameters:
level - the level of item to generate (1-20)

randomItem

public static GameObject randomItem(int level,
                                    int curseChance)
Generates a random item of the passed level.

Parameters:
level - the level of item to generate
curseChance - the chance the item should be cursed, -1 to use the default.
Returns:
a random item - can be null if something went wrong.

randomItem

public static GameObject randomItem(int level,
                                    java.lang.String stype,
                                    int curseChance)
Generates a random item of the passed level.

Parameters:
level - the level of item to generate
stype - the type of item, from the following list: "weapon", "armor", "misc", "treasure", "spellbook", "ring", "wand", "potion", "scroll". "ring" generates rings and amulets, and "wand" generates wands, rods and magical staves.
curseChance - the percentage chance in 100 that the item should be cursed, -1 to use the default chance.
Returns:
a random item

randomItem

public static GameObject randomItem(int level,
                                    java.lang.String stype)
Generates a random item of the passed level, with the default chance of generating a cursed item.

Parameters:
level - the level of item to generate
stype - the type of item, from the following list: "weapon", "armor", "misc", "treasure", "spellbook", "ring", "wand", "potion", "scroll". "ring" generates rings and amulets, and "wand" generates wands, rods and magical staves.
Returns:
a random item

randomItemOfLevelAndType

public static Archetype randomItemOfLevelAndType(int level,
                                                 java.lang.String type)
Returns an archetype chosen from a specific list, given the type and level. For certain types (e.g. weapons, armor) it has a chance of generating an enchanted item of the desired level, by starting with a nonmagical base item of a lower level.

Parameters:
level - the level of item to choose (after random adjustment). Doesn't work for "treasure" - call RandomTreasure.randomTreasure() for that.
type - the item type/category

randomItemOfLevelAndType

public static Archetype randomItemOfLevelAndType(int level,
                                                 java.lang.String stype,
                                                 boolean useMagic)
Returns an archetype chosen from a specific list, given the type and level.

Parameters:
level - the level of item to choose (after random adjustment). Doesn't work for "treasure" - call RandomTreasure.randomTreasure() for that.
stype - the item type/category
useMagic - true to have a chance of generating a magically enchanted item by using a nonmagic item as a base. If false, it will only return archetypes it finds in the list.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Tests the item generator.

Throws:
java.lang.Exception