com.eoi.freya.turn
Class Turn

java.lang.Object
  |
  +--com.eoi.freya.turn.Turn

public class Turn
extends java.lang.Object

Turn contains an ArrayList of Phases that it will execute for each PlayerCommand object in player command list.


Constructor Summary
protected Turn(java.lang.String filename)
          Create a Turn instance that is dynamically loaded with Phase objects.
 
Method Summary
 void addPhase(java.lang.String className, org.jdom.Element attributes, int position)
          Adds a Phase to the list, by defining the class name, attributes and position
static Turn getInstance()
          Singleton access
 Phase getNextPhase()
           
static Turn loadTurnList(java.lang.String filename)
          Singleton access, specifying the file name of the xml file that holds the Phase list
 boolean nextPhase()
           
 void run()
          Run the turn, using the player command list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Turn

protected Turn(java.lang.String filename)
Create a Turn instance that is dynamically loaded with Phase objects. The list is a an XML document that contains the full class name of each Phase class and any attributes that the phase needs.
Parameters:
filename - A String contain the full path and name of the phase list XML document
Method Detail

loadTurnList

public static Turn loadTurnList(java.lang.String filename)
Singleton access, specifying the file name of the xml file that holds the Phase list

getInstance

public static Turn getInstance()
                        throws java.lang.NullPointerException
Singleton access

addPhase

public void addPhase(java.lang.String className,
                     org.jdom.Element attributes,
                     int position)
Adds a Phase to the list, by defining the class name, attributes and position
Parameters:
className - String containing the full class name of the Phase class
attributes - A Jdom Element that is used as the info block for the Phase
position - The int value of the position to place the phase in

nextPhase

public boolean nextPhase()
Returns:
Is there another phase in the list?

getNextPhase

public Phase getNextPhase()
Returns:
the next phase and increment the list position.

run

public void run()
Run the turn, using the player command list. For each phase in the list, this method assigns the current players command block to the current phase and the calls execute() on the phase, unless it is a non-player (repeatForAllPlayers returns false) phase.


Freya Engine, The Turn Based Game Engine
Copyright(c) 2002 Alexander Bilton
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA