Planet resources and resource providers in XML dumps
* Dump version bumped up to 2 * Added SQL view that shows resource delta and provider information for all empire-owned planets * Added new storage classes for resource providers and resource deltas * Added row mapper which extracts all planet resources information (providers and deltas) * Modified dump generator to include planet resources / resource providers
This commit is contained in:
parent
95e6019c12
commit
ce6d86d344
17 changed files with 1607 additions and 50 deletions
legacyworlds-server-beans-bt/src/main/java/com/deepclone/lw/beans/bt/es
|
@ -20,6 +20,8 @@ import com.deepclone.lw.beans.bt.es.data.PlanetInformation;
|
|||
import com.deepclone.lw.beans.bt.es.data.QueueInformation;
|
||||
import com.deepclone.lw.beans.bt.es.data.QueueItemInformation;
|
||||
import com.deepclone.lw.beans.bt.es.data.ResearchInformation;
|
||||
import com.deepclone.lw.beans.bt.es.data.ResourceDeltaInformation;
|
||||
import com.deepclone.lw.beans.bt.es.data.ResourceProviderInformation;
|
||||
import com.deepclone.lw.beans.bt.es.data.ShipsInformation;
|
||||
import com.deepclone.lw.beans.bt.es.data.SystemInformation;
|
||||
import com.deepclone.lw.interfaces.bt.EmpireSummary;
|
||||
|
@ -40,6 +42,36 @@ import com.thoughtworks.xstream.XStream;
|
|||
public class EmpireSummaryBean
|
||||
implements EmpireSummary
|
||||
{
|
||||
/** Beginning of all dump SQL queries */
|
||||
private static final String SQL_START = "SELECT * FROM bugs.dump_";
|
||||
|
||||
/** Ending of (almost) all dump SQL queries */
|
||||
private static final String SQL_END = "_view WHERE empire_id = ?";
|
||||
|
||||
/** SQL query that accesses the main empire dump view */
|
||||
private static final String Q_EMPIRE = SQL_START + "main" + SQL_END;
|
||||
|
||||
/** SQL query that accesses the research dump view */
|
||||
private static final String Q_RESEARCH = SQL_START + "research" + SQL_END;
|
||||
|
||||
/** SQL query that accesses the empire's planets dump view */
|
||||
private static final String Q_PLANETS = SQL_START + "planets" + SQL_END;
|
||||
|
||||
/** SQL query that accesses the planetary resources dump view */
|
||||
private static final String Q_PLANET_RESOURCES = SQL_START + "planet_resources" + SQL_END;
|
||||
|
||||
/** SQL query that accesses the build queues dump view */
|
||||
private static final String Q_BUILD_QUEUES = SQL_START + "queues" + SQL_END + " ORDER BY queue_order";
|
||||
|
||||
/** SQL query that accesses the buildings dump view */
|
||||
private static final String Q_BUILDINGS = SQL_START + "buildings" + SQL_END;
|
||||
|
||||
/** SQL query that accesses the fleets dump view */
|
||||
private static final String Q_FLEETS = SQL_START + "fleets" + SQL_END;
|
||||
|
||||
/** SQL query that accesses the ships dump view */
|
||||
private static final String Q_SHIPS = SQL_START + "ships" + SQL_END;
|
||||
|
||||
/** JDBC access interface */
|
||||
private JdbcTemplate dTemplate;
|
||||
|
||||
|
@ -55,6 +87,9 @@ public class EmpireSummaryBean
|
|||
/** Empire-owned planet row mapper */
|
||||
private final PlanetInformationMapper mPlanet;
|
||||
|
||||
/** Planet resources row mapper */
|
||||
private final ResourceRowMapper mPlanetResources;
|
||||
|
||||
/** Planet construction queue item row mapper */
|
||||
private final QueueItemInformationMapper mQueueItem;
|
||||
|
||||
|
@ -79,12 +114,14 @@ public class EmpireSummaryBean
|
|||
AccountInformation.class , AllianceInformation.class , BuildingsInformation.class ,
|
||||
DebugInformation.class , EmpireInformation.class , FleetInformation.class , MovementInformation.class ,
|
||||
PlanetInformation.class , QueueInformation.class , QueueItemInformation.class ,
|
||||
ResearchInformation.class , ShipsInformation.class , SystemInformation.class
|
||||
ResearchInformation.class , ResourceDeltaInformation.class , ResourceProviderInformation.class ,
|
||||
ShipsInformation.class , SystemInformation.class
|
||||
} );
|
||||
|
||||
this.mMainInfo = new DebugInformationMapper( );
|
||||
this.mResearch = new ResearchInformationMapper( );
|
||||
this.mPlanet = new PlanetInformationMapper( );
|
||||
this.mPlanetResources = new ResourceRowMapper( );
|
||||
this.mQueueItem = new QueueItemInformationMapper( );
|
||||
this.mBuildings = new BuildingsInformationMapper( );
|
||||
this.mFleet = new FleetInformationMapper( );
|
||||
|
@ -116,46 +153,174 @@ public class EmpireSummaryBean
|
|||
@Override
|
||||
public String getSummary( int empireId )
|
||||
{
|
||||
String sql = "SELECT * FROM bugs.dump_main_view WHERE empire_id = ?";
|
||||
DebugInformation di = this.dTemplate.queryForObject( sql , this.mMainInfo , empireId );
|
||||
DebugInformation empireDump = this.dTemplate.queryForObject( Q_EMPIRE , this.mMainInfo , empireId );
|
||||
this.getResearch( empireId , empireDump );
|
||||
|
||||
sql = "SELECT * FROM bugs.dump_research_view WHERE empire_id = ?";
|
||||
for ( ResearchInformation ri : this.dTemplate.query( sql , this.mResearch , empireId ) ) {
|
||||
di.getResearch( ).add( ri );
|
||||
this.getPlanets( empireId , empireDump );
|
||||
this.getFleets( empireId , empireDump );
|
||||
|
||||
return this.xStream.toXML( empireDump );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get research information
|
||||
*
|
||||
* <p>
|
||||
* Read all research-related information from the appropriate dump view, and add corresponding
|
||||
* entries to the top-level instance.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param empireDump
|
||||
* the top-level instance
|
||||
*/
|
||||
private void getResearch( int empireId , DebugInformation empireDump )
|
||||
{
|
||||
for ( ResearchInformation ri : this.dTemplate.query( Q_RESEARCH , this.mResearch , empireId ) ) {
|
||||
empireDump.getResearch( ).add( ri );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get empire planets and related information
|
||||
*
|
||||
* <p>
|
||||
* Read the planet list and basic planet information from the appropriate dump view, then read
|
||||
* all extra information (resources, build queues, buildings).
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param empireDump
|
||||
* the top-level instance
|
||||
*/
|
||||
private void getPlanets( int empireId , DebugInformation empireDump )
|
||||
{
|
||||
HashMap< Integer , PlanetInformation > planets = new HashMap< Integer , PlanetInformation >( );
|
||||
for ( PlanetInformation planet : this.dTemplate.query( Q_PLANETS , this.mPlanet , empireId ) ) {
|
||||
empireDump.getPlanets( ).add( planet );
|
||||
planets.put( planet.getId( ) , planet );
|
||||
}
|
||||
|
||||
sql = "SELECT * FROM bugs.dump_planets_view WHERE empire_id = ?";
|
||||
Map< Integer , PlanetInformation > planets = new HashMap< Integer , PlanetInformation >( );
|
||||
for ( PlanetInformation pi : this.dTemplate.query( sql , this.mPlanet , empireId ) ) {
|
||||
di.getPlanets( ).add( pi );
|
||||
planets.put( pi.getId( ) , pi );
|
||||
}
|
||||
this.getPlanetResources( empireId , planets );
|
||||
this.getBuildQueues( empireId , planets );
|
||||
this.getBuildings( empireId , planets );
|
||||
}
|
||||
|
||||
sql = "SELECT * FROM bugs.dump_queues_view WHERE empire_id = ? ORDER BY queue_order";
|
||||
for ( QueueItemInformation qii : this.dTemplate.query( sql , this.mQueueItem , empireId ) ) {
|
||||
PlanetInformation pi = planets.get( qii.getPlanetId( ) );
|
||||
QueueInformation qi = ( qii.isMilitary( ) ? pi.getMilitaryQueue( ) : pi.getCivilianQueue( ) );
|
||||
qi.getItems( ).add( qii );
|
||||
}
|
||||
|
||||
sql = "SELECT * FROM bugs.dump_buildings_view WHERE empire_id = ?";
|
||||
for ( BuildingsInformation bi : this.dTemplate.query( sql , this.mBuildings , empireId ) ) {
|
||||
/**
|
||||
* Add resources information to planets
|
||||
*
|
||||
* <p>
|
||||
* Access resources information for the empire's planets and add the records to each planet.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param planets
|
||||
* a map associating planet records with their identifier
|
||||
*/
|
||||
private void getPlanetResources( int empireId , Map< Integer , PlanetInformation > planets )
|
||||
{
|
||||
for ( PlanetResourceRow resRow : this.dTemplate.query( Q_PLANET_RESOURCES , this.mPlanetResources , empireId ) ) {
|
||||
PlanetInformation planet = planets.get( resRow.getPlanetId( ) );
|
||||
planet.getResourceDeltas( ).add( resRow.getDelta( ) );
|
||||
|
||||
ResourceProviderInformation resProv = resRow.getProvider( );
|
||||
if ( resProv != null ) {
|
||||
planet.getResourceProviders( ).add( resProv );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add build queue information to planet records
|
||||
*
|
||||
* <p>
|
||||
* Access the contents of build queues and add the records to the corresponding planets.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param planets
|
||||
* the map of planets by identifier
|
||||
*/
|
||||
private void getBuildQueues( int empireId , Map< Integer , PlanetInformation > planets )
|
||||
{
|
||||
for ( QueueItemInformation queueItem : this.dTemplate.query( Q_BUILD_QUEUES , this.mQueueItem , empireId ) ) {
|
||||
PlanetInformation planet = planets.get( queueItem.getPlanetId( ) );
|
||||
|
||||
QueueInformation queue;
|
||||
if ( queueItem.isMilitary( ) ) {
|
||||
queue = planet.getMilitaryQueue( );
|
||||
} else {
|
||||
queue = planet.getCivilianQueue( );
|
||||
}
|
||||
|
||||
queue.getItems( ).add( queueItem );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add buildings information to planet records
|
||||
*
|
||||
* <p>
|
||||
* Access the contents of the buildings dump view and add the building records to the
|
||||
* corresponding planets.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param planets
|
||||
* the map of planets by identifier
|
||||
*/
|
||||
private void getBuildings( int empireId , Map< Integer , PlanetInformation > planets )
|
||||
{
|
||||
for ( BuildingsInformation bi : this.dTemplate.query( Q_BUILDINGS , this.mBuildings , empireId ) ) {
|
||||
planets.get( bi.getPlanetId( ) ).getBuildings( ).add( bi );
|
||||
}
|
||||
}
|
||||
|
||||
sql = "SELECT * FROM bugs.dump_fleets_view WHERE empire_id = ?";
|
||||
|
||||
/**
|
||||
* Retrieve information about the empire's fleets
|
||||
*
|
||||
* <p>
|
||||
* Access the list of fleets, add the records to the top-level instance, then retrieve all
|
||||
* necessary information.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param empireDump
|
||||
* the top-level empire dump
|
||||
*/
|
||||
private void getFleets( int empireId , DebugInformation empireDump )
|
||||
{
|
||||
Map< Long , FleetInformation > fleets = new HashMap< Long , FleetInformation >( );
|
||||
for ( FleetInformation fi : this.dTemplate.query( sql , this.mFleet , empireId ) ) {
|
||||
di.getFleets( ).add( fi );
|
||||
for ( FleetInformation fi : this.dTemplate.query( Q_FLEETS , this.mFleet , empireId ) ) {
|
||||
empireDump.getFleets( ).add( fi );
|
||||
fleets.put( fi.getId( ) , fi );
|
||||
}
|
||||
this.getShips( empireId , fleets );
|
||||
}
|
||||
|
||||
sql = "SELECT * FROM bugs.dump_ships_view WHERE empire_id = ?";
|
||||
for ( ShipsInformation si : this.dTemplate.query( sql , this.mShips , empireId ) ) {
|
||||
|
||||
/**
|
||||
* Add ships information to fleet records
|
||||
*
|
||||
* <p>
|
||||
* Retrieve information about ships and add the records to the corresponding fleets.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param fleets
|
||||
* the map of fleets by identifier
|
||||
*/
|
||||
private void getShips( int empireId , Map< Long , FleetInformation > fleets )
|
||||
{
|
||||
for ( ShipsInformation si : this.dTemplate.query( Q_SHIPS , this.mShips , empireId ) ) {
|
||||
fleets.get( si.getFleetId( ) ).getShips( ).add( si );
|
||||
}
|
||||
|
||||
return this.xStream.toXML( di );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package com.deepclone.lw.beans.bt.es;
|
||||
|
||||
|
||||
import com.deepclone.lw.beans.bt.es.data.ResourceDeltaInformation;
|
||||
import com.deepclone.lw.beans.bt.es.data.ResourceProviderInformation;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Planet resource row information
|
||||
*
|
||||
* <p>
|
||||
* Planet resources and resource providers are both extracted from the same
|
||||
* <code>bugs.planet_resources_view</code> rows. Because of that, this class is used to transmit the
|
||||
* information (as a {@link ResourceDeltaInformation} instance and an optional
|
||||
* {@link ResourceProviderInformation} instance) from the row mapper to the summary creation
|
||||
* component.
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*/
|
||||
class PlanetResourceRow
|
||||
{
|
||||
|
||||
/** Identifier of the planet */
|
||||
private final int planetId;
|
||||
|
||||
/** Resource delta information */
|
||||
private final ResourceDeltaInformation delta = new ResourceDeltaInformation( );
|
||||
|
||||
/** Resource provider information */
|
||||
private ResourceProviderInformation provider;
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the instance by setting the planet identifier
|
||||
*
|
||||
* @param planetId
|
||||
* the planet's identifier
|
||||
*/
|
||||
public PlanetResourceRow( int planetId )
|
||||
{
|
||||
this.planetId = planetId;
|
||||
}
|
||||
|
||||
|
||||
/** @return the planet's identifier */
|
||||
public int getPlanetId( )
|
||||
{
|
||||
return this.planetId;
|
||||
}
|
||||
|
||||
|
||||
/** @return the resource delta information record */
|
||||
public ResourceDeltaInformation getDelta( )
|
||||
{
|
||||
return this.delta;
|
||||
}
|
||||
|
||||
|
||||
/** @return the resource provider information record */
|
||||
public ResourceProviderInformation getProvider( )
|
||||
{
|
||||
return this.provider;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the resource provider information record
|
||||
*
|
||||
* @param provider
|
||||
* the resource provider information record
|
||||
*/
|
||||
public void setProvider( ResourceProviderInformation provider )
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the name of the resource
|
||||
*
|
||||
* <p>
|
||||
* This method should be called once the rest of the record(s) has been initialised. It will set
|
||||
* the resource name on both the delta and the provider (if the latter exists).
|
||||
*
|
||||
* @param resource
|
||||
* the name of the resource
|
||||
*/
|
||||
public void setResource( String resource )
|
||||
{
|
||||
this.delta.setResource( resource );
|
||||
if ( this.provider != null ) {
|
||||
this.provider.setResource( resource );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.deepclone.lw.beans.bt.es;
|
||||
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
import com.deepclone.lw.beans.bt.es.data.ResourceProviderInformation;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Mapper which extract planet resources and resource providers information
|
||||
*
|
||||
* <p>
|
||||
* This class maps rows from <code>bugs.dump_planet_resources_view</code> into
|
||||
* {@link PlanetResourceRow} instances.
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*
|
||||
*/
|
||||
class ResourceRowMapper
|
||||
implements RowMapper< PlanetResourceRow >
|
||||
{
|
||||
|
||||
/**
|
||||
* Map a row from <code>bugs.dump_planet_resources_view</code>
|
||||
*
|
||||
* <p>
|
||||
* Generate the {@link PlanetResourceRow} instance with the correct planet identifier, resource
|
||||
* name, income and upkeep. If there is also a resource provider, attach a
|
||||
* {@link ResourceProviderInformation} instance to the result.
|
||||
*/
|
||||
@Override
|
||||
public PlanetResourceRow mapRow( ResultSet rs , int rowNum )
|
||||
throws SQLException
|
||||
{
|
||||
PlanetResourceRow row = new PlanetResourceRow( rs.getInt( "planet_id" ) );
|
||||
|
||||
row.getDelta( ).setIncome( rs.getDouble( "pres_income" ) );
|
||||
row.getDelta( ).setUpkeep( rs.getDouble( "pres_upkeep" ) );
|
||||
|
||||
double pCapacity = rs.getDouble( "resprov_quantity_max" );
|
||||
if ( !rs.wasNull( ) ) {
|
||||
ResourceProviderInformation rpi = new ResourceProviderInformation( );
|
||||
rpi.setMaximalQuantity( pCapacity );
|
||||
rpi.setCurrentQuantity( rs.getDouble( "resprov_quantity" ) );
|
||||
rpi.setDifficulty( rs.getDouble( "resprov_difficulty" ) );
|
||||
rpi.setRecovery( rs.getDouble( "resprov_recovery" ) );
|
||||
row.setProvider( rpi );
|
||||
}
|
||||
|
||||
row.setResource( rs.getString( "resource_name" ) );
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ public class DebugInformation
|
|||
|
||||
@XStreamAsAttribute
|
||||
@XStreamAlias( "dump-version" )
|
||||
private int version = 1;
|
||||
private int version = 2;
|
||||
|
||||
private SystemInformation system = new SystemInformation( );
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.bt.es.data;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Invalid dump contents exception
|
||||
*
|
||||
* <p>
|
||||
* This runtime exception is thrown by the debugging data record classes when one of the fields is
|
||||
* set to an incorrect value.
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*
|
||||
*/
|
||||
public final class InvalidDumpContentsException
|
||||
extends RuntimeException
|
||||
{
|
||||
/** Serialisation identifier */
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** Class in which the error was caused */
|
||||
private final Class< ? extends Serializable > recordType;
|
||||
|
||||
/** Name of the field to which invalid contents were assigned */
|
||||
private final String field;
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the exception by setting the record and field
|
||||
*
|
||||
* @param type
|
||||
* the type of the XML dump record
|
||||
* @param field
|
||||
* the field to which invalid contents were assigned
|
||||
*/
|
||||
InvalidDumpContentsException( Class< ? extends Serializable > type , String field )
|
||||
{
|
||||
super( "Invalid contents for field " + field + " of record " + type.getSimpleName( ) );
|
||||
this.recordType = type;
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
|
||||
/** @return the type of the XML dump record */
|
||||
public Class< ? extends Serializable > getRecordType( )
|
||||
{
|
||||
return this.recordType;
|
||||
}
|
||||
|
||||
|
||||
/** @return the field to which invalid contents were assigned */
|
||||
public String getField( )
|
||||
{
|
||||
return this.field;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,118 +7,204 @@ import java.util.List;
|
|||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Planet XML record
|
||||
*
|
||||
* <p>
|
||||
* This class is used in XML dumps to represent the information about a planet. It includes a few
|
||||
* basic values, as well as information about buildings, queues and resources.
|
||||
*
|
||||
* <p>
|
||||
* This record exists since version 1 (B6M1) of XML dumps. However, the following changes were made
|
||||
* later.
|
||||
* <ul>
|
||||
* <li>Version 2 (B6M2):
|
||||
* <ul>
|
||||
* <li>resource providers added,
|
||||
* </ul>
|
||||
* </ul>
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*
|
||||
*/
|
||||
@XStreamAlias( "planet" )
|
||||
@SuppressWarnings( "serial" )
|
||||
public class PlanetInformation
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** Planet identifier */
|
||||
@XStreamAsAttribute
|
||||
@XStreamAlias( "id" )
|
||||
private int id;
|
||||
private Integer id;
|
||||
|
||||
/** Planet name */
|
||||
@XStreamAsAttribute
|
||||
@XStreamAlias( "id" )
|
||||
private String name;
|
||||
|
||||
/** Current population of the planet */
|
||||
@XStreamAlias( "population" )
|
||||
private double population;
|
||||
private Double population;
|
||||
|
||||
/** Current happiness of the planet's population */
|
||||
@XStreamAlias( "current-happiness" )
|
||||
private double currentHappiness;
|
||||
private Double currentHappiness;
|
||||
|
||||
/** Target happiness of the planet's population */
|
||||
@XStreamAlias( "target-happiness" )
|
||||
private double targetHappiness;
|
||||
|
||||
/** List of buildings */
|
||||
@XStreamAlias( "buildings" )
|
||||
private List< BuildingsInformation > buildings = new LinkedList< BuildingsInformation >( );
|
||||
private final List< BuildingsInformation > buildings = new LinkedList< BuildingsInformation >( );
|
||||
|
||||
/** Civilian construction queue */
|
||||
@XStreamAlias( "civ-queue" )
|
||||
private QueueInformation civilianQueue = new QueueInformation( );
|
||||
private final QueueInformation civilianQueue = new QueueInformation( );
|
||||
|
||||
/** Military construction queue */
|
||||
@XStreamAlias( "mil-queue" )
|
||||
private QueueInformation militaryQueue = new QueueInformation( );
|
||||
private final QueueInformation militaryQueue = new QueueInformation( );
|
||||
|
||||
/** Planet resource deltas */
|
||||
@XStreamImplicit
|
||||
private final LinkedList< ResourceDeltaInformation > resourceDeltas = new LinkedList< ResourceDeltaInformation >( );
|
||||
|
||||
/** List of resource providers */
|
||||
@XStreamImplicit( itemFieldName = "resource-provider" )
|
||||
private final LinkedList< ResourceProviderInformation > resourceProviders = new LinkedList< ResourceProviderInformation >( );
|
||||
|
||||
|
||||
public int getId( )
|
||||
/** @return the planet's identifier */
|
||||
public Integer getId( )
|
||||
{
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the planet's identifier
|
||||
*
|
||||
* @param id
|
||||
* the planet's identifier
|
||||
*/
|
||||
public void setId( int id )
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/** @return the planet's name */
|
||||
public String getName( )
|
||||
{
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the planet's name
|
||||
*
|
||||
* @param name
|
||||
* the planet's name
|
||||
*/
|
||||
public void setName( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public double getPopulation( )
|
||||
/** @return the planet's current population */
|
||||
public Double getPopulation( )
|
||||
{
|
||||
return population;
|
||||
return this.population;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the planet's current population
|
||||
*
|
||||
* @param population
|
||||
* the planet's current population
|
||||
*/
|
||||
public void setPopulation( double population )
|
||||
{
|
||||
this.population = population;
|
||||
}
|
||||
|
||||
|
||||
public double getCurrentHappiness( )
|
||||
/** @return the current happiness of the planet's population */
|
||||
public Double getCurrentHappiness( )
|
||||
{
|
||||
return currentHappiness;
|
||||
return this.currentHappiness;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current happiness of the planet's population
|
||||
*
|
||||
* @param currentHappiness
|
||||
* the current happiness of the planet's population
|
||||
*/
|
||||
public void setCurrentHappiness( double currentHappiness )
|
||||
{
|
||||
this.currentHappiness = currentHappiness;
|
||||
}
|
||||
|
||||
|
||||
public double getTargetHappiness( )
|
||||
/** @return the target happiness of the planet's population */
|
||||
public Double getTargetHappiness( )
|
||||
{
|
||||
return targetHappiness;
|
||||
return this.targetHappiness;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the target happiness of the planet's population
|
||||
*
|
||||
* @param targetHappiness
|
||||
* the target happiness of the planet's population
|
||||
*/
|
||||
public void setTargetHappiness( double targetHappiness )
|
||||
{
|
||||
this.targetHappiness = targetHappiness;
|
||||
}
|
||||
|
||||
|
||||
/** @return the list of buildings constructed on the planet */
|
||||
public List< BuildingsInformation > getBuildings( )
|
||||
{
|
||||
return buildings;
|
||||
return this.buildings;
|
||||
}
|
||||
|
||||
|
||||
/** @return the civilian construction queue */
|
||||
public QueueInformation getCivilianQueue( )
|
||||
{
|
||||
return civilianQueue;
|
||||
return this.civilianQueue;
|
||||
}
|
||||
|
||||
|
||||
/** @return the military construction queue */
|
||||
public QueueInformation getMilitaryQueue( )
|
||||
{
|
||||
return militaryQueue;
|
||||
return this.militaryQueue;
|
||||
}
|
||||
|
||||
|
||||
/** @return the list of resource delta records */
|
||||
public LinkedList< ResourceDeltaInformation > getResourceDeltas( )
|
||||
{
|
||||
return this.resourceDeltas;
|
||||
}
|
||||
|
||||
|
||||
/** @return the list of resource provider records */
|
||||
public LinkedList< ResourceProviderInformation > getResourceProviders( )
|
||||
{
|
||||
return this.resourceProviders;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
package com.deepclone.lw.beans.bt.es.data;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resource delta information
|
||||
*
|
||||
* <p>
|
||||
* This class represents records which contain a resource's delta - that is, the income and upkeep
|
||||
* for some type of resource.
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*/
|
||||
@SuppressWarnings( "serial" )
|
||||
@XStreamAlias( "resource-delta" )
|
||||
public class ResourceDeltaInformation
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
/** Identifier of the resource */
|
||||
@XStreamAlias( "id" )
|
||||
@XStreamAsAttribute
|
||||
private String resource;
|
||||
|
||||
/** Income for that type of resource */
|
||||
@XStreamAsAttribute
|
||||
private Double income;
|
||||
|
||||
/** Upkeep for that type of resource */
|
||||
@XStreamAsAttribute
|
||||
private Double upkeep;
|
||||
|
||||
|
||||
/** @return the resource's identifier */
|
||||
public String getResource( )
|
||||
{
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the resource's identifier
|
||||
*
|
||||
* @param resource
|
||||
* the resource's identifier
|
||||
*
|
||||
* @throws InvalidDumpContentsException
|
||||
* if the specified resource type is <code>null</code>
|
||||
*/
|
||||
public void setResource( String resource )
|
||||
throws InvalidDumpContentsException
|
||||
{
|
||||
if ( resource == null ) {
|
||||
throw new InvalidDumpContentsException( this.getClass( ) , "resource" );
|
||||
}
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the income for that type of resource, or <code>null</code> if no income information
|
||||
* is available
|
||||
*/
|
||||
public Double getIncome( )
|
||||
{
|
||||
return this.income;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the income for that type of resource
|
||||
*
|
||||
* @param income
|
||||
* the income for that type of resource
|
||||
*/
|
||||
public void setIncome( double income )
|
||||
{
|
||||
this.income = income;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the upkeep for that type of resource, or <code>null</code> if no upkeep information
|
||||
* is available
|
||||
*/
|
||||
public Double getUpkeep( )
|
||||
{
|
||||
return this.upkeep;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the upkeep for that type of resource
|
||||
*
|
||||
* @param upkeep
|
||||
* the upkeep for that type of resource
|
||||
*/
|
||||
public void setUpkeep( double upkeep )
|
||||
{
|
||||
this.upkeep = upkeep;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package com.deepclone.lw.beans.bt.es.data;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resource provider XML record
|
||||
*
|
||||
* <p>
|
||||
* This class represents the information about a resource provider that will be serialised to the
|
||||
* debugging XML dump when a player posts a bug report.
|
||||
*
|
||||
* <p>
|
||||
* This record exists since version 2 (B6M2) of XML dumps.
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*/
|
||||
@SuppressWarnings( "serial" )
|
||||
public class ResourceProviderInformation
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
/** Identifier of the resource */
|
||||
@XStreamAsAttribute
|
||||
private String resource;
|
||||
|
||||
/** Maximal quantity in the provider */
|
||||
@XStreamAsAttribute
|
||||
@XStreamAlias( "max" )
|
||||
private Double maximalQuantity;
|
||||
|
||||
/** Current quantity in the provider */
|
||||
@XStreamAsAttribute
|
||||
@XStreamAlias( "current" )
|
||||
private Double currentQuantity;
|
||||
|
||||
/** Extraction difficulty */
|
||||
@XStreamAsAttribute
|
||||
private Double difficulty;
|
||||
|
||||
/** Recovery rate */
|
||||
@XStreamAsAttribute
|
||||
private Double recovery;
|
||||
|
||||
|
||||
/** @return the resource's identifier */
|
||||
public String getResource( )
|
||||
{
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the resource's identifier
|
||||
*
|
||||
* @param resource
|
||||
* the resource's identifier
|
||||
*
|
||||
* @throws InvalidDumpContentsException
|
||||
* if the resource's identifier is <code>null</code>
|
||||
*/
|
||||
public void setResource( String resource )
|
||||
throws InvalidDumpContentsException
|
||||
{
|
||||
if ( resource == null ) {
|
||||
throw new InvalidDumpContentsException( this.getClass( ) , "resource" );
|
||||
}
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
|
||||
/** @return the provider's total capacity */
|
||||
public Double getMaximalQuantity( )
|
||||
{
|
||||
return this.maximalQuantity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the maximal quantity of resources in the provider
|
||||
*
|
||||
* @param maximalQuantity
|
||||
* the provider's total capacity
|
||||
*/
|
||||
public void setMaximalQuantity( double maximalQuantity )
|
||||
{
|
||||
this.maximalQuantity = maximalQuantity;
|
||||
}
|
||||
|
||||
|
||||
/** @return the current quantity of resources in the provider */
|
||||
public Double getCurrentQuantity( )
|
||||
{
|
||||
return this.currentQuantity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current quantity of resources in the provider
|
||||
*
|
||||
* @param currentQuantity
|
||||
* the current quantity of resources in the provider
|
||||
*/
|
||||
public void setCurrentQuantity( double currentQuantity )
|
||||
{
|
||||
this.currentQuantity = currentQuantity;
|
||||
}
|
||||
|
||||
|
||||
/** @return the provider's extraction difficulty */
|
||||
public Double getDifficulty( )
|
||||
{
|
||||
return this.difficulty;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the provider's extraction difficulty
|
||||
*
|
||||
* @param difficulty
|
||||
* the provider's extraction difficulty
|
||||
*/
|
||||
public void setDifficulty( double difficulty )
|
||||
{
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
|
||||
/** @return the provider's recovery rate */
|
||||
public Double getRecovery( )
|
||||
{
|
||||
return this.recovery;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the provider's recovery rate
|
||||
*
|
||||
* @param recovery
|
||||
* the provider's recovery rate
|
||||
*/
|
||||
public void setRecovery( double recovery )
|
||||
{
|
||||
this.recovery = recovery;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue