org.gjt.universe
Class WormholeOscillating

java.lang.Object
  |
  +--org.gjt.universe.DBItem
        |
        +--org.gjt.universe.Wormhole
              |
              +--org.gjt.universe.WormholeOscillating
All Implemented Interfaces:
java.io.Serializable, TurnProcessedListener

public class WormholeOscillating
extends Wormhole
implements TurnProcessedListener

This class implements a special kind of wormhole which has one end-point which oscillates between two or more locations on a regular basis. By convention, the 1st end-point is the one that is fixed, and the 2nd end-point is the one which cycles through the wormhole's alternate star systems. A civilization must possess the appropriate level of hyperspace sensor technology in order to determine whether a wormhole has an oscillating end-point and, if so, the period of oscillation, number, and location of alternate end-points. Otherwise, they will simply have to discover through observation of results. Although the period of oscillation is normally regular, it may be changed randomly as the result of a hyperspace storm. Likewise, a hyperspace storm may add or remove one or more systems as alternate end-points of an oscillating wormhole. A civilization which possesses the appropriate level of hyperspace engineering technology may construct a wormhole focus, which will allow the current end point of an oscillating wormhole to be shifted whenever desired (even multiple times within the same game turn).

Version:
$Id: WormholeOscillating.java,v 1.6 2001/05/13 16:36:34 noordvyk Exp $
Author:
Allan Noordvyk
See Also:
Wormhole, Serialized Form

Field Summary
private  VectorSystemID alternateEndPointIDs
           
private  int nextIndex
           
private  int oscillationCountdown
           
private  int oscillationPeriod
           
 
Fields inherited from class org.gjt.universe.Wormhole
 
Constructor Summary
WormholeOscillating()
          This constructor returns an oscillating wormhole with randomly determined attributes.
WormholeOscillating(SystemID ep1, VectorSystemID alt_eps, float d, boolean s, float i, int p)
          This constructer is the desginated initializer for instances of this class, all other constructors in this class and subclasses should call this method as their first instruction.
 
Method Summary
 VectorSystemID alternateEndPointIDs()
          This method returns the current set of alternate end-points system IDs assigned to the receiving oscillating wormhole instance.
 int getOsciliationPeriod()
          This method returns the oscillation period of the wormhole (in game turns).
 boolean isAlternateEndPointID(SystemID anID)
          This method is provided to allow callers to easily test is a particualr star system is one of the alternate end-points of the receiving oscillating wormhole instances.
 boolean isOscillating()
          This method returns true if the wormhole is oscillating (i.e.
private  void prepareForOscillation()
          This method is called by our two constructors to complete set-up for tying oscillation into the game turn.
 void setAlternateEndPointIDs(VectorSystemID newValue)
          This method assigns a new set of alternate end-point system IDs to the receiving oscillating wormhole instance.
 void setOscillationPeriod(int newValue)
          This method sets the oscillation period of the wormhole (in game turns).
 VectorDisplayReturn specificDisplayDebug()
          This method is used for debugging purposes and returns a display vector describing this object.
 void turnProcessed()
          This method is called automatically at the end of each game turn.
 
Methods inherited from class org.gjt.universe.Wormhole
getDiameter, getEndPoint1, getEndPoint2, getEndPointID1, getEndPointID2, getID, getIndex, getIntegrity, getIsStable, getName, hasCollapsed, isEndPoint, isIntergalactic, reduceIntegrity, setDiameter, setEndPointID1, setEndPointID2, setIntegrity, setIsStable
 
Methods inherited from class org.gjt.universe.DBItem
getLocation, getOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alternateEndPointIDs

private VectorSystemID alternateEndPointIDs

oscillationPeriod

private int oscillationPeriod

oscillationCountdown

private int oscillationCountdown

nextIndex

private int nextIndex
Constructor Detail

WormholeOscillating

public WormholeOscillating(SystemID ep1,
                           VectorSystemID alt_eps,
                           float d,
                           boolean s,
                           float i,
                           int p)
This constructer is the desginated initializer for instances of this class, all other constructors in this class and subclasses should call this method as their first instruction. This method returns an

Parameters:
ep1 - The ID of the star system at the fixed end point of the wormhole.
alt_eps - The list of IDs of the star systems that may be at the other end point of the wormhole.
d - The diameter of the wormhole (in meters)
s - True if the wormhole is currently stable, false otherwise.
i - The initial integrity value of the wormhole
p - The period of oscillation (in game turns).

WormholeOscillating

public WormholeOscillating()
This constructor returns an oscillating wormhole with randomly determined attributes.

Method Detail

prepareForOscillation

private void prepareForOscillation()
This method is called by our two constructors to complete set-up for tying oscillation into the game turn.


isOscillating

public boolean isOscillating()
This method returns true if the wormhole is oscillating (i.e. may change the star system where one of its end-points is located) and false if it is not. All instances of this base class are non-oscillating and thus this method always returns true for them.

Overrides:
isOscillating in class Wormhole
See Also:
WormholeOscillating

alternateEndPointIDs

public VectorSystemID alternateEndPointIDs()
This method returns the current set of alternate end-points system IDs assigned to the receiving oscillating wormhole instance.


setAlternateEndPointIDs

public void setAlternateEndPointIDs(VectorSystemID newValue)
This method assigns a new set of alternate end-point system IDs to the receiving oscillating wormhole instance. The wormhole will be immedately reset to be using the first end-point in the set.

Parameters:
newValue - A vector of 2 or more distinct system IDs.

isAlternateEndPointID

public boolean isAlternateEndPointID(SystemID anID)
This method is provided to allow callers to easily test is a particualr star system is one of the alternate end-points of the receiving oscillating wormhole instances. This method returns true if the star system with the given ID is one of the end-points of the wormhole, and false otherwise.

Parameters:
anID - The ID of the star system being tested.

getOsciliationPeriod

public int getOsciliationPeriod()
This method returns the oscillation period of the wormhole (in game turns).


setOscillationPeriod

public void setOscillationPeriod(int newValue)
This method sets the oscillation period of the wormhole (in game turns).

Parameters:
newValue - The new value to be adopted.

turnProcessed

public void turnProcessed()
This method is called automatically at the end of each game turn. It is used to step the wormhole an additional turn towards its next oscillation. If the switchover point is reached, the next alternate end-point is adopted and the countdown to the next oscillation restarted.

Specified by:
turnProcessed in interface TurnProcessedListener

specificDisplayDebug

public VectorDisplayReturn specificDisplayDebug()
This method is used for debugging purposes and returns a display vector describing this object.

Overrides:
specificDisplayDebug in class Wormhole


Copyright © 2001 Universe Dev Team All Rights Reserved.