diff --git a/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/FullPlanetListRecord.java b/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/FullPlanetListRecord.java new file mode 100644 index 0000000..786a96a --- /dev/null +++ b/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/FullPlanetListRecord.java @@ -0,0 +1,65 @@ +package com.deepclone.lw.beans.game.resources; + + +import com.deepclone.lw.cmd.player.gdata.PlanetListResourceRecord; + + + +/** + * Intermediary class for planet list resource records extraction + * + *
+ * This class is used as an intermediary to extract {@link PlanetListResourceRecord} instances from
+ * emp.plist_resources_view
. It contains the instance itself, and an additional field
+ * which indicates the planet's identifier.
+ *
+ *
+ * Instances of this class are returned by {@link PlanetListResourceRecordMapper} and then processed + * to generate the map returned by {@link ResourcesInformationDAOBean#getPlanetListData(int)}. + * + * @author E. Benoît + * + */ +class FullPlanetListRecord +{ + /** The planet's identifier */ + private int planetId; + + /** The resource record */ + private final PlanetListResourceRecord record = new PlanetListResourceRecord( ); + + + /** + * Gets the planet's identifier. + * + * @return the planet's identifier + */ + public int getPlanetId( ) + { + return this.planetId; + } + + + /** + * Sets the planet's identifier. + * + * @param planetId + * the new planet's identifier + */ + public void setPlanetId( int planetId ) + { + this.planetId = planetId; + } + + + /** + * Gets the resource record. + * + * @return the resource record + */ + public PlanetListResourceRecord getRecord( ) + { + return this.record; + } + +} diff --git a/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/PlanetListResourceRecordMapper.java b/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/PlanetListResourceRecordMapper.java new file mode 100644 index 0000000..c09f25b --- /dev/null +++ b/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/PlanetListResourceRecordMapper.java @@ -0,0 +1,72 @@ +package com.deepclone.lw.beans.game.resources; + + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.springframework.jdbc.core.RowMapper; + +import com.deepclone.lw.cmd.player.gdata.PlanetListResourceRecord; + + + +/** + * Planet list resource records mapper + * + *
+ * This class is responsible for mapping rows from emp.plist_resources_view
into
+ * {@link FullPlanetListRecord} instances.
+ *
+ * @author E. Benoît
+ */
+class PlanetListResourceRecordMapper
+ implements RowMapper< FullPlanetListRecord >
+{
+
+ /**
+ * Map a row from emp.plist_resources_view
+ *
+ *
+ * Convert a row from emp.plist_resources_view
into a {@link FullPlanetListRecord}
+ * instance. The resulting instance will have both its planet identifier and actual record set
+ * according to the row's contents.
+ */
+ @Override
+ public FullPlanetListRecord mapRow( ResultSet rs , int rowNum )
+ throws SQLException
+ {
+ FullPlanetListRecord fullRecord = new FullPlanetListRecord( );
+
+ fullRecord.setPlanetId( rs.getInt( "planet_id" ) );
+ this.extractRecord( fullRecord.getRecord( ) , rs );
+
+ return fullRecord;
+ }
+
+
+ /**
+ * Extract the contents of the actual record
+ *
+ *
+ * This method extracts the contents of the record that will be sent to the client from the + * result set. + * + * @param record + * the planet list resource record to update + * @param rs + * the result set to extract information from + * + * @throws SQLException + * if a SQLException is encountered getting column values + */ + private void extractRecord( PlanetListResourceRecord record , ResultSet rs ) + throws SQLException + { + record.setName( rs.getString( "resource_name" ) ); + record.setIncome( rs.getLong( "pres_income" ) ); + record.setUpkeep( rs.getLong( "pres_upkeep" ) ); + record.setCivInvestment( rs.getLong( "civ_investment" ) ); + record.setMilInvestment( rs.getLong( "mil_investment" ) ); + } + +} diff --git a/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/ResourcesInformationDAOBean.java b/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/ResourcesInformationDAOBean.java index 651d4e5..ca6b415 100644 --- a/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/ResourcesInformationDAOBean.java +++ b/legacyworlds-server-beans-resources/src/main/java/com/deepclone/lw/beans/game/resources/ResourcesInformationDAOBean.java @@ -1,13 +1,17 @@ package com.deepclone.lw.beans.game.resources; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.Map; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; +import com.deepclone.lw.cmd.player.gdata.PlanetListResourceRecord; import com.deepclone.lw.cmd.player.gdata.empire.EmpireResourceRecord; import com.deepclone.lw.cmd.player.gdata.planets.PlanetResourceRecord; import com.deepclone.lw.interfaces.game.resources.ResourcesInformationDAO; @@ -37,12 +41,18 @@ class ResourcesInformationDAOBean /** SQL query that fetches an empire's resources information */ private static final String Q_EMPIRE_RESOURCES = "SELECT * FROM emp.resources_view WHERE empire_id = ?"; + /** SQL query that fetches the resource records for an empire's planet list */ + private static final String Q_PLIST_RESOURCES = "SELECT * FROM emp.plist_resources_view WHERE empire_id = ?"; + /** Row mapper for planet resources */ private final PlanetResourceMapper mPlanetResource; /** Row mapper for empire resources */ private final EmpireResourceMapper mEmpireResource; + /** Row mapper for planet list records */ + private final PlanetListResourceRecordMapper mPlanetListRecord; + /** Spring JDBC interface */ private JdbcTemplate dTemplate; @@ -52,6 +62,7 @@ class ResourcesInformationDAOBean { this.mPlanetResource = new PlanetResourceMapper( ); this.mEmpireResource = new EmpireResourceMapper( ); + this.mPlanetListRecord = new PlanetListResourceRecordMapper( ); } @@ -96,4 +107,34 @@ class ResourcesInformationDAOBean return this.dTemplate.query( Q_EMPIRE_RESOURCES , this.mEmpireResource , empire ); } + + /** + * Run the planet list resources query and extract the data + * + *
+ * This implementation queries emp.plist_resources_view
to obtain the planet list's
+ * records, then maps the resulting rows using the intermediary {@link FullPlanetListRecord}
+ * class, and finally associates records to the corresponding planet identifiers.
+ */
+ @Override
+ public Map< Integer , List< PlanetListResourceRecord > > getPlanetListData( int empire )
+ {
+ Map< Integer , List< PlanetListResourceRecord > > result;
+ result = new HashMap< Integer , List< PlanetListResourceRecord > >( );
+
+ List< FullPlanetListRecord > queryOutput;
+ queryOutput = this.dTemplate.query( Q_PLIST_RESOURCES , this.mPlanetListRecord , empire );
+
+ for ( FullPlanetListRecord fullRecord : queryOutput ) {
+ List< PlanetListResourceRecord > records = result.get( fullRecord.getPlanetId( ) );
+ if ( records == null ) {
+ records = new LinkedList< PlanetListResourceRecord >( );
+ result.put( fullRecord.getPlanetId( ) , records );
+ }
+ records.add( fullRecord.getRecord( ) );
+ }
+
+ return result;
+ }
+
}
diff --git a/legacyworlds-server-beans-simple/src/main/java/com/deepclone/lw/beans/empire/EmpireManagementBean.java b/legacyworlds-server-beans-simple/src/main/java/com/deepclone/lw/beans/empire/EmpireManagementBean.java
index 2d769f3..7a4c6fe 100644
--- a/legacyworlds-server-beans-simple/src/main/java/com/deepclone/lw/beans/empire/EmpireManagementBean.java
+++ b/legacyworlds-server-beans-simple/src/main/java/com/deepclone/lw/beans/empire/EmpireManagementBean.java
@@ -1,8 +1,10 @@
package com.deepclone.lw.beans.empire;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -16,6 +18,7 @@ import com.deepclone.lw.cmd.player.elist.EnemyListResponse;
import com.deepclone.lw.cmd.player.gdata.GamePageData;
import com.deepclone.lw.cmd.player.gdata.NameIdPair;
import com.deepclone.lw.cmd.player.gdata.PlanetListData;
+import com.deepclone.lw.cmd.player.gdata.PlanetListResourceRecord;
import com.deepclone.lw.cmd.player.gdata.battles.BattleListEntry;
import com.deepclone.lw.cmd.player.gdata.empire.OverviewData;
import com.deepclone.lw.cmd.player.gdata.empire.ResearchLineData;
@@ -177,9 +180,19 @@ public class EmpireManagementBean
@Override
public ListPlanetsResponse getPlanetList( int empireId )
{
- GamePageData page = this.getGeneralInformation( empireId );
List< PlanetListData > planets = this.empireDao.getPlanetList( empireId );
- return new ListPlanetsResponse( page , planets );
+
+ Map< Integer , List< PlanetListResourceRecord >> resources;
+ resources = this.resourcesInformationDao.getPlanetListData( empireId );
+ for ( PlanetListData planet : planets ) {
+ List< PlanetListResourceRecord > planetResources = resources.get( planet.getId( ) );
+ if ( planetResources == null ) {
+ planetResources = new ArrayList< PlanetListResourceRecord >( );
+ }
+ planet.setResources( planetResources );
+ }
+
+ return new ListPlanetsResponse( this.getGeneralInformation( empireId ) , planets );
}
diff --git a/legacyworlds-server-data/db-structure/parts/040-functions/167-planet-list.sql b/legacyworlds-server-data/db-structure/parts/040-functions/167-planet-list.sql
index ca6ed36..e9ed6d1 100644
--- a/legacyworlds-server-data/db-structure/parts/040-functions/167-planet-list.sql
+++ b/legacyworlds-server-data/db-structure/parts/040-functions/167-planet-list.sql
@@ -3,7 +3,7 @@
--
-- Views for empires' planet lists
--
--- Copyright(C) 2004-2010, DeepClone Development
+-- Copyright(C) 2004-2012, DeepClone Development
-- --------------------------------------------------------
@@ -114,6 +114,58 @@ CREATE VIEW emp.planets_list_fleets
END );
+/*
+ * Planet list resources information
+ * ----------------------------------
+ *
+ * This view is used to display the resources-related information in the
+ * planet list pages. All rows in the view are ordered using the usual
+ * resource ordering view.
+ *
+ * FIXME: time-related constants are hardcoded.
+ * FIXME: civilian and military investments are set to 0.
+ *
+ * Columns:
+ * empire_id The empire's identifier
+ * planet_id The planet's identifier
+ * pres_income The income for this type of resources on a period
+ * of 12h RT / one month GT.
+ * pres_upkeep The upkeep for this type of resources on a period
+ * of 12h RT / one month GT.
+ * civ_investment The current amount invested in the civillian build
+ * queue (FIXME: forced to 0)
+ * mil_investment The current amount invested in the military build
+ * queue (FIXME: forced to 0)
+ */
+DROP VIEW IF EXISTS emp.plist_resources_view;
+CREATE VIEW emp.plist_resources_view
+ AS SELECT _emp_planet.empire_id , _emp_planet.planet_id ,
+ _name.translated_string AS resource_name ,
+ FLOOR( _pres.pres_income * 720.0 )::BIGINT AS pres_income ,
+ CEIL( _pres.pres_upkeep * 720.0 )::BIGINT AS pres_upkeep ,
+ 0::BIGINT AS civ_investment ,
+ 0::BIGINT AS mil_investment
+ FROM emp.planets _emp_planet
+ INNER JOIN verse.planet_resources _pres
+ USING ( planet_id )
+ INNER JOIN naming.empire_names _emp_name
+ ON _emp_name.id = _emp_planet.empire_id
+ INNER JOIN users.credentials _creds
+ ON _creds.address_id = _emp_name.owner_id
+ INNER JOIN defs.translations _name
+ ON _name.string_id = resource_name_id
+ AND _name.lang_id = _creds.language_id
+ INNER JOIN defs.ordered_resources_view _res_def
+ USING ( resource_name_id )
+ WHERE _pres.pres_income > 0
+ OR _pres.pres_upkeep > 0
+ ORDER BY _res_def.resource_ordering;
+
+GRANT SELECT
+ ON emp.plist_resources_view
+ TO :dbuser;
+
+
--
-- Actual planet list
--
diff --git a/legacyworlds-server-data/db-structure/tests/admin/040-functions/167-planet-list/010-plist-resources-view.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/167-planet-list/010-plist-resources-view.sql
new file mode 100644
index 0000000..86c18bf
--- /dev/null
+++ b/legacyworlds-server-data/db-structure/tests/admin/040-functions/167-planet-list/010-plist-resources-view.sql
@@ -0,0 +1,78 @@
+/*
+ * Tests for emp.plist_resources_view
+ */
+BEGIN;
+ \i utils/strings.sql
+ \i utils/resources.sql
+ \i utils/accounts.sql
+ \i utils/naming.sql
+ \i utils/universe.sql
+
+ /* Create a couple of resources, three planets and two empire names */
+ SELECT _create_resources( 2 , 'resource' );
+ SELECT _create_raw_planets( 3 , 'planet' );
+ SELECT _create_emp_names( 2 , 'empire' );
+
+ /* One of the empires possesses two planets */
+ SELECT emp.create_empire( _get_emp_name( 'empire1' ) ,
+ _get_map_name( 'planet1' ) ,
+ 200.0 );
+ INSERT INTO emp.planets( empire_id , planet_id )
+ VALUES ( _get_emp_name( 'empire1' ) , _get_map_name( 'planet2' ) );
+
+ /* First planet has income for one resource and upkeep for the other */
+ INSERT INTO verse.planet_resources ( planet_id , resource_name_id , pres_income )
+ VALUES ( _get_map_name( 'planet1' ) , _get_string( 'resource1' ) , 0.23 );
+ INSERT INTO verse.planet_resources ( planet_id , resource_name_id , pres_upkeep )
+ VALUES ( _get_map_name( 'planet1' ) , _get_string( 'resource2' ) , 0.22 );
+
+ /* Second planet has no income or upkeep */
+ INSERT INTO verse.planet_resources ( planet_id , resource_name_id )
+ SELECT _get_map_name( 'planet2' ) , resource_name_id
+ FROM defs.resources;
+
+ /* The second empire has no planets */
+ INSERT INTO emp.empires( name_id , cash )
+ VALUES ( _get_emp_name( 'empire2' ) , 123 );
+
+ /* Third planet has income and upkeep for all resources */
+ INSERT INTO verse.planet_resources ( planet_id , resource_name_id , pres_income , pres_upkeep )
+ SELECT _get_map_name( 'planet3' ) , resource_name_id ,
+ 4 + row_number( ) OVER( ) * 2 , row_number( ) OVER( ) * 2 + 5
+ FROM defs.resources;
+
+ -- ***** TESTS BEGIN HERE *****
+ SELECT plan( 4 );
+
+ SELECT diag_test_name( 'emp.plist_resources_view - No rows for neutral planets' );
+ SELECT is_empty( $$
+ SELECT * FROM emp.plist_resources_view
+ WHERE planet_id = _get_map_name( 'planet3' );
+ $$ );
+
+ SELECT diag_test_name( 'emp.plist_resources_view - No rows for empires with no planets' );
+ SELECT is_empty( $$
+ SELECT * FROM emp.plist_resources_view
+ WHERE empire_id = _get_emp_name( 'empire2' );
+ $$ );
+
+ SELECT diag_test_name( 'emp.plist_resources_view - No rows for owned planets with zero income and upkeep' );
+ SELECT is_empty( $$
+ SELECT * FROM emp.plist_resources_view
+ WHERE planet_id = _get_map_name( 'planet2' );
+ $$ );
+
+ SELECT diag_test_name( 'emp.plist_resources_view - Rows for owned planets with income and upkeep' );
+ SELECT set_eq( $$
+ SELECT empire_id , resource_name , pres_income , pres_upkeep ,
+ civ_investment , mil_investment
+ FROM emp.plist_resources_view
+ WHERE planet_id = _get_map_name( 'planet1' );
+ $$ , $$ VALUES(
+ _get_emp_name( 'empire1' ) , 'Test string #1' , 165 , 0 , 0 , 0
+ ) , (
+ _get_emp_name( 'empire1' ) , 'Test string #2' , 0 , 159 , 0 , 0
+ ) $$ );
+
+ SELECT * FROM finish( );
+ROLLBACK;
\ No newline at end of file
diff --git a/legacyworlds-server-data/db-structure/tests/user/040-functions/167-planet-list/010-plist-resources-view.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/167-planet-list/010-plist-resources-view.sql
new file mode 100644
index 0000000..ddd0cb9
--- /dev/null
+++ b/legacyworlds-server-data/db-structure/tests/user/040-functions/167-planet-list/010-plist-resources-view.sql
@@ -0,0 +1,11 @@
+/*
+ * Test privileges on emp.plist_resources_view
+ */
+BEGIN;
+ SELECT plan( 1 );
+
+ SELECT diag_test_name( 'emp.plist_resources_view - SELECT privilege' );
+ SELECT lives_ok( 'SELECT * FROM emp.plist_resources_view' );
+
+ SELECT * FROM finish( );
+ROLLBACK;
\ No newline at end of file
diff --git a/legacyworlds-server-interfaces/src/main/java/com/deepclone/lw/interfaces/game/resources/ResourcesInformationDAO.java b/legacyworlds-server-interfaces/src/main/java/com/deepclone/lw/interfaces/game/resources/ResourcesInformationDAO.java
index 5c88115..44acfd1 100644
--- a/legacyworlds-server-interfaces/src/main/java/com/deepclone/lw/interfaces/game/resources/ResourcesInformationDAO.java
+++ b/legacyworlds-server-interfaces/src/main/java/com/deepclone/lw/interfaces/game/resources/ResourcesInformationDAO.java
@@ -2,7 +2,9 @@ package com.deepclone.lw.interfaces.game.resources;
import java.util.List;
+import java.util.Map;
+import com.deepclone.lw.cmd.player.gdata.PlanetListResourceRecord;
import com.deepclone.lw.cmd.player.gdata.empire.EmpireResourceRecord;
import com.deepclone.lw.cmd.player.gdata.planets.PlanetResourceRecord;
@@ -40,4 +42,16 @@ public interface ResourcesInformationDAO
* @return the list of empire economic records
*/
public List< EmpireResourceRecord > getEmpireInformation( int empire );
+
+
+ /**
+ * Obtain resources information for an empire's planet list
+ *
+ * @param empire
+ * the empire whose planet list is being generated
+ *
+ * @return a map of planet list resource records associating planet identifiers to lists of
+ * resource records
+ */
+ public Map< Integer , List< PlanetListResourceRecord > > getPlanetListData( int empire );
}
diff --git a/legacyworlds-server-tests/src/test/java/com/deepclone/lw/beans/game/resources/TestPlanetListResourceRecordMapper.java b/legacyworlds-server-tests/src/test/java/com/deepclone/lw/beans/game/resources/TestPlanetListResourceRecordMapper.java
new file mode 100644
index 0000000..3839e80
--- /dev/null
+++ b/legacyworlds-server-tests/src/test/java/com/deepclone/lw/beans/game/resources/TestPlanetListResourceRecordMapper.java
@@ -0,0 +1,91 @@
+package com.deepclone.lw.beans.game.resources;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashMap;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.deepclone.lw.cmd.player.gdata.PlanetListResourceRecord;
+import com.deepclone.lw.testing.MockResultSet;
+
+
+
+/**
+ * Tests for the {@link PlanetListResourceRecordMapper}
+ *
+ * @author E. Benoît
+ */
+public class TestPlanetListResourceRecordMapper
+{
+
+ /** Planet identifier value */
+ private static final int TEST_PLANET_ID = 1;
+
+ /** Income value */
+ private static final long TEST_INCOME = 2L;
+
+ /** Upkeep value */
+ private static final long TEST_UPKEEP = 3L;
+
+ /** Civilian investment value */
+ private static final long TEST_CIV_INVESTMENT = 4L;
+
+ /** Military investment value */
+ private static final long TEST_MIL_INVESTMENT = 5L;
+
+ /** Fake result set used as the data source */
+ private ResultSet data;
+
+ /** Row mapper to test */
+ private PlanetListResourceRecordMapper mapper;
+
+
+ /**
+ * Initialise the row mapper as well as the fake result set
+ */
+ @Before
+ @SuppressWarnings( "unchecked" )
+ public void setUp( )
+ {
+ HashMap< String , Object > row = new HashMap< String , Object >( );
+ row.put( "planet_id" , TEST_PLANET_ID );
+ row.put( "pres_income" , TEST_INCOME );
+ row.put( "pres_upkeep" , TEST_UPKEEP );
+ row.put( "civ_investment" , TEST_CIV_INVESTMENT );
+ row.put( "mil_investment" , TEST_MIL_INVESTMENT );
+
+ this.data = MockResultSet.create( new HashMap[] {
+ row
+ } );
+
+ this.mapper = new PlanetListResourceRecordMapper( );
+ }
+
+
+ /**
+ * Try mapping a row
+ */
+ @Test
+ public void testMapRow( )
+ throws SQLException
+ {
+ this.data.absolute( 1 );
+
+ FullPlanetListRecord fullRecord = this.mapper.mapRow( this.data , 1 );
+ assertEquals( TEST_PLANET_ID , fullRecord.getPlanetId( ) );
+
+ PlanetListResourceRecord record = fullRecord.getRecord( );
+ assertNotNull( record );
+ assertEquals( TEST_INCOME , record.getIncome( ) );
+ assertEquals( TEST_UPKEEP , record.getUpkeep( ) );
+ assertEquals( TEST_CIV_INVESTMENT , record.getCivInvestment( ) );
+ assertEquals( TEST_MIL_INVESTMENT , record.getMilInvestment( ) );
+ }
+
+}
diff --git a/legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata/PlanetListData.java b/legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata/PlanetListData.java
index 27c4571..7814d38 100644
--- a/legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata/PlanetListData.java
+++ b/legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata/PlanetListData.java
@@ -2,331 +2,663 @@ package com.deepclone.lw.cmd.player.gdata;
import java.io.Serializable;
+import java.util.List;
+/**
+ * An entry in the planet list
+ *
+ *
+ * This class represents an entry in the planet list. It contains all available information about a + * single planet. + * + * @author E. Benoît + */ public class PlanetListData implements Serializable { - private static final long serialVersionUID = 1L; + /** + * Serialisation version identifier + * + *
null
if there is no battle */
private Long battle;
+ /**
+ * Gets the identifier of the planet.
+ *
+ * @return the identifier of the planet
+ */
public int getId( )
{
- return id;
+ return this.id;
}
+ /**
+ * Sets the identifier of the planet.
+ *
+ * @param id
+ * the new identifier of the planet
+ */
public void setId( int id )
{
this.id = id;
}
+ /**
+ * Gets the name of the planet.
+ *
+ * @return the name of the planet
+ */
public String getName( )
{
- return name;
+ return this.name;
}
+ /**
+ * Sets the name of the planet.
+ *
+ * @param name
+ * the new name of the planet
+ */
public void setName( String name )
{
this.name = name;
}
+ /**
+ * Gets the abscissa of the planet's system.
+ *
+ * @return the abscissa of the planet's system
+ */
public int getX( )
{
- return x;
+ return this.x;
}
+ /**
+ * Sets the abscissa of the planet's system.
+ *
+ * @param x
+ * the new abscissa of the planet's system
+ */
public void setX( int x )
{
this.x = x;
}
+ /**
+ * Gets the ordinates of the planet's system.
+ *
+ * @return the ordinates of the planet's system
+ */
public int getY( )
{
- return y;
+ return this.y;
}
+ /**
+ * Sets the ordinates of the planet's system.
+ *
+ * @param y
+ * the new ordinates of the planet's system
+ */
public void setY( int y )
{
this.y = y;
}
+ /**
+ * Gets the orbit of the planet in its system.
+ *
+ * @return the orbit of the planet in its system
+ */
public int getOrbit( )
{
- return orbit;
+ return this.orbit;
}
+ /**
+ * Sets the orbit of the planet in its system.
+ *
+ * @param orbit
+ * the new orbit of the planet in its system
+ */
public void setOrbit( int orbit )
{
this.orbit = orbit;
}
+ /**
+ * Gets the current population.
+ *
+ * @return the current population
+ */
public long getPopulation( )
{
- return population;
+ return this.population;
}
+ /**
+ * Sets the current population.
+ *
+ * @param population
+ * the new current population
+ */
public void setPopulation( long population )
{
this.population = population;
}
+ /**
+ * Gets the happiness percentage.
+ *
+ * @return the happiness percentage
+ */
public int getHappiness( )
{
- return happiness;
+ return this.happiness;
}
+ /**
+ * Sets the happiness percentage.
+ *
+ * @param happiness
+ * the new happiness percentage
+ */
public void setHappiness( int happiness )
{
this.happiness = happiness;
}
- public long getIncome( )
+ /**
+ * Gets the resources information records
+ *
+ * @return the resources information records
+ */
+ public List< PlanetListResourceRecord > getResources( )
{
- return income;
+ return this.resources;
}
+ /**
+ * Sets the resources information records
+ *
+ * @param resources
+ * the new resources information records
+ */
+ public void setResources( List< PlanetListResourceRecord > resources )
+ {
+ this.resources = resources;
+ }
+
+
+ /**
+ * Gets the monetary income of the planet.
+ *
+ * @return the monetary income of the planet
+ */
+ public long getIncome( )
+ {
+ return this.income;
+ }
+
+
+ /**
+ * Sets the monetary income of the planet.
+ *
+ * @param income
+ * the new monetary income of the planet
+ */
public void setIncome( long income )
{
this.income = income;
}
+ /**
+ * Gets the monetary upkeep of the planet.
+ *
+ * @return the monetary upkeep of the planet
+ */
public long getUpkeep( )
{
- return upkeep;
+ return this.upkeep;
}
+ /**
+ * Sets the monetary upkeep of the planet.
+ *
+ * @param upkeep
+ * the new monetary upkeep of the planet
+ */
public void setUpkeep( long upkeep )
{
this.upkeep = upkeep;
}
+ /**
+ * Gets the current military production.
+ *
+ * @return the current military production
+ */
public long getMilitaryProduction( )
{
- return militaryProduction;
+ return this.militaryProduction;
}
+ /**
+ * Sets the current military production.
+ *
+ * @param militaryProduction
+ * the new current military production
+ */
public void setMilitaryProduction( long militaryProduction )
{
this.militaryProduction = militaryProduction;
}
+ /**
+ * Gets the current industrial production.
+ *
+ * @return the current industrial production
+ */
public long getIndustrialProduction( )
{
- return industrialProduction;
+ return this.industrialProduction;
}
+ /**
+ * Sets the current industrial production.
+ *
+ * @param industrialProduction
+ * the new current industrial production
+ */
public void setIndustrialProduction( long industrialProduction )
{
this.industrialProduction = industrialProduction;
}
+ /**
+ * Gets the current "extra population growth" production.
+ *
+ * @return the current "extra population growth" production
+ */
public long getGrowthProduction( )
{
- return growthProduction;
+ return this.growthProduction;
}
+ /**
+ * Sets the current "extra population growth" production.
+ *
+ * @param growthProduction
+ * the new current "extra population growth" production
+ */
public void setGrowthProduction( long growthProduction )
{
this.growthProduction = growthProduction;
}
+ /**
+ * Gets the money invested in the civilian queue.
+ *
+ * @return the money invested in the civilian queue
+ */
public long getCivInvestment( )
{
- return civInvestment;
+ return this.civInvestment;
}
+ /**
+ * Sets the money invested in the civilian queue.
+ *
+ * @param civInvestment
+ * the new money invested in the civilian queue
+ */
public void setCivInvestment( long civInvestment )
{
this.civInvestment = civInvestment;
}
+ /**
+ * Gets the amount of buildings in the civilian queue.
+ *
+ * @return the amount of buildings in the civilian queue
+ */
public int getCivAmount( )
{
- return civAmount;
+ return this.civAmount;
}
+ /**
+ * Sets the amount of buildings in the civilian queue.
+ *
+ * @param civAmount
+ * the new amount of buildings in the civilian queue
+ */
public void setCivAmount( int civAmount )
{
this.civAmount = civAmount;
}
+ /**
+ * Checks whether the current operation on the civilian queue is a destruction.
+ *
+ * @return true
if the current operation on the civilian queue is a destruction
+ */
public boolean isCivDestroy( )
{
- return civDestroy;
+ return this.civDestroy;
}
+ /**
+ * Sets whether the current operation on the civilian queue is a destruction.
+ *
+ * @param civDestroy
+ * true
if the current operation on the civilian queue is a destruction
+ */
public void setCivDestroy( boolean civDestroy )
{
this.civDestroy = civDestroy;
}
+ /**
+ * Gets the name of the buildings being destroyed or constructed.
+ *
+ * @return the name of the buildings being destroyed or constructed
+ */
public String getCivName( )
{
- return civName;
+ return this.civName;
}
+ /**
+ * Sets the name of the buildings being destroyed or constructed.
+ *
+ * @param civName
+ * the new name of the buildings being destroyed or constructed
+ */
public void setCivName( String civName )
{
this.civName = civName;
}
+ /**
+ * Gets the money invested in the military build queue.
+ *
+ * @return the money invested in the military build queue
+ */
public long getMilInvestment( )
{
- return milInvestment;
+ return this.milInvestment;
}
+ /**
+ * Sets the money invested in the military build queue.
+ *
+ * @param milInvestment
+ * the new money invested in the military build queue
+ */
public void setMilInvestment( long milInvestment )
{
this.milInvestment = milInvestment;
}
+ /**
+ * Gets the amount of ships in the civilian queue.
+ *
+ * @return the amount of ships in the civilian queue
+ */
public int getMilAmount( )
{
- return milAmount;
+ return this.milAmount;
}
+ /**
+ * Sets the amount of ships in the civilian queue.
+ *
+ * @param milAmount
+ * the new amount of ships in the civilian queue
+ */
public void setMilAmount( int milAmount )
{
this.milAmount = milAmount;
}
+ /**
+ * Gets the name of the ships being constructed.
+ *
+ * @return the name of the ships being constructed
+ */
public String getMilName( )
{
- return milName;
+ return this.milName;
}
+ /**
+ * Sets the name of the ships being constructed.
+ *
+ * @param milName
+ * the new name of the ships being constructed
+ */
public void setMilName( String milName )
{
this.milName = milName;
}
+ /**
+ * Gets the fleet power from turrets.
+ *
+ * @return the fleet power from turrets
+ */
public long getFpStatic( )
{
- return fpStatic;
+ return this.fpStatic;
}
+ /**
+ * Sets the fleet power from turrets.
+ *
+ * @param fpStatic
+ * the new fleet power from turrets
+ */
public void setFpStatic( long fpStatic )
{
this.fpStatic = fpStatic;
}
+ /**
+ * Gets the power of the owner's fleets.
+ *
+ * @return the power of the owner's fleets
+ */
public long getFpOwn( )
{
- return fpOwn;
+ return this.fpOwn;
}
+ /**
+ * Sets the power of the owner's fleets.
+ *
+ * @param fpOwn
+ * the new power of the owner's fleets
+ */
public void setFpOwn( long fpOwn )
{
this.fpOwn = fpOwn;
}
+ /**
+ * Gets the power of the friendly fleets.
+ *
+ * @return the power of the friendly fleets
+ */
public long getFpFriendly( )
{
- return fpFriendly;
+ return this.fpFriendly;
}
+ /**
+ * Sets the power of the friendly fleets.
+ *
+ * @param fpFriendly
+ * the new power of the friendly fleets
+ */
public void setFpFriendly( long fpFriendly )
{
this.fpFriendly = fpFriendly;
}
+ /**
+ * Gets the power of the hostile fleets.
+ *
+ * @return the power of the hostile fleets
+ */
public long getFpHostile( )
{
- return fpHostile;
+ return this.fpHostile;
}
+ /**
+ * Sets the power of the hostile fleets.
+ *
+ * @param fpHostile
+ * the new power of the hostile fleets
+ */
public void setFpHostile( long fpHostile )
{
this.fpHostile = fpHostile;
}
+ /**
+ * Gets the battle identifier or null
if there is no battle.
+ *
+ * @return the battle identifier or null
if there is no battle
+ */
public Long getBattle( )
{
- return battle;
+ return this.battle;
}
+ /**
+ * Sets the battle identifier.
+ *
+ * @param battle
+ * the new battle identifier or null
if there is no battle
+ */
public void setBattle( Long battle )
{
this.battle = battle;
diff --git a/legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata/PlanetListResourceRecord.java b/legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata/PlanetListResourceRecord.java
new file mode 100644
index 0000000..d1c16ac
--- /dev/null
+++ b/legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata/PlanetListResourceRecord.java
@@ -0,0 +1,161 @@
+package com.deepclone.lw.cmd.player.gdata;
+
+
+import java.io.Serializable;
+
+
+
+/**
+ * A resource record for the planet list
+ *
+ * + * This class is used by {@link PlanetListData} to carry information about resources for the planet + * list page. + * + * @author E. Benoît + */ +public class PlanetListResourceRecord + implements Serializable + +{ + + /** + * Serialisation version identifier + * + *