Mining settings in XML dumps
* Empire mining settings have been included in the empire's resource information records * Planet-specific mining settings have been included in the resource provider information records
This commit is contained in:
parent
9b346a80c2
commit
3637b6e1d1
11 changed files with 380 additions and 70 deletions
legacyworlds-server-beans-bt/src/main/java/com/deepclone/lw/beans/bt/es
|
@ -28,7 +28,8 @@ final class EmpireResourceInformationMapper
|
|||
*
|
||||
* <p>
|
||||
* Create a new {@link EmpireResourceInformation} instance and set its fields using the row's
|
||||
* contents.
|
||||
* contents. If a mining priority is present, set it, otherwise leave the field to its default
|
||||
* <code>null</code> value.
|
||||
*/
|
||||
@Override
|
||||
public EmpireResourceInformation mapRow( ResultSet rs , int rowNum )
|
||||
|
@ -40,6 +41,11 @@ final class EmpireResourceInformationMapper
|
|||
empRes.setOwed( rs.getDouble( "empres_owed" ) );
|
||||
empRes.setPossessed( rs.getDouble( "empres_possessed" ) );
|
||||
|
||||
int priority = rs.getInt( "mining_priority" );
|
||||
if ( !rs.wasNull( ) ) {
|
||||
empRes.setMiningPriority( priority );
|
||||
}
|
||||
|
||||
return empRes;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ class ResourceRowMapper
|
|||
* <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.
|
||||
* {@link ResourceProviderInformation} instance to the result, and set its mining priority if
|
||||
* one exists.
|
||||
*/
|
||||
@Override
|
||||
public PlanetResourceRow mapRow( ResultSet rs , int rowNum )
|
||||
|
@ -48,6 +49,12 @@ class ResourceRowMapper
|
|||
rpi.setCurrentQuantity( rs.getDouble( "resprov_quantity" ) );
|
||||
rpi.setDifficulty( rs.getDouble( "resprov_difficulty" ) );
|
||||
rpi.setRecovery( rs.getDouble( "resprov_recovery" ) );
|
||||
|
||||
int miningPriority = rs.getInt( "mining_priority" );
|
||||
if ( !rs.wasNull( ) ) {
|
||||
rpi.setMiningPriority( miningPriority );
|
||||
}
|
||||
|
||||
row.setProvider( rpi );
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
|||
*
|
||||
* <p>
|
||||
* This class is used to store information about an empire's resources in debugging XML dumps. Each
|
||||
* instance indicates the amount possessed or owed for a given type of resources.
|
||||
* instance indicates the amount possessed or owed for a given type of resources, as well as the
|
||||
* mining priority if it is a natural resource.
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*/
|
||||
|
@ -36,6 +37,14 @@ public class EmpireResourceInformation
|
|||
@XStreamAsAttribute
|
||||
private Double owed;
|
||||
|
||||
/**
|
||||
* The mining priority for this type of resource, or <code>null</code> if it is not a natural
|
||||
* resource
|
||||
*/
|
||||
@XStreamAlias( "mining-priority" )
|
||||
@XStreamAsAttribute
|
||||
private Integer miningPriority;
|
||||
|
||||
|
||||
/** @return the type of resources */
|
||||
public String getResource( )
|
||||
|
@ -100,4 +109,26 @@ public class EmpireResourceInformation
|
|||
this.owed = owed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the mining priority for this type of resource, or <code>null</code> if it is not a
|
||||
* natural resource
|
||||
*/
|
||||
public Integer getMiningPriority( )
|
||||
{
|
||||
return this.miningPriority;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the mining priority for this type of resource
|
||||
*
|
||||
* @param miningPriority
|
||||
* the mining priority for this type of resource
|
||||
*/
|
||||
public void setMiningPriority( int miningPriority )
|
||||
{
|
||||
this.miningPriority = miningPriority;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,11 @@ public class ResourceProviderInformation
|
|||
@XStreamAsAttribute
|
||||
private Double recovery;
|
||||
|
||||
/** Planet-specific mining priority */
|
||||
@XStreamAlias( "mining-priority" )
|
||||
@XStreamAsAttribute
|
||||
private Integer miningPriority;
|
||||
|
||||
|
||||
/** @return the resource's identifier */
|
||||
public String getResource( )
|
||||
|
@ -149,4 +154,26 @@ public class ResourceProviderInformation
|
|||
this.recovery = recovery;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the planet-specific mining priority, or <code>null</code> if the empire's global
|
||||
* settings are in used
|
||||
*/
|
||||
public Integer getMiningPriority( )
|
||||
{
|
||||
return this.miningPriority;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the planet-specific mining priority
|
||||
*
|
||||
* @param miningPriority
|
||||
* the planet-specific mining priority
|
||||
*/
|
||||
public void setMiningPriority( int miningPriority )
|
||||
{
|
||||
this.miningPriority = miningPriority;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue