Planet mining settings interface

* Modified owned planet view to include a field which indicates whether
mining settings are specific to the planet or come from the empire;
modified "simple" game components accordingly

* Modified stored procedures to only allow planet-specific mining
settings updates when the planet actually uses planet-specific settings,
and added a stored procedure which toggles the source of a planet's
settings

* Added corresponding parts to mining settings DAO and resources
controller

* Added session commands and server command handlers that toggle the
source of the settings and that upload the settings

* Split planet page template into multiple files for clarity and added
the mining priorities form to the natural resources tab
This commit is contained in:
Emmanuel BENOîT 2012-02-07 17:03:55 +01:00
parent 51b529a09f
commit e64f847ec3
25 changed files with 1009 additions and 152 deletions
legacyworlds-server-beans-user/src/main
java/com/deepclone/lw/beans/user/player/game/planets
resources/configuration/session-types

View file

@ -0,0 +1,73 @@
package com.deepclone.lw.beans.user.player.game.planets;
import org.springframework.beans.factory.annotation.Autowired;
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
import com.deepclone.lw.cmd.player.planets.ToggleMiningSettingsCommand;
import com.deepclone.lw.cmd.player.planets.ViewPlanetCommand;
import com.deepclone.lw.interfaces.game.resources.ResourcesController;
import com.deepclone.lw.interfaces.session.ServerSession;
import com.deepclone.lw.session.Command;
import com.deepclone.lw.session.CommandResponse;
import com.deepclone.lw.session.NullResponse;
/**
* Command handler for {@link ToggleMiningSettingsCommand}
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
class ToggleMiningSettingsCommandDelegateBean
implements AutowiredCommandDelegate
{
/** The resources controller */
private ResourcesController resourcesController;
/**
* Dependency injector that sets the resources controller
*
* @param resourcesController
* the resources controller
*/
@Autowired( required = true )
public void setResourcesController( ResourcesController resourcesController )
{
this.resourcesController = resourcesController;
}
/** This class handles {@link ToggleMiningSettingsCommand} instances */
@Override
public Class< ? extends Command > getType( )
{
return ToggleMiningSettingsCommand.class;
}
/** This class is enabled for the {@link GameSubTypeBean} session type */
@Override
public Class< ? extends SessionCommandHandler > getCommandHandler( )
{
return GameSubTypeBean.class;
}
/** If the account is not in vacation mode, try to toggle the planet's settings */
@Override
public CommandResponse execute( ServerSession session , Command command )
{
if ( !session.get( "vacation" , Boolean.class ) ) {
int empireId = session.get( "empireId" , Integer.class );
ViewPlanetCommand planet = (ViewPlanetCommand) command;
this.resourcesController.togglePlanet( empireId , planet.getId( ) );
}
return new NullResponse( );
}
}

View file

@ -0,0 +1,72 @@
package com.deepclone.lw.beans.user.player.game.planets;
import org.springframework.beans.factory.annotation.Autowired;
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
import com.deepclone.lw.cmd.player.planets.UpdatePlanetMiningSettingsCommand;
import com.deepclone.lw.interfaces.game.resources.ResourcesController;
import com.deepclone.lw.interfaces.session.ServerSession;
import com.deepclone.lw.session.Command;
import com.deepclone.lw.session.CommandResponse;
import com.deepclone.lw.session.NullResponse;
/**
* Command handler for {@link UpdatePlanetMiningSettingsCommand}
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
class UpdatePlanetMiningSettingsCommandDelegateBean
implements AutowiredCommandDelegate
{
/** The resources controller */
private ResourcesController resourcesController;
/**
* Dependency injector that sets the resources controller
*
* @param resourcesController
* the resources controller
*/
@Autowired( required = true )
public void setResourcesController( ResourcesController resourcesController )
{
this.resourcesController = resourcesController;
}
/** This class handles {@link UpdatePlanetMiningSettingsCommand} instances */
@Override
public Class< ? extends Command > getType( )
{
return UpdatePlanetMiningSettingsCommand.class;
}
/** This class is enabled for the {@link GameSubTypeBean} session type */
@Override
public Class< ? extends SessionCommandHandler > getCommandHandler( )
{
return GameSubTypeBean.class;
}
/** If the empire is not in vacation mode, try updating the planet's mining priorities */
@Override
public CommandResponse execute( ServerSession session , Command command )
{
if ( !session.get( "vacation" , Boolean.class ) ) {
UpdatePlanetMiningSettingsCommand settings = (UpdatePlanetMiningSettingsCommand) command;
int empireId = session.get( "empireId" , Integer.class );
this.resourcesController.updatePlanetSettings( empireId , settings.getId( ) , settings.getSettings( ) );
}
return new NullResponse( );
}
}

View file

@ -61,6 +61,8 @@
<bean class="com.deepclone.lw.beans.user.player.game.planets.FlushQueueCommandDelegateBean" />
<bean class="com.deepclone.lw.beans.user.player.game.planets.RenamePlanetCommandDelegateBean" />
<bean class="com.deepclone.lw.beans.user.player.game.planets.AbandonPlanetCommandDelegateBean" />
<bean class="com.deepclone.lw.beans.user.player.game.planets.ToggleMiningSettingsCommandDelegateBean" />
<bean class="com.deepclone.lw.beans.user.player.game.planets.UpdatePlanetMiningSettingsCommandDelegateBean" />
<!-- Game: enemy list -->
<bean class="com.deepclone.lw.beans.user.player.game.elist.EnemyListCommandDelegateBean" />