jAsea
Class jAseaRun

java.lang.Object
  |
  +--jAsea.jAseaRun

public class jAseaRun
extends java.lang.Object


Field Summary
(package private)  jAseaObject[] alrs
           
(package private)  jAseaParser[] commands
          Parsers for each task command
(package private)  java.lang.String[] dirnames
          An array of the cardinal direction names (Equals to dirnames4 or dirnames8, depending on the value of EightBitCompass)
(package private) static java.lang.String[] dirnames4
          An array of the cardinal direction names with a 4 point compass.
(package private) static java.lang.String[] dirnames8
          An array of the cardinal direction names with an 8 point compass.
(package private)  jAseaObject[] events
           
(package private)  jAseaObject game
          The game object itself.
(package private)  boolean gamerunning
          Whether the game is running or not
(package private)  jAseaObject global
          Copies of various fields of the "game" object.
(package private)  jAseaObject header
          Copies of various fields of the "game" object.
(package private)  jAseaDump jad
          Used to view an object in jAsea code
(package private)  jAseaWindow jaw
          Window where it gets input & displays output
(package private)  jAseaLibrary[] lib
          Parsers for each command in the standard library
(package private)  jAseaObject[] npcs
           
(package private)  jAseaObject[] objects
           
(package private)  PrintFilter os
          Filters the output created by the program by substituting variables, then ALRs, then releasing
(package private)  java.util.Hashtable parsedExpressions
          Maps strings of expressions used in TaskActions to objects of Expression class
(package private) static java.util.Random r
          Random Number Generator
(package private)  jAseaObject[] roomgroups
           
(package private)  jAseaObject[] rooms
           
(package private)  boolean showErrors
          Debugging flag.
(package private)  jAseaGameState state
          Current game state
(package private)  jAseaObject[] synonyms
           
(package private)  jAseaObject[] tasks
           
(package private)  jAseaObject[] vars
           
 
Constructor Summary
jAseaRun(java.lang.String filename)
          Constructor.
jAseaRun(java.lang.String filename, boolean interactive)
          Constructor.
 
Method Summary
(package private)  boolean canRunTask(int tasknum)
          Is the player in a room where the task can be run?
(package private)  boolean canSeeEvent(jAseaObject evt)
          Is the player in a room where s/he can see text from the event
(package private)  java.lang.String Complete(boolean b)
          String representation of a boolean.
(package private)  int ContainerObject(int i)
          The index of the 'i'th Container object.
(package private)  int DynamicObject(int i)
          The 'i'th dynamic object.
(package private)  int evalExprI(java.lang.String expr)
          Calculates the value of an integer expression
(package private)  java.lang.String evalExprS(java.lang.String expr)
          Calculates the value of an String expression NOT IMPLEMENTED AT PRESENT
(package private)  void EventMoveObject(int obj, int dest)
          Move an object from within an event
(package private)  void FinishEvent(jAseaObject evt, jAseaEventState es)
          Stop event, move to finished state or restart
(package private)  void go()
          Old main loop, obsolete
(package private)  void go2()
          Main Loop Should really be moved to UI code
(package private)  int IntegerVariable(int i)
          The 'i'th integer variable.
(package private)  int LieableObject(int i)
          The 'i'th lieable object.
(package private)  void look(boolean was_command)
          Print room description.
static void main(java.lang.String[] args)
          The main function.
(package private)  void MoveNPCToRoom(int npcnum, int roomnum)
          Move a non-player character to a room.
(package private)  void MoveObject(int obj, int v2, int v3)
          Move an object to a place
(package private)  void MovePlayerToRoom(int roomnum)
          Move player to specified room
(package private)  int NPCCount(int roomnum)
          Return the number of characters in the room, including the player.
(package private)  boolean NPCInRoom(int npc, int room)
          Is a specific non-player character in a specific room?
(package private)  java.lang.String NPCName(int i)
          Get a non-player character's name.
(package private)  boolean ObjectDirectlyInRoom(int objectnum, int room)
          Return whether or not an object is on the floor of a room
(package private)  boolean ObjectIndirectlyInRoom(int object, int room)
          Return whether an object is nested within a room - Directly in - on object indirectly in - in open object indirectly in - carried by NPC who is in said room
(package private)  boolean objectInPlace(int obj, int v2, int v3)
          Is an object in a certain place, state, or condition? This documentation needs more info on all the different states that can be checked.
(package private)  java.lang.String ObjectLocation(int obj)
          Show current location of object (Debug code only)
(package private)  java.lang.String ObjectName(int i)
          The name of a particular object.
(package private)  java.lang.String ObjectStateName(jAseaObject obj, int statenum)
          The name of a particular state of the particular object.
(package private)  void parseLoop(java.io.BufferedReader br)
          Old main loop, now obsolete
(package private)  boolean passTaskChar(int v1, int v2, int v3)
          Determine whether a restriction related to character passes or not
(package private)  boolean passTaskObjectLocation(int v1, int v2, int v3)
          Determine whether or not an ObjectLocation Restriction is true or not
(package private)  boolean passTaskObjectState(int v1, int v2)
          Determine whether a ObjectState Restriction passes or not
(package private)  boolean passTaskRestr(jAseaObject restr)
           
(package private)  boolean passTaskTaskState(int v1, int v2)
          Determine whether a restriction related to TaskState passes or not
(package private)  boolean passTaskVar(int v1, int v2, int v3, java.lang.String v4)
          Determine whether a restriction related to variable state passes or not.
(package private)  boolean PlayerInRoom(int room)
          Is the player in a specific room?
(package private)  void printContainerContents(int obj)
          Print a list of all objects in a container (For testing only, to be disabled in production releases, or at least restricted to debug mode.)
(package private)  void printNPCContents(int npcnum)
          Print NPC name & a list of all objects carried by, worn by, or part it.
(package private)  void printRoomContents(int room)
          Print all objects in a room (Debug code only)
(package private)  void printSurfaceContents(int obj)
          Print a list of all objects on a surface (For testing only, to be disabled in production releases, or at least restricted to debug mode.)
(package private)  int randomAdjacentRoomGroupMember(int room, int rg)
          Return a random RoomGroup member adjacent to a certain room.
(package private) static int randomInt(int low, int high)
          Return a random integer between low and high boundaries.
(package private)  int randomRoomGroupMember(int rg)
          Choose a random member of a RoomGroup
(package private)  boolean roomInRoomGroup(int roomnum, int rg)
          Returns whether a room is in a RoomGroup
(package private)  java.lang.String RoomName(int i)
          The short name of a room.
(package private)  void runChangeObjectStateAction(int v1, int v2)
          Change the status of an object
(package private)  void runChangeScoreAction(int tasknum, int v1)
          Changes current score (negative changes always used, positive scores only used once)
(package private)  void runChangeVariableAction(int v1, int v2, int v3, java.lang.String expr, int v5)
          Change the value of a variable
(package private)  void runEndGameAction(int v1, int v2, int v3)
          The end of game action.
(package private)  void runMoveNPCAction(int v1, int v2, int v3)
          Move the player or an NPC
(package private)  void runMoveObjectAction(int v1, int v2, int v3)
          Runs a MoveObject type TaskAction
(package private)  void runSetTaskAction(int v1, int v2)
          Attempt to run another task
(package private)  boolean runTask(int tasknum, boolean forwards)
          Checks to see whether the restrictions for a task pass or not.
(package private)  void runTaskAction(int tasknum, jAseaObject act)
          Run a particular task action.
 void showError(java.lang.String s)
          Print an error message to the error output.
 void showErrorln()
          Print a newline to the error output.
 void showErrorln(java.lang.String s)
          Print an error message to the error output, with a newline added to the end.
(package private)  void showRoomDesc(int roomnum)
          Print the long description of a room.
(package private)  void ShowString(java.lang.String s)
          Prints a string.
(package private)  int StandableObject(int i)
          The 'i'th standable object.
(package private)  void StartEvent(int eventnum, jAseaObject evt, jAseaEventState es)
          Change event from WAITING state to RUNNING State
(package private)  void StartNPCWalk(int npcnum, int walk)
          Start an NPC's walk
(package private)  int StatefulObject(int i)
          The index of the 'i'th Openable or Statussed object.
(package private)  int StringVariable(int i)
          The 'i'th String variable.
(package private)  int SurfaceObject(int i)
          The index of 'i'-th Surface object.
(package private)  java.lang.String TaskName(int i)
          The name of a task.
(package private)  void tickEvent(int eventnum)
          Attempt to advance said event by one turn
(package private)  void tickNPCWalk(int npcnum)
          Move NPC one step along current walk
(package private)  void tickTurn(java.lang.String cmd)
          Run all code that results from entering a command
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

game

jAseaObject game
The game object itself. Generally not used directly


global

jAseaObject global
Copies of various fields of the "game" object. Used to streamline code.


header

jAseaObject header
Copies of various fields of the "game" object. Used to streamline code.


rooms

jAseaObject[] rooms

objects

jAseaObject[] objects

tasks

jAseaObject[] tasks

events

jAseaObject[] events

npcs

jAseaObject[] npcs

synonyms

jAseaObject[] synonyms

alrs

jAseaObject[] alrs

roomgroups

jAseaObject[] roomgroups

vars

jAseaObject[] vars

state

jAseaGameState state
Current game state


commands

jAseaParser[] commands
Parsers for each task command


lib

jAseaLibrary[] lib
Parsers for each command in the standard library


r

static java.util.Random r
Random Number Generator


os

PrintFilter os
Filters the output created by the program by substituting variables, then ALRs, then releasing


gamerunning

boolean gamerunning
Whether the game is running or not


parsedExpressions

java.util.Hashtable parsedExpressions
Maps strings of expressions used in TaskActions to objects of Expression class


jaw

jAseaWindow jaw
Window where it gets input & displays output


jad

jAseaDump jad
Used to view an object in jAsea code


showErrors

boolean showErrors
Debugging flag.


dirnames4

static final java.lang.String[] dirnames4
An array of the cardinal direction names with a 4 point compass.


dirnames8

static final java.lang.String[] dirnames8
An array of the cardinal direction names with an 8 point compass.


dirnames

java.lang.String[] dirnames
An array of the cardinal direction names (Equals to dirnames4 or dirnames8, depending on the value of EightBitCompass)

Constructor Detail

jAseaRun

public jAseaRun(java.lang.String filename)
         throws java.io.IOException
Constructor. Runs in noninteractive mode (used for dumping a file)


jAseaRun

public jAseaRun(java.lang.String filename,
                boolean interactive)
         throws java.io.IOException
Constructor.

Parameters:
filename - the game file
interactive - run in interactive mode
Method Detail

ShowString

void ShowString(java.lang.String s)
Prints a string.

Parameters:
s - the string to print

showError

public void showError(java.lang.String s)
Print an error message to the error output.

Parameters:
s - the message to print

showErrorln

public void showErrorln(java.lang.String s)
Print an error message to the error output, with a newline added to the end.

Parameters:
s - the message to print

showErrorln

public void showErrorln()
Print a newline to the error output.


randomInt

static int randomInt(int low,
                     int high)
Return a random integer between low and high boundaries.

Parameters:
low - the low boundary
high - the high boundary
Returns:
the random integer

NPCInRoom

boolean NPCInRoom(int npc,
                  int room)
Is a specific non-player character in a specific room?

Parameters:
npc - the non-player character index
room - the room index
Returns:
true if the non-player character is in the room, false otherwise.

PlayerInRoom

boolean PlayerInRoom(int room)
Is the player in a specific room?

Parameters:
room - the room index
Returns:
true if the player is in the room, false otherwise.

canRunTask

boolean canRunTask(int tasknum)
Is the player in a room where the task can be run?

Parameters:
tasknum - the task index number
Returns:
true if the task can be run, false otherwise

objectInPlace

boolean objectInPlace(int obj,
                      int v2,
                      int v3)
Is an object in a certain place, state, or condition? This documentation needs more info on all the different states that can be checked.

Parameters:
obj - the object index
v2 - the type of place or state to check for
v3 - more of the type of place/state to check for
Returns:
true if the assertion is true, false otherwise

passTaskRestr

boolean passTaskRestr(jAseaObject restr)
Parameters:
restr - Restriction to be tested.
Returns:
Whether or not that restriction passed.

passTaskObjectLocation

boolean passTaskObjectLocation(int v1,
                               int v2,
                               int v3)
Determine whether or not an ObjectLocation Restriction is true or not

Parameters:
v1 - Object Affected
v2 - Type of object Restriction
v3 - Third argument (meaning varies by v2)
Returns:
whether that restriction passed or not

passTaskObjectState

boolean passTaskObjectState(int v1,
                            int v2)
Determine whether a ObjectState Restriction passes or not

Parameters:
v1 - StatefulObject# to be tested
v2 - State it should be in
Returns:
Whether to restriction passes or not

passTaskTaskState

boolean passTaskTaskState(int v1,
                          int v2)
Determine whether a restriction related to TaskState passes or not

Parameters:
v1 - Task to be checked
v2 - Whether that task should be completed or not
Returns:
Whether the restriction passed or not.

passTaskChar

boolean passTaskChar(int v1,
                     int v2,
                     int v3)
Determine whether a restriction related to character passes or not

Parameters:
v1 - Character affected
v2 - Type of restriction
v3 - Third argument (meaning varies by v2)
Returns:
whether the restriction passes or not

NPCCount

int NPCCount(int roomnum)
Return the number of characters in the room, including the player.

Parameters:
roomnum - the room index
Returns:
the number of characters

passTaskVar

boolean passTaskVar(int v1,
                    int v2,
                    int v3,
                    java.lang.String v4)
Determine whether a restriction related to variable state passes or not.

Parameters:
v1 - Variable to be checked
v2 - meaning varies
v3 - meaning varies
v4 - meaning varies
Returns:
whether that restriction passed or not.

runTask

boolean runTask(int tasknum,
                boolean forwards)
Checks to see whether the restrictions for a task pass or not. If they do pass, it runs all the TaskActions Returns true if the caller should keep looking for a match (some restriction failed, and that restriction didn't print text) Returns false if the caller should stop looking for a match (all restrictions passed, or failed restriction printed text)

Parameters:
tasknum - Number of task to be run
forwards - Is the task to be run in the forward direction?
Returns:
Should the caller keep looking for a matching function

showRoomDesc

void showRoomDesc(int roomnum)
Print the long description of a room.

Parameters:
roomnum - the room index

runTaskAction

void runTaskAction(int tasknum,
                   jAseaObject act)
Run a particular task action.

Parameters:
tasknum - Number of task whose action is to be run (used only for score type actions)
act - TaskAction to be run

runMoveObjectAction

void runMoveObjectAction(int v1,
                         int v2,
                         int v3)
Runs a MoveObject type TaskAction

Parameters:
v1 - Object to be moved
v2 - Meaning varies
v3 - Meaning varies

MoveObject

void MoveObject(int obj,
                int v2,
                int v3)
Move an object to a place

Parameters:
obj - Object to be moved
v2 - Type of movement
v3 - Meaning varies

MovePlayerToRoom

void MovePlayerToRoom(int roomnum)
Move player to specified room

Parameters:
roomnum - the room index

MoveNPCToRoom

void MoveNPCToRoom(int npcnum,
                   int roomnum)
Move a non-player character to a room.

Parameters:
npcnum - the non-player character index
roomnum - the room index number

runMoveNPCAction

void runMoveNPCAction(int v1,
                      int v2,
                      int v3)
Move the player or an NPC

Parameters:
v1 - NPC to be moved
v2 - Type of movement
v3 - Meaning varies

runChangeObjectStateAction

void runChangeObjectStateAction(int v1,
                                int v2)
Change the status of an object

Parameters:
v1 - Stateful Object to be changed
v2 - New state

runChangeVariableAction

void runChangeVariableAction(int v1,
                             int v2,
                             int v3,
                             java.lang.String expr,
                             int v5)
Change the value of a variable

Parameters:
v1 - Number of variable to be changed
v2 - meaning varies
v3 - meaning varies
expr - meaning varies
v5 - meaning varies

evalExprI

int evalExprI(java.lang.String expr)
Calculates the value of an integer expression

Parameters:
expr - Expression to be evaluated
Returns:
Value of expression

evalExprS

java.lang.String evalExprS(java.lang.String expr)
Calculates the value of an String expression NOT IMPLEMENTED AT PRESENT

Parameters:
expr - Expression to be evaluated
Returns:
Value of expression

runChangeScoreAction

void runChangeScoreAction(int tasknum,
                          int v1)
Changes current score (negative changes always used, positive scores only used once)

Parameters:
tasknum - Number of task
v1 - Amount to change score by

runSetTaskAction

void runSetTaskAction(int v1,
                      int v2)
Attempt to run another task

Parameters:
v1 - whether task should be run forwards or back
v2 - task to run

runEndGameAction

void runEndGameAction(int v1,
                      int v2,
                      int v3)
The end of game action.

Parameters:
v1 - the end state. 0 = win, 1 = lose, 2 = die.
v2 - seem to be unused
v3 - seem to be unused

ObjectIndirectlyInRoom

boolean ObjectIndirectlyInRoom(int object,
                               int room)
Return whether an object is nested within a room - Directly in - on object indirectly in - in open object indirectly in - carried by NPC who is in said room

Parameters:
object - the object index
room - the room index
Returns:
if the object is in that room

ObjectDirectlyInRoom

boolean ObjectDirectlyInRoom(int objectnum,
                             int room)
Return whether or not an object is on the floor of a room

Parameters:
objectnum - the object index
room - the room index
Returns:
true if object is on said floor

randomRoomGroupMember

int randomRoomGroupMember(int rg)
Choose a random member of a RoomGroup

Parameters:
rg - RoomGroup to pick from
Returns:
room number

randomAdjacentRoomGroupMember

int randomAdjacentRoomGroupMember(int room,
                                  int rg)
Return a random RoomGroup member adjacent to a certain room.

Parameters:
room - the room index
rg - RoomGroup to chooise from
Returns:
a random member of RoomGroup #'rg' that's adjacent to 'room', if no such member exists, return -1

roomInRoomGroup

boolean roomInRoomGroup(int roomnum,
                        int rg)
Returns whether a room is in a RoomGroup

Parameters:
roomnum - Room #
rg - RoomGroup #
Returns:
true if room in in RoomGroup

printSurfaceContents

void printSurfaceContents(int obj)
Print a list of all objects on a surface (For testing only, to be disabled in production releases, or at least restricted to debug mode.)

Parameters:
obj - SurfaceObject # to be printed

printContainerContents

void printContainerContents(int obj)
Print a list of all objects in a container (For testing only, to be disabled in production releases, or at least restricted to debug mode.)

Parameters:
obj - ContainerObject # to be printed

printNPCContents

void printNPCContents(int npcnum)
Print NPC name & a list of all objects carried by, worn by, or part it. (Debug mode only)

Parameters:
npcnum - NPC to be printed

ObjectLocation

java.lang.String ObjectLocation(int obj)
Show current location of object (Debug code only)

Parameters:
obj - Object # to be
Returns:
String containing current location

printRoomContents

void printRoomContents(int room)
Print all objects in a room (Debug code only)

Parameters:
room - the room index

go2

void go2()
Main Loop Should really be moved to UI code


tickTurn

void tickTurn(java.lang.String cmd)
Run all code that results from entering a command

Parameters:
cmd - Command to be run.

go

void go()
  throws java.io.IOException
Old main loop, obsolete

java.io.IOException

look

void look(boolean was_command)
Print room description.

Parameters:
was_command - True if the player entered "look" If false, verbose is off, and the room is visited, be brief.

parseLoop

void parseLoop(java.io.BufferedReader br)
         throws java.io.IOException
Old main loop, now obsolete

java.io.IOException

tickEvent

void tickEvent(int eventnum)
Attempt to advance said event by one turn

Parameters:
eventnum - Number of Event to run

canSeeEvent

boolean canSeeEvent(jAseaObject evt)
Is the player in a room where s/he can see text from the event

Parameters:
evt - Event Number
Returns:
If player can see text

StartEvent

void StartEvent(int eventnum,
                jAseaObject evt,
                jAseaEventState es)
Change event from WAITING state to RUNNING State

Parameters:
eventnum - #of event to start
evt - Data for event
es - State of event

FinishEvent

void FinishEvent(jAseaObject evt,
                 jAseaEventState es)
Stop event, move to finished state or restart

Parameters:
evt - Event Data
es - State of event

EventMoveObject

void EventMoveObject(int obj,
                     int dest)
Move an object from within an event

Parameters:
obj - Object # to be moved
dest - Room to move it to

StartNPCWalk

void StartNPCWalk(int npcnum,
                  int walk)
Start an NPC's walk

Parameters:
npcnum - NPC number
walk - walk to start

tickNPCWalk

void tickNPCWalk(int npcnum)
Move NPC one step along current walk

Parameters:
npcnum - NPC number to move

main

public static void main(java.lang.String[] args)
The main function. Read in a file and run it


TaskName

java.lang.String TaskName(int i)
The name of a task.

Parameters:
i - the index of the task

ObjectName

java.lang.String ObjectName(int i)
The name of a particular object.

Parameters:
i - the index of the object
Returns:
the object's name

ObjectStateName

java.lang.String ObjectStateName(jAseaObject obj,
                                 int statenum)
The name of a particular state of the particular object.

Parameters:
obj - the object
statenum - the state number to search for
Returns:
the state name

RoomName

java.lang.String RoomName(int i)
The short name of a room. Returns an error message if the room was not found.

Parameters:
i - the index of the room
Returns:
the room name

NPCName

java.lang.String NPCName(int i)
Get a non-player character's name.

Parameters:
i - the index of the character
Returns:
the name

Complete

java.lang.String Complete(boolean b)
String representation of a boolean. If true, return "Incomplete", else return "Complete.

Parameters:
b - the boolean
Returns:
the string

SurfaceObject

int SurfaceObject(int i)
The index of 'i'-th Surface object.

Parameters:
i - the number of the Surface object desired

ContainerObject

int ContainerObject(int i)
The index of the 'i'th Container object.

Parameters:
i - the number of the ContainerObject desired

StatefulObject

int StatefulObject(int i)
The index of the 'i'th Openable or Statussed object.

Parameters:
i - the index of the object desired

DynamicObject

int DynamicObject(int i)
The 'i'th dynamic object.

Parameters:
i - the index of the object desired

StandableObject

int StandableObject(int i)
The 'i'th standable object.

Parameters:
i - the index of the object desired

LieableObject

int LieableObject(int i)
The 'i'th lieable object.

Parameters:
i - the index of the object desired

IntegerVariable

int IntegerVariable(int i)
The 'i'th integer variable.

Parameters:
i - the index of the var desired

StringVariable

int StringVariable(int i)
The 'i'th String variable.

Parameters:
i - the index of the var desired