Resources information on planet list

* Added resource information records to the planet list's response.

* Added a database view and the corresponding row mapper and DAO method
which can be used as the data source for the planet list's resource
information. For now this view always returns 0 for both civilian and
military investments.

* Added new tab to display resource information on the planet list page.
The old version of the economy tab will be kept until the corresponding
data no longer exists.

* The following SQL scripts must be re-executed to upgrade a database:
  -> 040-functions/167-planet-list.sql
This commit is contained in:
Emmanuel BENOîT 2012-02-15 14:45:43 +01:00
parent bf6bea5a79
commit 96670d45be
15 changed files with 1079 additions and 31 deletions

View file

@ -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
*
* <p>
* This class is used as an intermediary to extract {@link PlanetListResourceRecord} instances from
* <code>emp.plist_resources_view</code>. It contains the instance itself, and an additional field
* which indicates the planet's identifier.
*
* <p>
* Instances of this class are returned by {@link PlanetListResourceRecordMapper} and then processed
* to generate the map returned by {@link ResourcesInformationDAOBean#getPlanetListData(int)}.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*
*/
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;
}
}

View file

@ -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
*
* <p>
* This class is responsible for mapping rows from <code>emp.plist_resources_view</code> into
* {@link FullPlanetListRecord} instances.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
class PlanetListResourceRecordMapper
implements RowMapper< FullPlanetListRecord >
{
/**
* Map a row from <code>emp.plist_resources_view</code>
*
* <p>
* Convert a row from <code>emp.plist_resources_view</code> 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
*
* <p>
* 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" ) );
}
}

View file

@ -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
*
* <p>
* This implementation queries <code>emp.plist_resources_view</code> 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;
}
}

View file

@ -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 );
}

View file

@ -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
--

View file

@ -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;

View file

@ -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;

View file

@ -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 );
}

View file

@ -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 <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
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( ) );
}
}

View file

@ -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
*
* <p>
* This class represents an entry in the planet list. It contains all available information about a
* single planet.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class PlanetListData
implements Serializable
{
private static final long serialVersionUID = 1L;
/**
* Serialisation version identifier
*
* <ul>
* <li>Introduced in B6M1 with ID 1
* <li>Modified in B6M2, ID set to 2
* </ul>
*/
private static final long serialVersionUID = 2L;
/** Identifier of the planet */
private int id;
/** Name of the planet */
private String name;
/** Abscissa of the planet's system */
private int x;
/** Ordinates of the planet's system */
private int y;
/** Orbit of the planet in its system */
private int orbit;
/** Current population */
private long population;
/** Happiness percentage */
private int happiness;
/** Resources information (income, upkeep, etc...) */
private List< PlanetListResourceRecord > resources;
/** Monetary income of the planet */
private long income;
/** Monetary upkeep of the planet */
private long upkeep;
/** Current military production */
private long militaryProduction;
/** Current industrial production */
private long industrialProduction;
/** Current "extra population growth" production */
private long growthProduction;
/** Money invested in the civilian queue */
private long civInvestment;
/** Amount of buildings in the civilian queue */
private int civAmount;
/** Whether the current operation on the civilian queue is a destruction */
private boolean civDestroy;
/** Name of the buildings being destroyed or constructed */
private String civName;
/** Money invested in the military build queue */
private long milInvestment;
/** Amount of ships in the civilian queue */
private int milAmount;
/** Name of the ships being constructed */
private String milName;
/** Fleet power from turrets */
private long fpStatic;
/** Power of the owner's fleets */
private long fpOwn;
/** Power of the friendly fleets */
private long fpFriendly;
/** Power of the hostile fleets */
private long fpHostile;
/** Battle identifier or <code>null</code> 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 <code>true</code> 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
* <code>true</code> 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 <code>null</code> if there is no battle.
*
* @return the battle identifier or <code>null</code> if there is no battle
*/
public Long getBattle( )
{
return battle;
return this.battle;
}
/**
* Sets the battle identifier.
*
* @param battle
* the new battle identifier or <code>null</code> if there is no battle
*/
public void setBattle( Long battle )
{
this.battle = battle;

View file

@ -0,0 +1,161 @@
package com.deepclone.lw.cmd.player.gdata;
import java.io.Serializable;
/**
* A resource record for the planet list
*
* <p>
* This class is used by {@link PlanetListData} to carry information about resources for the planet
* list page.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class PlanetListResourceRecord
implements Serializable
{
/**
* Serialisation version identifier
*
* <ul>
* <li>Introduced in B6M2 with ID 1
* </ul>
*/
private static final long serialVersionUID = 1L;
/** The name of the resource */
private String name;
/** The income for that resource type */
private long income;
/** The upkeep for that resource type */
private long upkeep;
/** The amount of that resource invested into the civilian construction queue */
private long civInvestment;
/** The amount of that resource invested into the military construction queue */
private long milInvestment;
/**
* Gets the name of the resource.
*
* @return the name of the resource
*/
public String getName( )
{
return this.name;
}
/**
* Sets the name of the resource.
*
* @param name
* the new name of the resource
*/
public void setName( String name )
{
this.name = name;
}
/**
* Gets the income for that resource type.
*
* @return the income for that resource type
*/
public long getIncome( )
{
return this.income;
}
/**
* Sets the income for that resource type.
*
* @param income
* the new income for that resource type
*/
public void setIncome( long income )
{
this.income = income;
}
/**
* Gets the upkeep for that resource type.
*
* @return the upkeep for that resource type
*/
public long getUpkeep( )
{
return this.upkeep;
}
/**
* Sets the upkeep for that resource type.
*
* @param upkeep
* the new upkeep for that resource type
*/
public void setUpkeep( long upkeep )
{
this.upkeep = upkeep;
}
/**
* Gets the amount of that resource invested into the civilian construction queue.
*
* @return the amount of that resource invested into the civilian construction queue
*/
public long getCivInvestment( )
{
return this.civInvestment;
}
/**
* Sets the amount of that resource invested into the civilian construction queue.
*
* @param civInvestment
* the new amount of that resource invested into the civilian construction queue
*/
public void setCivInvestment( long civInvestment )
{
this.civInvestment = civInvestment;
}
/**
* Gets the amount of that resource invested into the military construction queue.
*
* @return the amount of that resource invested into the military construction queue
*/
public long getMilInvestment( )
{
return this.milInvestment;
}
/**
* Sets the amount of that resource invested into the military construction queue.
*
* @param milInvestment
* the new amount of that resource invested into the military construction queue
*/
public void setMilInvestment( long milInvestment )
{
this.milInvestment = milInvestment;
}
}

View file

@ -28,7 +28,7 @@
</@listview>
</@tab>
<@tab id="eco" title="Economy">
<@tab id="eco" title="Economy (OLD)">
<@listview>
<@lv_line headers=true>
<@lv_column width="x">Name</@lv_column>
@ -56,6 +56,9 @@
</@listview>
</@tab>
<#include "planets/economy.ftl" />
<@RenderEconomy />
<@tab id="prod" title="Production">
<@listview>
<@lv_line headers=true>

View file

@ -0,0 +1,56 @@
<#macro RenderEconomy>
<@tab id="economy" title="Economy">
<@listview>
<@lv_line headers=true>
<@lv_column width="x">Name</@lv_column>
<@lv_column width="x">Resource</@lv_column>
<@lv_column width=110 right=true>Income</@lv_column>
<@lv_column width=110 right=true>Upkeep</@lv_column>
<@lv_column width=110 right=true>Profit</@lv_column>
</@lv_line>
<#list pl as planet>
<#if planet.resources?size = 0>
<@lv_line>
<@lv_column><a href="planet-${planet.id}#resources">${planet.name?xhtml}</a></@lv_column>
<@lv_column colspan=4 centered=true><em>No income or upkeep</em></@lv_column>
</@lv_line>
<#else>
<#list planet.resources as resource>
<@lv_line>
<@lv_column>
<#if resource_index = 0>
<a href="planet-${planet.id}#resources">${planet.name?xhtml}</a>
<#else>
&nbsp;
</#if>
</@lv_column>
<@lv_column>${resource.name?xhtml}</@lv_column>
<@lv_column right=true>${resource.income?string(",##0")}</@lv_column>
<@lv_column right=true>${resource.upkeep?string(",##0")}</@lv_column>
<@lv_column right=true>
<#if resource.upkeep gt resource.income>
<span style="color: red">
</#if>
${( resource.income - resource.upkeep )?string(",##0")}
<#if resource.upkeep gt resource.income>
</span>
</#if>
</@lv_column>
</@lv_line>
</#list>
</#if>
</#list>
<@lv_line headers=true>
<@lv_column width="x" colspan=6>&nbsp;</@lv_column>
</@lv_line>
<@lv_line>
<@lv_column centered=true colspan=6>
Incomes, upkeeps and profits are displayed for a period of one game month (12 actual hours).
</@lv_column>
</@lv_line>
</@listview>
</@tab>
</#macro>

View file

@ -28,7 +28,7 @@
</@listview>
</@tab>
<@tab id="eco" title="Économie">
<@tab id="eco" title="Économie (VIEUX)">
<@listview>
<@lv_line headers=true>
<@lv_column width="x">Nom</@lv_column>
@ -56,6 +56,9 @@
</@listview>
</@tab>
<#include "planets/economy.ftl" />
<@RenderEconomy />
<@tab id="prod" title="Production">
<@listview>
<@lv_line headers=true>

View file

@ -0,0 +1,56 @@
<#macro RenderEconomy>
<@tab id="economy" title="Economie">
<@listview>
<@lv_line headers=true>
<@lv_column width="x">Name</@lv_column>
<@lv_column width="x">Resource</@lv_column>
<@lv_column width=110 right=true>Revenus</@lv_column>
<@lv_column width=110 right=true>Charges</@lv_column>
<@lv_column width=110 right=true>Bénéfices</@lv_column>
</@lv_line>
<#list pl as planet>
<#if planet.resources?size = 0>
<@lv_line>
<@lv_column><a href="planet-${planet.id}#resources">${planet.name?xhtml}</a></@lv_column>
<@lv_column colspan=4 centered=true><em>Aucune entrée pour cette planète</em></@lv_column>
</@lv_line>
<#else>
<#list planet.resources as resource>
<@lv_line>
<@lv_column>
<#if resource_index = 0>
<a href="planet-${planet.id}#resources">${planet.name?xhtml}</a>
<#else>
&nbsp;
</#if>
</@lv_column>
<@lv_column>${resource.name?xhtml}</@lv_column>
<@lv_column right=true>${resource.income?string(",##0")}</@lv_column>
<@lv_column right=true>${resource.upkeep?string(",##0")}</@lv_column>
<@lv_column right=true>
<#if resource.upkeep gt resource.income>
<span style="color: red">
</#if>
${( resource.income - resource.upkeep )?string(",##0")}
<#if resource.upkeep gt resource.income>
</span>
</#if>
</@lv_column>
</@lv_line>
</#list>
</#if>
</#list>
<@lv_line headers=true>
<@lv_column width="x" colspan=6>&nbsp;</@lv_column>
</@lv_line>
<@lv_line>
<@lv_column centered=true colspan=6>
Les revenus, charges et bénéfices sont indiqués pour une durée d'un mois en temps de jeu, soit 12 heures réelles.
</@lv_column>
</@lv_line>
</@listview>
</@tab>
</#macro>