Importing SVN archives - Trunk
This commit is contained in:
parent
fc4c6bd340
commit
ff53af6668
507 changed files with 8866 additions and 2450 deletions
legacyworlds-server/legacyworlds-server-interfaces
pom.xml
src/main/java/com/deepclone/lw/interfaces
|
@ -4,12 +4,12 @@
|
|||
<parent>
|
||||
<artifactId>legacyworlds-server</artifactId>
|
||||
<groupId>com.deepclone.lw</groupId>
|
||||
<version>5.99.1</version>
|
||||
<version>5.99.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.deepclone.lw</groupId>
|
||||
<artifactId>legacyworlds-server-interfaces</artifactId>
|
||||
<version>5.99.1</version>
|
||||
<version>5.99.2</version>
|
||||
|
||||
<name>Legacy Worlds server interfaces</name>
|
||||
<description>This package contains interfaces for all beans provided by the various server components.</description>
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.deepclone.lw.cmd.ObjectNameError;
|
|||
import com.deepclone.lw.cmd.player.gdata.NameIdPair;
|
||||
import com.deepclone.lw.cmd.player.gdata.PlanetListData;
|
||||
import com.deepclone.lw.cmd.player.gdata.empire.OverviewData;
|
||||
import com.deepclone.lw.sqld.game.EmpireTechLine;
|
||||
import com.deepclone.lw.sqld.game.GeneralInformation;
|
||||
|
||||
|
||||
|
@ -24,12 +23,6 @@ public interface EmpireDAO
|
|||
public OverviewData getOverview( int empireId );
|
||||
|
||||
|
||||
public List< EmpireTechLine > getTechnology( int empireId );
|
||||
|
||||
|
||||
public void implementTechnology( int empireId , int lineId );
|
||||
|
||||
|
||||
public List< PlanetListData > getPlanetList( int empireId );
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.deepclone.lw.cmd.player.ListPlanetsResponse;
|
|||
import com.deepclone.lw.cmd.player.EmpireResponse;
|
||||
import com.deepclone.lw.cmd.player.elist.EnemyListResponse;
|
||||
import com.deepclone.lw.cmd.player.gdata.GamePageData;
|
||||
import com.deepclone.lw.interfaces.i18n.LanguageTranslator;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
@ -19,12 +20,19 @@ public interface EmpireManagement
|
|||
public GamePageData getGeneralInformation( int empireId );
|
||||
|
||||
|
||||
/**
|
||||
* Generate a translation interface in the language used by the account who controls an empire.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @return the translation interface
|
||||
*/
|
||||
public LanguageTranslator getTranslator( int empireId );
|
||||
|
||||
|
||||
public EmpireResponse getOverview( int empireId );
|
||||
|
||||
|
||||
public EmpireResponse implementTechnology( int empireId , int techId );
|
||||
|
||||
|
||||
public ListPlanetsResponse getPlanetList( int empireId );
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package com.deepclone.lw.interfaces.game;
|
||||
|
||||
|
||||
public interface UpdatesDAO
|
||||
{
|
||||
public boolean processUpdates( long tickId );
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.deepclone.lw.interfaces.game.techs;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.deepclone.lw.sqld.game.techs.EmpireTechnology;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface for the empire technology and research data access component.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface EmpireTechnologyDAO
|
||||
{
|
||||
/**
|
||||
* List the technologies (implemented, researched and being researched) for the empire.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier.
|
||||
* @return the list of technology records for the empire.
|
||||
*/
|
||||
public List< EmpireTechnology > getTechnologies( int empireId );
|
||||
|
||||
|
||||
/**
|
||||
* Implement a technology for an empire.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @param technology
|
||||
* the technology's name
|
||||
* @return an error code:
|
||||
* <ul>
|
||||
* <li>0 on success,</li>
|
||||
* <li>1 if the technology does not exist or is not in the correct status,</li>
|
||||
* <li>2 if the empire does not have sufficient resources.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int implementTechnology( int empireId , String technology );
|
||||
|
||||
|
||||
/**
|
||||
* Prepare the temporary table used for a research priorities update.
|
||||
*/
|
||||
public void startPrioritiesUpdate( );
|
||||
|
||||
|
||||
/**
|
||||
* Upload new research priority values into the temporary table used for priority updates.
|
||||
*
|
||||
* @param priorities
|
||||
* the map associating relative technology identifiers with priority values
|
||||
*/
|
||||
public void uploadPriorities( Map< String , Integer > priorities );
|
||||
|
||||
|
||||
/**
|
||||
* Execute prepared research priority updates for an empire.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire's identifier
|
||||
* @return an error code:
|
||||
* <ul>
|
||||
* <li>0 on success,</li>
|
||||
* <li>1 if the listed technologies do not match the empire's current research,</li>
|
||||
* <li>2 if the new priorities were invalid.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int finishPrioritiesUpdate( int empireId );
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.deepclone.lw.interfaces.game.techs;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.deepclone.lw.cmd.player.research.ResearchOperationResponse;
|
||||
import com.deepclone.lw.cmd.player.research.ViewResearchResponse;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface for the empire research and technology management component.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface EmpireTechnologyManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Generate the response to a research view request.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire for whom the research view is being displayed.
|
||||
* @return the response containing the view
|
||||
*/
|
||||
public ViewResearchResponse getResearchData( int empireId );
|
||||
|
||||
|
||||
/**
|
||||
* Implement a technology for an empire.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire trying to implement a technology.
|
||||
* @param technology
|
||||
* the name of the technology to implement
|
||||
*
|
||||
* @return the response describing the result of the operation
|
||||
*/
|
||||
public ResearchOperationResponse implementTechnology( int empireId , String technology );
|
||||
|
||||
|
||||
/**
|
||||
* Set an empire's research priorities.
|
||||
*
|
||||
* @param empireId
|
||||
* the empire trying to set its research priorities.
|
||||
* @param priorities
|
||||
* a map associating relative technology identifiers to priorities.
|
||||
*
|
||||
* @return the response describing the result of the operation
|
||||
*/
|
||||
public ResearchOperationResponse setResearchPriorities( int empireId , Map< String , Integer > priorities );
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.deepclone.lw.interfaces.game.techs;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.deepclone.lw.sqld.game.techs.ResearchUpdateInput;
|
||||
import com.deepclone.lw.sqld.game.techs.ResearchUpdateOutput;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Data access component for research updates.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface ResearchUpdateDAO
|
||||
{
|
||||
|
||||
/**
|
||||
* Prepare the database for a research update batch.
|
||||
*
|
||||
* @param updateId
|
||||
* the current update's identifier
|
||||
*/
|
||||
public void prepareUpdate( long updateId );
|
||||
|
||||
|
||||
/**
|
||||
* Access the update's information.
|
||||
*
|
||||
* @param updateId
|
||||
* the current update's identifier
|
||||
* @return the current research status for the empires in the current batch.
|
||||
*/
|
||||
public List< ResearchUpdateInput > getUpdateData( long updateId );
|
||||
|
||||
|
||||
/**
|
||||
* Load the amount of research points for each empire in the update.
|
||||
*
|
||||
* @param updateId
|
||||
* the current update's identifier.
|
||||
* @return a map which associates empire identifiers to amounts of research points.
|
||||
*/
|
||||
public Map< Integer , Double > getResearchPoints( long updateId );
|
||||
|
||||
|
||||
/**
|
||||
* Submit the output of the research update.
|
||||
*
|
||||
* @param output
|
||||
* a list of changes to commit to the database
|
||||
*/
|
||||
public void submitUpdateData( List< ResearchUpdateOutput > output );
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.deepclone.lw.interfaces.game.techs;
|
||||
|
||||
|
||||
import com.deepclone.lw.sqld.game.techs.TechGraph;
|
||||
import com.deepclone.lw.sqld.game.techs.TechGraphException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Data access component for the technology graph.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface TechnologyGraphDAO
|
||||
{
|
||||
|
||||
/**
|
||||
* Load the technology graph from the database.
|
||||
*
|
||||
* @return the technology graph's representation
|
||||
* @throws TechGraphException
|
||||
* if some logic error occurs while the graph is being loaded (for example, circular
|
||||
* dependencies).
|
||||
*/
|
||||
public TechGraph loadGraph( )
|
||||
throws TechGraphException;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.deepclone.lw.interfaces.game.techs;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.deepclone.lw.cmd.admin.techs.TechCategory;
|
||||
import com.deepclone.lw.sqld.game.techs.TechGraph;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface for the technology graph manager, which allows queries on the technology graph, as well
|
||||
* as updates.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface TechnologyGraphManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Access a copy of the tech graph as it exists in the server's memory. This copy includes all
|
||||
* local changes.
|
||||
*
|
||||
* @return a copy of the tech graph
|
||||
*/
|
||||
public TechGraph getGraph( );
|
||||
|
||||
|
||||
/**
|
||||
* List all technology categories from the tech graph.
|
||||
*
|
||||
* @return the list of technology categories
|
||||
*/
|
||||
public List< TechCategory > listCategories( );
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.deepclone.lw.interfaces.game.updates;
|
||||
|
||||
|
||||
/**
|
||||
* Runtime exception indicating a duplicate game update phase handler registration.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public class DuplicateUpdateHandler
|
||||
extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final GameUpdatePhase phase;
|
||||
|
||||
|
||||
public DuplicateUpdateHandler( GameUpdatePhase phase )
|
||||
{
|
||||
super( "duplicate handler for phase " + phase.toString( ) );
|
||||
this.phase = phase;
|
||||
}
|
||||
|
||||
|
||||
public GameUpdatePhase getPhase( )
|
||||
{
|
||||
return phase;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.deepclone.lw.interfaces.game.updates;
|
||||
|
||||
|
||||
/**
|
||||
* Interface to the main game update component.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface GameUpdate
|
||||
{
|
||||
|
||||
/**
|
||||
* Register a handler component for a game update phase.
|
||||
*
|
||||
* @param handler
|
||||
* the handler to register
|
||||
*
|
||||
* @throws DuplicateUpdateHandler
|
||||
* if a handler has already been registered for the game update phase returned by
|
||||
* the new handler's {@link GameUpdatePhaseHandler#getPhase()} method.
|
||||
*/
|
||||
public void registerHandler( GameUpdatePhaseHandler handler )
|
||||
throws DuplicateUpdateHandler;
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.deepclone.lw.interfaces.game.updates;
|
||||
|
||||
|
||||
/**
|
||||
* The various phases of a game update. This enumeration should reflect the <em>update_type</em> SQL
|
||||
* type.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public enum GameUpdatePhase {
|
||||
|
||||
/** Empire income and upkeep computation */
|
||||
EMPIRE_MONEY( GameUpdateTarget.EMPIRE ) ,
|
||||
|
||||
/** Empire research update */
|
||||
EMPIRE_RESEARCH( GameUpdateTarget.EMPIRE ) ,
|
||||
|
||||
/** Debt effects computation */
|
||||
EMPIRE_DEBT( GameUpdateTarget.EMPIRE ) ,
|
||||
|
||||
/** Arrival of fleets on planets */
|
||||
PLANET_FLEET_ARRIVALS( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Fleet movement computation */
|
||||
PLANET_FLEET_MOVEMENTS( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Fleet status counter decrease */
|
||||
PLANET_FLEET_STATUS( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Check for new battles */
|
||||
PLANET_BATTLE_START( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Main battle computation */
|
||||
PLANET_BATTLE_MAIN( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Check for battles that have ended */
|
||||
PLANET_BATTLE_END( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Abandon planets */
|
||||
PLANET_ABANDON( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Construct/destroy buildings */
|
||||
PLANET_CONSTRUCTION( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Construct/destroy ships */
|
||||
PLANET_MILITARY( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Update planetary population */
|
||||
PLANET_POPULATION( GameUpdateTarget.PLANET ) ,
|
||||
|
||||
/** Compute planet income */
|
||||
PLANET_MONEY( GameUpdateTarget.PLANET );
|
||||
|
||||
private final GameUpdateTarget target;
|
||||
|
||||
|
||||
private GameUpdatePhase( GameUpdateTarget target )
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
|
||||
/** @return the type of target affected by the update */
|
||||
public GameUpdateTarget getTarget( )
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.deepclone.lw.interfaces.game.updates;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for handlers that implement a phase of the game update.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface GameUpdatePhaseHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* @return the game update phase this handler is responsible for.
|
||||
*/
|
||||
public GameUpdatePhase getPhase( );
|
||||
|
||||
|
||||
/**
|
||||
* Prepare the handler.
|
||||
*
|
||||
* This method is called outside of any transaction before the update starts.
|
||||
*
|
||||
* @param updateId
|
||||
* the update's identifier
|
||||
*/
|
||||
public void onPhaseStart( long updateId );
|
||||
|
||||
|
||||
/**
|
||||
* Update the game.
|
||||
*
|
||||
* @param updateId
|
||||
* the update's identifier.
|
||||
*
|
||||
* @return <code>true</code> if there are more updates of this type to process,
|
||||
* <code>false</code> if the phase is complete
|
||||
*/
|
||||
public boolean updateGame( long updateId );
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.deepclone.lw.interfaces.game.updates;
|
||||
|
||||
|
||||
/**
|
||||
* The type of item targeted by a game update phase.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public enum GameUpdateTarget {
|
||||
|
||||
/** Empire update */
|
||||
EMPIRE ,
|
||||
|
||||
/** Planet update */
|
||||
PLANET
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.deepclone.lw.interfaces.game.updates;
|
||||
|
||||
|
||||
/**
|
||||
* Interface of the game update data access component.
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface UpdatesDAO
|
||||
{
|
||||
|
||||
/**
|
||||
* Prepare a batch of game updates.
|
||||
*
|
||||
* @param updateId
|
||||
* game update identifier
|
||||
* @param phase
|
||||
* phase of the update
|
||||
*
|
||||
* @return <code>true</code> if there are game updates to process in the specified phase,
|
||||
* <code>false</code> if all updates in the current phase have been handled.
|
||||
*/
|
||||
public boolean prepareUpdates( long updateId , GameUpdatePhase phase );
|
||||
|
||||
|
||||
/**
|
||||
* Execute a game update phase that is implemented as a stored procedure.
|
||||
*
|
||||
* @param updateId
|
||||
* game update identifier
|
||||
* @param phase
|
||||
* phase of the game update to execute
|
||||
*/
|
||||
public void executeProceduralUpdate( long updateId , GameUpdatePhase phase );
|
||||
|
||||
|
||||
/**
|
||||
* Mark a set of update records as processed.
|
||||
*
|
||||
* @param updateId
|
||||
* game update identifier
|
||||
* @param phase
|
||||
* current phase of the game update
|
||||
*/
|
||||
public void validateUpdatedRecords( long updateId , GameUpdatePhase phase );
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.deepclone.lw.interfaces.i18n;
|
||||
|
||||
|
||||
/**
|
||||
* Translation interface specific to a language
|
||||
*
|
||||
* @author tseeker
|
||||
*/
|
||||
public interface LanguageTranslator
|
||||
{
|
||||
|
||||
/** @return the code of the interface's language */
|
||||
public String getLanguage( );
|
||||
|
||||
|
||||
/** @return the name of the interface's language */
|
||||
public String getLanguageName( );
|
||||
|
||||
|
||||
/**
|
||||
* Translate a string.
|
||||
*
|
||||
* @param string
|
||||
* the string identifier
|
||||
* @return the string's translation in the interface's language
|
||||
* @throws UnknownStringException
|
||||
* if the string does not exist
|
||||
*/
|
||||
public String translate( String string )
|
||||
throws UnknownStringException;
|
||||
}
|
|
@ -62,4 +62,17 @@ public interface Translator
|
|||
*/
|
||||
public String translate( String language , String string )
|
||||
throws UnknownStringException , UnknownLanguageException;
|
||||
|
||||
|
||||
/**
|
||||
* Initialise a translator for a specific language
|
||||
*
|
||||
* @param language
|
||||
* the identifier of the language
|
||||
* @return a translation interface for the language
|
||||
* @throws UnknownLanguageException
|
||||
* if the specified language does not exist or is not supported
|
||||
*/
|
||||
public LanguageTranslator getLanguageTranslator( String language )
|
||||
throws UnknownLanguageException;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.deepclone.lw.interfaces.sys;
|
|||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
|
@ -32,15 +31,15 @@ public interface ConstantsManager
|
|||
|
||||
|
||||
/**
|
||||
* Registers a constants user, which will need to be informed of the constants' changes. If the
|
||||
* Register a constants user, which will need to be informed of the constants' changes. If the
|
||||
* required constants have not been registered yet, the user instance will not be notified.
|
||||
*
|
||||
* @param user
|
||||
* the constants user component to register
|
||||
* @param constants
|
||||
* set of constant names the user wants to be informed about
|
||||
* constant names the user wants to be informed about
|
||||
*/
|
||||
public void registerUser( ConstantsUser user , Set< String > constants );
|
||||
public void registerUser( ConstantsUser user , String... constants );
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,4 +50,11 @@ public interface SystemStatus
|
|||
public Long checkStuckTick( )
|
||||
throws MaintenanceStatusException;
|
||||
|
||||
|
||||
/**
|
||||
* Update the status when a game update has been completed.
|
||||
*/
|
||||
public void endTick( )
|
||||
throws TickStatusException , MaintenanceStatusException;
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue