mdh.hephaestus2
Class World

java.lang.Object
  |
  +--mdh.hephaestus2.World

public class World
extends Object

Game world model. Adventure has a reference to the World object as "world", or you can use World.getWorld() to get it. World contains the data model of the game and methods to access it - getStuff() is the most important of these.

Author:
Copyright © 2002 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>

Method Summary
 void addPlayer(Player pl)
          Adds a Player to the active players list.
 Object choice(ArrayList list)
          Returns a randomly selected item from a list, or null if the list is empty.
 int d(int s)
          Rolls one 's'-sided die and returns the roll.
 int d(int n, int s)
          Rols 'n' 's'-sided dice and returns the total.
 int d(String text)
          Rolls a "die text" in the form 1d6, 2d8+3, 3d10+-3, 1d6*5+2.
 int dXX()
          Returns an open-ended die roll for stat checks.
 Player getLeader()
          Returns the first Player in the party; many actions apply to the leader first.
 int getNPlayers()
          Returns the number of Players in the party.
 Player getPlayer(int i)
          Returns the 'i'th Player in the party.
 boolean getPlaying()
          Returns true if an adventure is loaded and the game is currently playing.
 Object getStuff(int id)
          Returns the Stuff with the given id, or null if it does not exist.
 Stuff getStuff(int id, int type)
          Returns the Stuff with the given id only if it is of 'type' (one of Global.TYPE_*) or a subtype, otherwise null.
 int getTurn()
          Returns the current game turn.
static World getWorld()
          Returns the World instance.
 void moveParty(int mapid, int x, int y, int facing, boolean teleport)
          Moves all members of the party to a new location.
 void removePlayer(Player pl)
          Removes a Player from the party.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWorld

public static World getWorld()
Returns the World instance.


addPlayer

public void addPlayer(Player pl)
               throws HephaestusException
Adds a Player to the active players list. This is automatically done for you when a Player object is created, but if you later remove a Player from the party, you can re-add it with addPlayer().

HephaestusException

choice

public Object choice(ArrayList list)
Returns a randomly selected item from a list, or null if the list is empty.


d

public int d(String text)
      throws HephaestusException
Rolls a "die text" in the form 1d6, 2d8+3, 3d10+-3, 1d6*5+2. Any number of +, *, or / operations can be listed after the dice, and they are performed in order left to right, not according to algebraic order. Subtraction is done as shown above, by adding a negative number.

HephaestusException

d

public int d(int s)
Rolls one 's'-sided die and returns the roll.


d

public final int d(int n,
                   int s)
Rols 'n' 's'-sided dice and returns the total.


dXX

public int dXX()
Returns an open-ended die roll for stat checks. Two 10-sided "dice" are rolled. If the total is 2-3 (3% chance), another dXX is rolled and subtracted from the total; if the total is 19-20 (3% chance), another dXX is rolled and added to the total. The normal way to check tasks is with code like:
if( getStat(whatever) + world.dXX() + modifiers > 20 )
Positive modifiers make the task easier, negative modifiers make it harder.


getLeader

public Player getLeader()
Returns the first Player in the party; many actions apply to the leader first.


getNPlayers

public int getNPlayers()
Returns the number of Players in the party.


getPlayer

public Player getPlayer(int i)
Returns the 'i'th Player in the party.


getPlaying

public boolean getPlaying()
Returns true if an adventure is loaded and the game is currently playing.


getStuff

public final Object getStuff(int id)
Returns the Stuff with the given id, or null if it does not exist.


getStuff

public final Stuff getStuff(int id,
                            int type)
Returns the Stuff with the given id only if it is of 'type' (one of Global.TYPE_*) or a subtype, otherwise null.


getTurn

public final int getTurn()
Returns the current game turn. If you assume that a turn is 1 minute long in game-world time (which is just slow enough that the user will notice the passage of time), there are 1440 turns per day. You might want to have time limits in your adventures, change map light levels and terrain tiles and opacity depending on the time of day, etc. The usual way to use it is like this:
 int startturn = // turn of day when the story starts - 6*60 for 6am, etc.
 int turn = game.getTurn();
 int day = (startturn+turn) / 1440;
 int turnofday = (startturn+turn) % 1440;
 int hour = turnofday / 60;
 int minute = turnofday % 60;
 


moveParty

public void moveParty(int mapid,
                      int x,
                      int y,
                      int facing,
                      boolean teleport)
               throws HephaestusException
Moves all members of the party to a new location.

HephaestusException

removePlayer

public void removePlayer(Player pl)
                  throws HephaestusException
Removes a Player from the party. The Player object still exists, and can be re-added later with addPlayer(), but until then will no longer move and act with the party.

On a game design note, please don't make heavy use of this. There's very little more annoying in console RPGs than players entering and leaving the party all the time - if you're one of us, stay in. And for Cthulhu's sake, don't repeat that pathetic "cute girl PC is poisoned/temporarily dead/being audited by the IRS, so we have to leave her behind and do an adventure without her" plot. Everyone will hate you if you do that, because it takes control away from the player, and it's sexist as all hell. Abduct the brainless bimbo boy PC, if you must.

HephaestusException