jezuch.utils.starmapper2
Class PlanetInfo

java.lang.Object
  |
  +--jezuch.utils.starmapper2.PlanetInfo
All Implemented Interfaces:
java.io.Serializable

public class PlanetInfo
extends java.lang.Object
implements java.io.Serializable

PlanetInfo is a sort of wrapper around Planet, that contains information for that Planet read from a Stars! PLA file (population, owner, report age etc.). Class StarsMap.StarsPla is a collection of PlanetInfos representing a Stars! report from one year. So a single PlanetInfo is a planet report. This class is immutable and exposes all fields as public final.

Since:
2.0
Version:
2.0
Author:
Krzysztof Sobolewski
See Also:
Serialized Form

Field Summary
static int DEFAULT_AR_VALUE
          Default AR's planet's influence range (light years).
static int MAX_AR_POPULATION
          Maximum population in AR's starbase (nominal limit of Death Star).
static int MAX_POPULATION
          Value of maximum non-overcrowded planet's population in Stars!.
static int MAX_VALUE
          Base maximum planet's influence range (light years).
static int MIN_VALUE
          Minimum planet's influence range (light years).
 Player owner
          Reference to Player that owns the planet according to the reports.
 Planet planet
          Reference to Planet that this PlanetInfo describes.
 int population
          Population of a Planet referenced by this PlanetInfo according to the reports.
 int reportAge
          Age of the report that is represented by this PlanetInfo.
 java.lang.String sbase
          Starbase name that is orbiting this planet according to the reports.
 
Constructor Summary
PlanetInfo(Planet planet, Player owner, java.lang.String sbase, int reportAge, int population)
          Creates a planet report for a given planet and parameters.
 
Method Summary
 int getValue()
          Calculates a value of a planet according to this report.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_AR_VALUE

public static final int DEFAULT_AR_VALUE
Default AR's planet's influence range (light years). This is equal to MAX_VALUE/2. It is needed, because Starmapper can't know what is the population of AR's planet's population, because this information is included only if this report is done by the AR itself. Might be useful when determining behavior of Starmapper.

See Also:
Constant Field Values

MAX_AR_POPULATION

public static final int MAX_AR_POPULATION
Maximum population in AR's starbase (nominal limit of Death Star). Planets of course can be overpopulated. This value is used to calculate "synthetic" population of AR's planet.

See Also:
Constant Field Values

MAX_POPULATION

public static final int MAX_POPULATION
Value of maximum non-overcrowded planet's population in Stars!. Might be useful when determining behavior of Starmapper.

See Also:
Constant Field Values

MAX_VALUE

public static final int MAX_VALUE
Base maximum planet's influence range (light years). This is for a planet that has 1000000 colonists, planets with larger maximum population (OBRM, JoATs) will have larger influence range. Might be useful when determining behavior of Starmapper.

See Also:
Constant Field Values

MIN_VALUE

public static final int MIN_VALUE
Minimum planet's influence range (light years). Might be useful when determining behavior of Starmapper.

See Also:
Constant Field Values

owner

public final Player owner
Reference to Player that owns the planet according to the reports. Can be null, what means that the planet is uninhabited.

See Also:
Player

planet

public final Planet planet
Reference to Planet that this PlanetInfo describes.

See Also:
Planet

population

public final int population
Population of a Planet referenced by this PlanetInfo according to the reports.


reportAge

public final int reportAge
Age of the report that is represented by this PlanetInfo. Starmapper tries to use latest reports possible for a Planet.


sbase

public final java.lang.String sbase
Starbase name that is orbiting this planet according to the reports.

Constructor Detail

PlanetInfo

public PlanetInfo(Planet planet,
                  Player owner,
                  java.lang.String sbase,
                  int reportAge,
                  int population)
Creates a planet report for a given planet and parameters.

Parameters:
planet - a Planet that this report is about
owner - a Player that owns this planet according to the report. Can be null, what means there's no owner (uninhabited planet)
sbase - name of a starbase orbiting the planet; null means that there's no starbase
reportAge - age of the report (years)
population - population of the planet
Throws:
java.lang.IllegalArgumentException - thron if planet is null, population is a negative integer or report age is negative integer
See Also:
Planet, Player
Method Detail

getValue

public int getValue()
Calculates a value of a planet according to this report. The exact formula is quite complicated and is different for AR races and all other races.
For non-AR races it's calculated like this:
  1. Population is trimed to MAX_POPULATION (overcrowded planets aren't more important)
  2. Base value is then ((double)pop/1000000)*(MAX_VALUE-MIN_VALUE)
  3. If there's no starbase, base value is decreased by 25%
  4. Base value is increased by MIN_VALUE, so the final value for typical planet (pop<=1000000) is basically in range [MIN_VALUE; MAX_VALUE], converted to int.
For AR races the value is calculated like above, but the population is "synthetic" and equal to (population*MAX_POPULATION/MAX_AR_POPULATION) Besides, if Starmapper can't resolve the population (there's no starbase maping to populations), getValue() returns DEFAULT_AR_VALUE.

Returns:
planet value, that is planet's influence range
See Also:
MAX_POPULATION, MAX_VALUE, MIN_VALUE, DEFAULT_AR_VALUE, MAX_AR_POPULATION