Project: * Clean-up (Eclipse cruft, unused files, etc...) * Git-specific changes * Maven POMs clean-up and changes for the build system * Version set to 1.0.0-0 in the development branches * Maven plug-ins updated to latest versions * Very partial dev. documentation added
This commit is contained in:
parent
c74e30d5ba
commit
0665a760de
1439 changed files with 1020 additions and 1649 deletions
legacyworlds-web-main/src
|
@ -0,0 +1,35 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "banned" )
|
||||
@SessionAttributes( "language" )
|
||||
public class BannedPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/banned" )
|
||||
public String banned( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession session = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "restricted" , language , "banned" , session.getBanDetails( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.gdata.GameResponseBase;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionAttributes( "language" )
|
||||
public class CommonPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/scope" )
|
||||
public String scopePage( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession session = this.getSession( PlayerSession.class , request );
|
||||
if ( session == null || !"game".equals( session.getSessionSubType( ) ) ) {
|
||||
return this.renderStatic( model , "external" , language , "scope" );
|
||||
}
|
||||
|
||||
GameResponseBase response = session.getEnemyList( );
|
||||
return this.renderStatic( model , "game" , language , response , "scope" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/rules" )
|
||||
public String rulesPage( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession session = this.getSession( PlayerSession.class , request );
|
||||
if ( session == null || !"game".equals( session.getSessionSubType( ) ) ) {
|
||||
return this.renderStatic( model , "external" , language , "rules" );
|
||||
}
|
||||
|
||||
GameResponseBase response = session.getEnemyList( );
|
||||
return this.renderStatic( model , "game" , language , response , "rules" );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
import com.deepclone.lw.session.SessionCommandException;
|
||||
import com.deepclone.lw.session.SessionIdentifierException;
|
||||
import com.deepclone.lw.web.beans.session.MaintenanceStatus;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
|
||||
|
||||
|
||||
public class ErrorHandlerBean
|
||||
implements HandlerExceptionResolver
|
||||
{
|
||||
|
||||
private MaintenanceStatus maintenanceStatus;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setMaintenanceStatus( MaintenanceStatus maintenanceStatus )
|
||||
{
|
||||
this.maintenanceStatus = maintenanceStatus;
|
||||
}
|
||||
|
||||
|
||||
private String getLanguage( HttpServletRequest request )
|
||||
{
|
||||
HttpSession session = request.getSession( );
|
||||
String l = (String) session.getAttribute( "language" );
|
||||
return ( l == null ) ? "en" : l;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ModelAndView resolveException( HttpServletRequest request , HttpServletResponse response , Object handler ,
|
||||
Exception ex )
|
||||
{
|
||||
if ( ex instanceof SessionServerException ) {
|
||||
MaintenanceResponse maintenance = this.maintenanceStatus.getStatus( );
|
||||
if ( maintenance != null ) {
|
||||
return this.maintenance( request , maintenance );
|
||||
}
|
||||
return this.offline( request );
|
||||
} else if ( ex instanceof SessionMaintenanceException ) {
|
||||
MaintenanceResponse maintenance = ( (SessionMaintenanceException) ex ).getMaintenance( );
|
||||
this.maintenanceStatus.storeStatus( maintenance );
|
||||
return this.maintenance( request , maintenance );
|
||||
} else if ( ex instanceof SessionIdentifierException || ex instanceof SessionCommandException ) {
|
||||
return new ModelAndView( "redirect:player-session" );
|
||||
}
|
||||
|
||||
// Other exceptions are not handled
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private ModelAndView maintenance( HttpServletRequest request , MaintenanceResponse maintenance )
|
||||
{
|
||||
ModelAndView mav = new ModelAndView( "ROOT" );
|
||||
mav.addObject( "container" , "offline" );
|
||||
mav.addObject( "language" , this.getLanguage( request ) );
|
||||
mav.addObject( "type" , "maintenance" );
|
||||
mav.addObject( "data" , maintenance );
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
private ModelAndView offline( HttpServletRequest request )
|
||||
{
|
||||
ModelAndView mav = new ModelAndView( "ROOT" );
|
||||
mav.addObject( "container" , "offline" );
|
||||
mav.addObject( "language" , this.getLanguage( request ) );
|
||||
mav.addObject( "type" , "offline" );
|
||||
return mav;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = false , redirectTo = "player-session" )
|
||||
@SessionAttributes( "language" )
|
||||
public class ExternalPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/" )
|
||||
public String root( )
|
||||
{
|
||||
return "redirect:home";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/home" )
|
||||
public String mainPage( @ModelAttribute( "language" ) String language , Model model )
|
||||
{
|
||||
return this.renderStatic( model , "external" , language , "home" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/no-session" )
|
||||
public String noSession( @ModelAttribute( "language" ) String language , Model model )
|
||||
{
|
||||
return this.renderStatic( model , "external" , language , "noSession" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/logged-out" )
|
||||
public String loggedOut( @ModelAttribute( "language" ) String language , Model model )
|
||||
{
|
||||
return this.renderStatic( model , "external" , language , "loggedOut" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/password-recovery-ok" )
|
||||
public String passwordRecoveryOk( @ModelAttribute( "language" ) String language , Model model )
|
||||
{
|
||||
return this.renderStatic( model , "external" , language , "passwordRecoveryOk" );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = false , redirectTo = "player-session" )
|
||||
@SessionAttributes( "language" )
|
||||
public class LoginPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( value = "/login.action" , method = RequestMethod.POST )
|
||||
public String login( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "mail" ) String mail , @RequestParam( "password" ) String password )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.initSession( PlayerSession.class , request );
|
||||
boolean authenticated = pSession.authenticate( mail , password );
|
||||
if ( !authenticated ) {
|
||||
this.clearSession( request );
|
||||
return this.renderStatic( model , "external" , language , "loginFailed" );
|
||||
}
|
||||
|
||||
model.addAttribute( "language" , pSession.getLanguage( ) );
|
||||
return this.redirect( "player-session" );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "no-session" )
|
||||
@SessionAttributes( "language" )
|
||||
public class LogoutPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( value = "/logout.action" )
|
||||
public String validation( HttpServletRequest request , Model model )
|
||||
throws SessionServerException , SessionException
|
||||
{
|
||||
PlayerSession session = this.getSession( PlayerSession.class , request );
|
||||
session.terminate( );
|
||||
return this.redirect( "logged-out" );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.ext.ConfirmPasswordRecoveryResponse;
|
||||
import com.deepclone.lw.cmd.ext.RequestPasswordRecoveryResponse;
|
||||
import com.deepclone.lw.cmd.ext.ConfirmPasswordRecoveryResponse.PasswordRecoveryStatus;
|
||||
import com.deepclone.lw.cmd.ext.RequestPasswordRecoveryResponse.PasswordRecoveryRequestStatus;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.ExternalSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = false , redirectTo = "player-session" )
|
||||
@SessionAttributes( "language" )
|
||||
public class PasswordRecoveryPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/password-recovery" )
|
||||
public String passwordRecoveryPage( @ModelAttribute( "language" ) String language , Model model )
|
||||
{
|
||||
return this.renderMap( model , "external" , language , "passwordRecovery" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/request-password-recovery.action" , method = RequestMethod.POST )
|
||||
public String requestPasswordRecovery( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( "mail" ) String mail )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ExternalSession eSession = this.createTemporarySession( ExternalSession.class , request );
|
||||
RequestPasswordRecoveryResponse response = eSession.requestPasswordRecovery( mail );
|
||||
PasswordRecoveryRequestStatus status = response.getStatus( );
|
||||
if ( status == PasswordRecoveryRequestStatus.OK ) {
|
||||
return this.renderMap( model , "external" , language , "passwordRecovery" , "sent" , true , "mail" , mail );
|
||||
}
|
||||
return this.renderMap( model , "external" , language , "passwordRecovery" , "mail" , mail , "status" , status );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/confirm-password-recovery.action" , method = RequestMethod.POST )
|
||||
public String confirmPasswordRecovery( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( "mail" ) String mail , @RequestParam( "code" ) String token ,
|
||||
@RequestParam( "password" ) String password , @RequestParam( "passwordConfirm" ) String passwordConfirm )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ExternalSession eSession = this.createTemporarySession( ExternalSession.class , request );
|
||||
ConfirmPasswordRecoveryResponse response;
|
||||
response = eSession.confirmPasswordRecovery( mail , token , password , passwordConfirm );
|
||||
PasswordRecoveryStatus status = response.getStatus( );
|
||||
if ( status == PasswordRecoveryStatus.OK ) {
|
||||
return this.redirect( "password-recovery-ok" );
|
||||
}
|
||||
|
||||
return this.renderMap( model , "external" , language , "passwordRecovery" , "cStatus" , status , "cMail" ,
|
||||
mail , "cCode" , token );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.ClientSessionReference;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "no-session" )
|
||||
public class PlayerSessionRedirector
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/player-session" )
|
||||
public String sessionRedirection( HttpServletRequest request )
|
||||
{
|
||||
ClientSessionReference cReference = (ClientSessionReference) request.getSession( ).getAttribute( "sReference" );
|
||||
String type = cReference.getReference( ).extra;
|
||||
|
||||
if ( "validation".equals( type ) ) {
|
||||
return this.redirect( "validate-account" );
|
||||
}
|
||||
|
||||
if ( "disabled".equals( type ) ) {
|
||||
return this.redirect( "reactivate" );
|
||||
}
|
||||
|
||||
if ( "game".equals( type ) ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
if ( "banned".equals( type ) ) {
|
||||
return this.redirect( "banned" );
|
||||
}
|
||||
|
||||
throw new RuntimeException( "unknown session sub-type: " + type );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "disabled" )
|
||||
@SessionAttributes( "language" )
|
||||
public class ReactivationPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/reactivate" )
|
||||
public String reactivationPage( @ModelAttribute( "language" ) String language , Model model )
|
||||
{
|
||||
return this.renderStatic( model , "restricted" , language , "reactivate" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/reactivate.action" )
|
||||
public String reactivation( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "restricted" , language , "reactivation" , pSession.reactivate( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.ext.CreateAccountResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.ExternalSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = false , redirectTo = "player-session" )
|
||||
@SessionAttributes( "language" )
|
||||
public class RegistrationPages
|
||||
extends PageControllerBase
|
||||
|
||||
{
|
||||
|
||||
@RequestMapping( "/register" )
|
||||
public String registrationPage( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ExternalSession eSession = this.createTemporarySession( ExternalSession.class , request );
|
||||
return this.render( model , "external" , language , "register" , eSession.listLanguages( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/register.action" , method = RequestMethod.POST )
|
||||
public String registration( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( "mail" ) String mail , @RequestParam( "mailConfirm" ) String mailConfirm ,
|
||||
@RequestParam( "password" ) String password , @RequestParam( "passwordConfirm" ) String passwordConfirm ,
|
||||
@RequestParam( "language" ) String selLanguage )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ExternalSession eSession = this.createTemporarySession( ExternalSession.class , request );
|
||||
CreateAccountResponse response;
|
||||
response = eSession.createAccount( mail , mailConfirm , password , passwordConfirm , selLanguage );
|
||||
|
||||
if ( response.getLanguage( ) != null ) {
|
||||
language = response.getLanguage( );
|
||||
}
|
||||
|
||||
if ( response.getCreated( ) ) {
|
||||
return this.renderMap( model , "external" , language , "registered" , "mail" , response.getMail( ) );
|
||||
}
|
||||
return this.render( model , "external" , language , "register" , response );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.deepclone.lw.web.main;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.account.AccountValidationResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "validation" )
|
||||
@SessionAttributes( "language" )
|
||||
public class ValidationPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/validate-account" )
|
||||
public String validationPage( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession session = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "restricted" , language , "validation" , session.startValidation( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/validation.action" , method = RequestMethod.POST )
|
||||
public String validation( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "token" ) String token , @RequestParam( "empire" ) String empire ,
|
||||
@RequestParam( "old" ) String old , @RequestParam( "planet" ) String planet )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession session = this.getSession( PlayerSession.class , request );
|
||||
String uEmpire = ( "".equals( empire ) ? old : empire );
|
||||
|
||||
AccountValidationResponse response = session.validate( token , uEmpire , planet );
|
||||
if ( response.isValidated( ) ) {
|
||||
return this.redirect( "player-session" );
|
||||
}
|
||||
return this.render( model , "restricted" , language , "validation" , response );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.account.GetAccountResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class AccountPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
@RequestMapping( "/account" )
|
||||
public String view( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
GetAccountResponse data = pSession.getAccount( );
|
||||
return this.render( model , "game" , data.getAccount( ).getLanguage( ) , "account" , data );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/set-language.action" )
|
||||
public String setLanguage( HttpServletRequest request , Model model , @RequestParam( "language" ) String newLanguage )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.getSession( PlayerSession.class , request ).setLanguage( newLanguage );
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/set-password.action" )
|
||||
public String setPassword( HttpServletRequest request , Model model ,
|
||||
@RequestParam( "current" ) String currentPassword , @RequestParam( "password" ) String newPass1 ,
|
||||
@RequestParam( "passwordConfirm" ) String newPass2 )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
String challenge = pSession.createAuthenticationChallenge( );
|
||||
|
||||
GetAccountResponse data = pSession.setPassword( currentPassword , challenge , newPass1 , newPass2 );
|
||||
if ( data.getAccount( ) == null ) {
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
return this.render( model , "game" , data.getAccount( ).getLanguage( ) , "account" , data );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/set-address.action" )
|
||||
public String setAddress( HttpServletRequest request , Model model , @RequestParam( "password" ) String password ,
|
||||
@RequestParam( "mail" ) String newAddr1 , @RequestParam( "mailConfirm" ) String newAddr2 )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
String challenge = pSession.createAuthenticationChallenge( );
|
||||
|
||||
GetAccountResponse data = pSession.setAddress( password , challenge , newAddr1 , newAddr2 );
|
||||
if ( data.getAccount( ) == null ) {
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
return this.render( model , "game" , data.getAccount( ).getLanguage( ) , "account" , data );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/confirm-set-address.action" )
|
||||
public String confirmSetAddress( HttpServletRequest request , Model model ,
|
||||
@RequestParam( value = "cancel-set-address" , required = false ) String cancel ,
|
||||
@RequestParam( "code" ) String code )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
if ( cancel != null ) {
|
||||
pSession.cancelAddressChange( );
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
|
||||
GetAccountResponse data = pSession.confirmAddressChange( code );
|
||||
if ( data.getAccount( ) == null ) {
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
return this.render( model , "game" , data.getAccount( ).getLanguage( ) , "account" , data );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/set-preferences.action" )
|
||||
public String confirmSetAddress( HttpServletRequest request , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
Map< String , Object > input = this.getInput( request );
|
||||
|
||||
if ( input.containsKey( "load-default-preferences" ) ) {
|
||||
pSession.loadDefaultPreferences( );
|
||||
} else {
|
||||
Map< String , String > prefs = new HashMap< String , String >( );
|
||||
for ( Map.Entry< String , Object > entry : input.entrySet( ) ) {
|
||||
if ( ! ( entry.getValue( ) instanceof String[] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] values = (String[]) entry.getValue( );
|
||||
if ( values.length < 1 ) {
|
||||
continue;
|
||||
}
|
||||
prefs.put( entry.getKey( ) , values[ 0 ] );
|
||||
}
|
||||
pSession.setPreferences( prefs );
|
||||
}
|
||||
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/quit.action" )
|
||||
public String quit( HttpServletRequest request , Model model , @RequestParam( "reason" ) String reason )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.getSession( PlayerSession.class , request ).setQuit( reason );
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/cancel-quit.action" )
|
||||
public String cancelQuit( HttpServletRequest request , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.getSession( PlayerSession.class , request ).cancelQuit( );
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/toggle-vacation.action" )
|
||||
public String toggleVacation( HttpServletRequest request , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.getSession( PlayerSession.class , request ).toggleVacation( );
|
||||
return this.redirect( "account" );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.alliances.AllianceStatusResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class AlliancePage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/alliance" )
|
||||
public String view( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "alliance" , pSession.getAllianceStatus( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/alliance-info.action" , method = RequestMethod.POST )
|
||||
public String info( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "tag" ) String tag )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "alliance" , pSession.viewAlliance( tag ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/join-alliance.action" , method = RequestMethod.POST )
|
||||
public String join( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "tag" ) String tag )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "alliance" , pSession.joinAlliance( tag ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/cancel-join.action" , method = RequestMethod.POST )
|
||||
public String cancelJoin( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "alliance" , pSession.cancelJoinAlliance( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/create-alliance.action" , method = RequestMethod.POST )
|
||||
public String create( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "tag" ) String tag , @RequestParam( "name" ) String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "alliance" , pSession.createAlliance( tag , name ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/manage-requests.action" , method = RequestMethod.POST )
|
||||
public String manageRequests( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "members" , required = false ) String[] members ,
|
||||
@RequestParam( "action" ) String action )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
boolean accept = "1".equals( action );
|
||||
List< Integer > identifiers = new LinkedList< Integer >( );
|
||||
if ( members != null ) {
|
||||
for ( String member : members ) {
|
||||
try {
|
||||
identifiers.add( Integer.parseInt( member ) );
|
||||
} catch ( NumberFormatException e ) {
|
||||
// EMPTY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
AllianceStatusResponse response;
|
||||
if ( identifiers.isEmpty( ) ) {
|
||||
response = pSession.getAllianceStatus( );
|
||||
} else {
|
||||
int[] ids = new int[ identifiers.size( ) ];
|
||||
int i = 0;
|
||||
for ( Integer l : identifiers ) {
|
||||
ids[ i++ ] = l.intValue( );
|
||||
}
|
||||
response = pSession.manageRequests( accept , ids );
|
||||
}
|
||||
return this.render( model , "game" , language , "alliance" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/kick-members.action" , method = RequestMethod.POST )
|
||||
public String kickMembers( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "members" , required = false ) String[] members )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
List< Integer > identifiers = new LinkedList< Integer >( );
|
||||
if ( members != null ) {
|
||||
for ( String member : members ) {
|
||||
try {
|
||||
identifiers.add( Integer.parseInt( member ) );
|
||||
} catch ( NumberFormatException e ) {
|
||||
// EMPTY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
AllianceStatusResponse response;
|
||||
if ( identifiers.isEmpty( ) ) {
|
||||
response = pSession.getAllianceStatus( );
|
||||
} else {
|
||||
int[] ids = new int[ identifiers.size( ) ];
|
||||
int i = 0;
|
||||
for ( Integer l : identifiers ) {
|
||||
ids[ i++ ] = l.intValue( );
|
||||
}
|
||||
response = pSession.kickMembers( ids );
|
||||
}
|
||||
return this.render( model , "game" , language , "alliance" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/transfer-leadership.action" , method = RequestMethod.POST )
|
||||
public String transferLeadership( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( "leadership" ) String leadership )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
AllianceStatusResponse response;
|
||||
try {
|
||||
response = pSession.transferLeadership( Integer.parseInt( leadership ) );
|
||||
} catch ( NumberFormatException e ) {
|
||||
response = pSession.getAllianceStatus( );
|
||||
}
|
||||
return this.render( model , "game" , language , "alliance" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/leave-alliance.action" , method = RequestMethod.POST )
|
||||
public String leaveAlliance( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "alliance" , pSession.leaveAlliance( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.battles.GetBattleResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class BattlePages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/battle-{battleId}-latest" )
|
||||
public String getBattle( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable( "battleId" ) String sBattleId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
long battle;
|
||||
try {
|
||||
battle = Long.parseLong( sBattleId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
GetBattleResponse data = this.getSession( PlayerSession.class , request ).getBattle( battle );
|
||||
if ( data.getBattle( ) == null ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
return this.render( model , "game" , language , "battle" , data );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/battle-{battleId}-at-{tickId}" )
|
||||
public String getBattle( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable( "battleId" ) String sBattleId , @PathVariable( "tickId" ) String sTickId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
long battle;
|
||||
try {
|
||||
battle = Long.parseLong( sBattleId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
long tick;
|
||||
try {
|
||||
tick = Long.parseLong( sTickId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "battle-" + battle + "-latest" );
|
||||
}
|
||||
|
||||
GetBattleResponse data = this.getSession( PlayerSession.class , request ).getBattle( battle , tick );
|
||||
if ( data.getBattle( ) == null ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
return this.render( model , "game" , language , "battle" , data );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/battle-{battleId}-at.action" , method = RequestMethod.POST )
|
||||
public String getBattlePost( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "battleId" ) String sBattleId , @RequestParam( "tick" ) String sTickId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
long battle;
|
||||
try {
|
||||
battle = Long.parseLong( sBattleId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
long tick;
|
||||
try {
|
||||
tick = Long.parseLong( sTickId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "battle-" + battle + "-latest" );
|
||||
}
|
||||
|
||||
return this.redirect( "battle-" + battle + "-at-" + tick );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/battles" )
|
||||
public String getBattles( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.getBattles( request , language , model , 0 );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/battles-{page}" )
|
||||
public String getBattles( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable( "page" ) String sPage )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int page;
|
||||
try {
|
||||
page = Integer.parseInt( sPage );
|
||||
} catch ( NumberFormatException e ) {
|
||||
page = 0;
|
||||
}
|
||||
|
||||
return this.getBattles( request , language , model , page );
|
||||
}
|
||||
|
||||
|
||||
private String getBattles( HttpServletRequest request , String language , Model model , int page )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "battles" , pSession.getBattles( page ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.bt.data.BugEvent;
|
||||
import com.deepclone.lw.cmd.player.bt.*;
|
||||
import com.deepclone.lw.cmd.player.gdata.GamePageData;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.msgs.MessageFormatter;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.BugTrackerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class BugTrackerPages
|
||||
extends BugTrackerBase
|
||||
{
|
||||
|
||||
private static final int perPage = 10;
|
||||
|
||||
private MessageFormatter formatter;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setFormatter( MessageFormatter formatter )
|
||||
{
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/bugtrack" )
|
||||
public String listBugs( HttpServletRequest request , Model model , @ModelAttribute( "language" ) String language ,
|
||||
@RequestParam( value = "status" , required = false ) String sStatus ,
|
||||
@RequestParam( value = "own" , required = false ) String sOwn ,
|
||||
@RequestParam( value = "first" , required = false ) String sFirst )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
BugQuery query = this.getBugQuery( sStatus , sOwn , sFirst );
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ListBugsResponse response = pSession.listBugs( query.status , query.ownOnly , query.first , perPage );
|
||||
return this.render( model , "game" , language , "bugsList" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/report-bug" )
|
||||
public String showReportForm( HttpServletRequest request , Model model ,
|
||||
@ModelAttribute( "language" ) String language ,
|
||||
@RequestParam( value = "status" , required = false ) String sStatus ,
|
||||
@RequestParam( value = "own" , required = false ) String sOwn ,
|
||||
@RequestParam( value = "first" , required = false ) String sFirst )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
BugQuery query = this.getBugQuery( sStatus , sOwn , sFirst );
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
GamePageData page = pSession.listPlanets( ).getPage( );
|
||||
return this.renderMap( model , "game" , language , "bugsReport" , "page" , page , "query" , query );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/report-bug.action" , method = RequestMethod.POST )
|
||||
public String postReport( HttpServletRequest request , Model model , @ModelAttribute( "language" ) String language ,
|
||||
@RequestParam( value = "status" , required = false ) String sStatus ,
|
||||
@RequestParam( value = "own" , required = false ) String sOwn ,
|
||||
@RequestParam( value = "first" , required = false ) String sFirst , @RequestParam( "title" ) String title ,
|
||||
@RequestParam( "description" ) String description )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
BugQuery query = this.getBugQuery( sStatus , sOwn , sFirst );
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ReportBugResponse response = pSession.reportBug( title , description );
|
||||
|
||||
if ( response.getTitle( ) == null ) {
|
||||
// Successful post
|
||||
String rTo = "bug-" + response.getBugId( ) + this.makeGetParams( query );
|
||||
return this.redirect( rTo );
|
||||
}
|
||||
|
||||
response = new ReportBugResponse( response , query );
|
||||
return this.render( model , "game" , language , "bugsReport" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/bug-{id}" )
|
||||
public String viewBug( HttpServletRequest request , Model model , @ModelAttribute( "language" ) String language ,
|
||||
@RequestParam( value = "status" , required = false ) String sStatus ,
|
||||
@RequestParam( value = "own" , required = false ) String sOwn ,
|
||||
@RequestParam( value = "first" , required = false ) String sFirst , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
BugQuery query = this.getBugQuery( sStatus , sOwn , sFirst );
|
||||
|
||||
long bugId;
|
||||
try {
|
||||
bugId = Long.parseLong( sId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "bugtrack" + this.makeGetParams( query ) );
|
||||
}
|
||||
|
||||
ViewBugResponse response = this.getSession( PlayerSession.class , request ).getBugReport( bugId );
|
||||
if ( response.getReport( ) == null ) {
|
||||
return this.redirect( "bugtrack" + this.makeGetParams( query ) );
|
||||
}
|
||||
|
||||
response = new ViewBugResponse( response , query );
|
||||
return this.displayReport( model , language , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/bug-{id}-comment.action" , method = RequestMethod.POST )
|
||||
public String commentBug( HttpServletRequest request , Model model , @ModelAttribute( "language" ) String language ,
|
||||
@RequestParam( value = "status" , required = false ) String sStatus ,
|
||||
@RequestParam( value = "own" , required = false ) String sOwn ,
|
||||
@RequestParam( value = "first" , required = false ) String sFirst , @PathVariable( "id" ) String sId ,
|
||||
@RequestParam( "comment" ) String comment )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
BugQuery query = this.getBugQuery( sStatus , sOwn , sFirst );
|
||||
|
||||
long bugId;
|
||||
try {
|
||||
bugId = Long.parseLong( sId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "bugtrack" + this.makeGetParams( query ) );
|
||||
}
|
||||
|
||||
PostCommentResponse response = this.getSession( PlayerSession.class , request )
|
||||
.postBugComment( bugId , comment );
|
||||
if ( response.isPosted( ) ) {
|
||||
String rTo = "bug-" + bugId + this.makeGetParams( query );
|
||||
return this.redirect( rTo );
|
||||
} else if ( response.getReport( ) == null ) {
|
||||
return this.redirect( "bugtrack" + this.makeGetParams( query ) );
|
||||
}
|
||||
|
||||
response = new PostCommentResponse( response , query );
|
||||
return this.displayReport( model , language , response );
|
||||
}
|
||||
|
||||
|
||||
private String displayReport( Model model , String language , ViewBugResponse response )
|
||||
{
|
||||
for ( BugEvent event : response.getEvents( ) ) {
|
||||
if ( event.getTitle( ) != null ) {
|
||||
event.setTitle( this.formatter.cleanMessage( event.getTitle( ) ) );
|
||||
}
|
||||
if ( event.getContents( ) != null ) {
|
||||
event.setContents( this.formatter.formatMessage( event.getContents( ) , false ) );
|
||||
}
|
||||
}
|
||||
return this.render( model , "game" , language , "bugsView" , response );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.ListPlanetsResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class ChatPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/chat" )
|
||||
public String chat( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ListPlanetsResponse response = this.getSession( PlayerSession.class , request ).listPlanets( );
|
||||
return this.render( model , "chat" , language , "chat" , response );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.elist.EnemyListResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class EnemiesPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/enemies" )
|
||||
public String overview( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "enemies" , pSession.getEnemyList( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/add-enemy-empire.action" , method = RequestMethod.POST )
|
||||
public String addEmpire( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "name" ) String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "enemies" , pSession.addEnemy( false , name ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/add-enemy-alliance.action" , method = RequestMethod.POST )
|
||||
public String addAlliance( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( "name" ) String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "enemies" , pSession.addEnemy( true , name ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/remove-enemy-empires.action" , method = RequestMethod.POST )
|
||||
public String removeEmpires( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "id" , required = false ) String[] sIds )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.remove( request , language , model , sIds , false );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/remove-enemy-alliances.action" , method = RequestMethod.POST )
|
||||
public String removeAlliances( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "id" , required = false ) String[] sIds )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.remove( request , language , model , sIds , true );
|
||||
}
|
||||
|
||||
|
||||
private String remove( HttpServletRequest request , String language , Model model , String[] sIds , boolean alliance )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
List< Integer > identifiers = new LinkedList< Integer >( );
|
||||
if ( sIds != null ) {
|
||||
for ( String member : sIds ) {
|
||||
try {
|
||||
identifiers.add( Integer.parseInt( member ) );
|
||||
} catch ( NumberFormatException e ) {
|
||||
// EMPTY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
EnemyListResponse response;
|
||||
if ( identifiers.isEmpty( ) ) {
|
||||
response = pSession.getEnemyList( );
|
||||
} else {
|
||||
int[] ids = new int[ identifiers.size( ) ];
|
||||
int i = 0;
|
||||
for ( Integer l : identifiers ) {
|
||||
ids[ i++ ] = l.intValue( );
|
||||
}
|
||||
response = pSession.removeEnemies( alliance , ids );
|
||||
}
|
||||
|
||||
return this.render( model , "game" , language , "enemies" , response );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.fleets.MoveFleetsResponse;
|
||||
import com.deepclone.lw.cmd.player.fleets.MultiFleetsResponse;
|
||||
import com.deepclone.lw.cmd.player.fleets.RenameFleetsResponse;
|
||||
import com.deepclone.lw.cmd.player.fleets.SplitFleetResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class FleetsPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/fleets" )
|
||||
public String fleetsList( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "fleets" , pSession.getFleets( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/fleets.action" )
|
||||
public String fleetsAction( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "selection" , required = false ) String[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Map< String , Object > input = this.getInput( request );
|
||||
long fleetIds[] = this.getSelected( selection );
|
||||
if ( fleetIds.length == 0 ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
// "Split" is special - it needs a single fleet, no less, no more
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
if ( input.containsKey( "split" ) ) {
|
||||
if ( fleetIds.length != 1 ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
SplitFleetResponse response = pSession.splitFleet( fleetIds[ 0 ] );
|
||||
if ( response.getInitialFleet( ) == null ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
return this.render( model , "game" , language , "splitFleet" , response );
|
||||
}
|
||||
|
||||
// Handle "multiple" commands and responses
|
||||
MultiFleetsResponse response = null;
|
||||
if ( input.containsKey( "rename" ) ) {
|
||||
response = pSession.renameFleets( fleetIds );
|
||||
} else if ( input.containsKey( "move" ) ) {
|
||||
response = pSession.moveFleets( fleetIds );
|
||||
} else if ( input.containsKey( "setAttack" ) ) {
|
||||
response = pSession.setFleetsMode( fleetIds , true , false );
|
||||
} else if ( input.containsKey( "setDefend" ) ) {
|
||||
response = pSession.setFleetsMode( fleetIds , false , false );
|
||||
} else if ( input.containsKey( "merge" ) ) {
|
||||
response = pSession.mergeFleets( fleetIds );
|
||||
} else if ( input.containsKey( "disband" ) ) {
|
||||
response = pSession.disbandFleets( fleetIds , false );
|
||||
} else {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
// Empty response - we're done, redirect to the fleets page
|
||||
if ( response == null || response.getFleets( ).isEmpty( ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
return this.render( model , "game" , language , "fleetsCommand" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/move-fleets.action" )
|
||||
public String moveFleets( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( value = "selection" , required = false ) String[] selection ,
|
||||
@RequestParam( "destination" ) String destination , @RequestParam( "mode" ) String mode )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Map< String , Object > input = this.getInput( request );
|
||||
long fleetIds[] = this.getSelected( selection );
|
||||
if ( fleetIds.length == 0 || input.containsKey( "cancel" ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
MoveFleetsResponse response = pSession.moveFleets( fleetIds , destination , "1".equals( mode ) );
|
||||
|
||||
if ( response.getFleets( ).isEmpty( ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
return this.render( model , "game" , language , "fleetsCommand" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/rename-fleets.action" )
|
||||
public String renameFleets( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "selection" , required = false ) String[] selection ,
|
||||
@RequestParam( "name" ) String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Map< String , Object > input = this.getInput( request );
|
||||
long fleetIds[] = this.getSelected( selection );
|
||||
if ( fleetIds.length == 0 || input.containsKey( "cancel" ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
RenameFleetsResponse response = pSession.renameFleets( fleetIds , name );
|
||||
|
||||
if ( response.getFleets( ).isEmpty( ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
return this.render( model , "game" , language , "fleetsCommand" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/set-fleets-mode.action" )
|
||||
public String setFleetsMode( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "selection" , required = false ) String[] selection ,
|
||||
@RequestParam( "attack" ) String sAttack )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Map< String , Object > input = this.getInput( request );
|
||||
long fleetIds[] = this.getSelected( selection );
|
||||
if ( fleetIds.length == 0 || input.containsKey( "cancel" ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
pSession.setFleetsMode( fleetIds , "1".equals( sAttack ) , true );
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/disband-fleets.action" )
|
||||
public String disbandFleets( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( value = "selection" , required = false ) String[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Map< String , Object > input = this.getInput( request );
|
||||
long fleetIds[] = this.getSelected( selection );
|
||||
if ( fleetIds.length == 0 || input.containsKey( "cancel" ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
pSession.disbandFleets( fleetIds , true );
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/split-fleet.action" )
|
||||
public String splitFleet( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "fleet" ) String idStr , @RequestParam( "nFleets" ) String nbStr ,
|
||||
@RequestParam( "name" ) String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
long id;
|
||||
try {
|
||||
id = Long.parseLong( idStr );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
int nb;
|
||||
try {
|
||||
nb = Integer.parseInt( nbStr );
|
||||
} catch ( NumberFormatException e ) {
|
||||
nb = 0;
|
||||
}
|
||||
|
||||
Map< String , Object > input = this.getInput( request );
|
||||
Map< Integer , Integer > ships = new HashMap< Integer , Integer >( );
|
||||
|
||||
// Get ship counts
|
||||
for ( Map.Entry< String , Object > contents : input.entrySet( ) ) {
|
||||
String k = contents.getKey( );
|
||||
if ( "cancel".equals( k ) ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
if ( !k.startsWith( "ships_" ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
int shipType = Integer.parseInt( k.substring( 6 ) );
|
||||
String[] value = (String[]) contents.getValue( );
|
||||
ships.put( shipType , Integer.parseInt( value[ 0 ] ) );
|
||||
} catch ( Throwable t ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
SplitFleetResponse response = pSession.splitFleet( id , ships , nb , name );
|
||||
if ( response.getInitialFleet( ) == null ) {
|
||||
return this.redirect( "fleets" );
|
||||
}
|
||||
|
||||
return this.render( model , "game" , language , "splitFleet" , response );
|
||||
}
|
||||
|
||||
|
||||
private long[] getSelected( String[] selection )
|
||||
{
|
||||
if ( selection == null ) {
|
||||
return new long[] { };
|
||||
}
|
||||
|
||||
ArrayList< Long > selected = new ArrayList< Long >( );
|
||||
for ( String sel : selection ) {
|
||||
try {
|
||||
selected.add( Long.parseLong( sel ) );
|
||||
} catch ( NumberFormatException e ) {
|
||||
// EMPTY - ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
long[] values = new long[ selected.size( ) ];
|
||||
for ( int i = 0 ; i < values.length ; i++ ) {
|
||||
values[ i ] = selected.get( i ).longValue( );
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.GetNewPlanetResponse;
|
||||
import com.deepclone.lw.cmd.player.ListPlanetsResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class GetPlanetPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
@RequestMapping( "/get-planet" )
|
||||
public String getPlanet( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ListPlanetsResponse data = pSession.listPlanets( );
|
||||
if ( data.getPlanets( ).size( ) > 0 ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
return this.render( model , "game" , language , "getNewPlanet" , new GetNewPlanetResponse( data.getPage( ) , "" ,
|
||||
null ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/get-planet.action" )
|
||||
public String getPlanet( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "name" ) String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
GetNewPlanetResponse data = this.getSession( PlayerSession.class , request ).getNewPlanet( name );
|
||||
|
||||
if ( data.getPlanet( ) != null ) {
|
||||
return this.redirect( "planet-" + data.getPlanet( ) );
|
||||
}
|
||||
if ( data.getName( ) == null ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
return this.render( model , "game" , language , "getNewPlanet" , data );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.ViewMapResponse;
|
||||
import com.deepclone.lw.cmd.player.gdata.MapSize;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class MapPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/map" )
|
||||
public String viewMap( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ViewMapResponse map = this.getMap( pSession , request.getSession( ) );
|
||||
return this.render( model , "game" , language , "map" , map );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/move-map.action" , method = RequestMethod.POST )
|
||||
public String viewMap( HttpServletRequest request , @RequestParam( "x" ) String xStr ,
|
||||
@RequestParam( "y" ) String yStr , @RequestParam( "sz" ) String szStr )
|
||||
{
|
||||
int x , y , szOrd;
|
||||
x = this.getInt( xStr );
|
||||
y = this.getInt( yStr );
|
||||
szOrd = this.getInt( szStr );
|
||||
|
||||
MapSize sz;
|
||||
try {
|
||||
sz = MapSize.values( )[ szOrd ];
|
||||
} catch ( ArrayIndexOutOfBoundsException e ) {
|
||||
sz = MapSize.SMALL;
|
||||
}
|
||||
|
||||
HttpSession session = request.getSession( );
|
||||
session.setAttribute( "mapX" , x );
|
||||
session.setAttribute( "mapY" , y );
|
||||
session.setAttribute( "mapSize" , sz );
|
||||
|
||||
return this.redirect( "map" );
|
||||
}
|
||||
|
||||
|
||||
private int getInt( String str )
|
||||
{
|
||||
try {
|
||||
return Integer.parseInt( str );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ViewMapResponse getMap( PlayerSession pSession , HttpSession session )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Integer mx = (Integer) session.getAttribute( "mapX" );
|
||||
Integer my = (Integer) session.getAttribute( "mapY" );
|
||||
MapSize size = (MapSize) session.getAttribute( "mapSize" );
|
||||
|
||||
ViewMapResponse vmr;
|
||||
if ( mx == null || my == null || size == null ) {
|
||||
vmr = pSession.viewMap( );
|
||||
} else {
|
||||
vmr = pSession.viewMap( mx , my , size );
|
||||
}
|
||||
|
||||
session.setAttribute( "mapX" , vmr.getX( ) );
|
||||
session.setAttribute( "mapY" , vmr.getY( ) );
|
||||
session.setAttribute( "mapSize" , vmr.getSize( ) );
|
||||
|
||||
return vmr;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.deepclone.lw.cmd.msgdata.MessageListEntry;
|
||||
import com.deepclone.lw.cmd.player.gdata.GamePageData;
|
||||
import com.deepclone.lw.cmd.player.gdata.GameResponseBase;
|
||||
|
||||
|
||||
|
||||
public class MessageBoxView
|
||||
extends GameResponseBase
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final boolean inbox;
|
||||
private int pages;
|
||||
private int cPage;
|
||||
private final List< MessageListEntry > messages = new LinkedList< MessageListEntry >( );
|
||||
|
||||
|
||||
public MessageBoxView( GamePageData page , boolean inbox )
|
||||
{
|
||||
super( page );
|
||||
this.inbox = inbox;
|
||||
}
|
||||
|
||||
|
||||
public int getPages( )
|
||||
{
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
||||
public void setPages( int pages )
|
||||
{
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
|
||||
public int getcPage( )
|
||||
{
|
||||
return cPage;
|
||||
}
|
||||
|
||||
|
||||
public void setcPage( int cPage )
|
||||
{
|
||||
this.cPage = cPage;
|
||||
}
|
||||
|
||||
|
||||
public boolean isInbox( )
|
||||
{
|
||||
return inbox;
|
||||
}
|
||||
|
||||
|
||||
public List< MessageListEntry > getMessages( )
|
||||
{
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
||||
public void addMessage( MessageListEntry entry )
|
||||
{
|
||||
this.messages.add( entry );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,487 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.msgdata.Message;
|
||||
import com.deepclone.lw.cmd.msgdata.MessageListEntry;
|
||||
import com.deepclone.lw.cmd.msgdata.MessageType;
|
||||
import com.deepclone.lw.cmd.player.msgs.ComposeMessageResponse;
|
||||
import com.deepclone.lw.cmd.player.msgs.GetMessagesResponse;
|
||||
import com.deepclone.lw.cmd.player.msgs.ReadMessageResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.msgs.MessageFormatter;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class MessagePages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
private final static int perPage = 12;
|
||||
|
||||
private MessageFormatter formatter;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setFormatter( MessageFormatter formatter )
|
||||
{
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/messages" )
|
||||
public String viewInbox( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
MessageBoxView view = this.viewMessageBox( true , this.getSession( PlayerSession.class , request ) , 0 );
|
||||
return this.render( model , "game" , language , "messageBox" , view );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/inbox-{page}" )
|
||||
public String viewInbox( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable( "page" ) String sPage )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int page;
|
||||
try {
|
||||
page = Integer.parseInt( sPage );
|
||||
} catch ( NumberFormatException e ) {
|
||||
page = 0;
|
||||
}
|
||||
|
||||
MessageBoxView view = this.viewMessageBox( true , this.getSession( PlayerSession.class , request ) , page );
|
||||
return this.render( model , "game" , language , "messageBox" , view );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/inbox-from-{id}" )
|
||||
public String viewInboxFrom( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
long id;
|
||||
try {
|
||||
id = Integer.parseInt( sId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
id = 0;
|
||||
}
|
||||
|
||||
MessageBoxView view = this.viewMessageBoxFrom( true , this.getSession( PlayerSession.class , request ) , id );
|
||||
return this.render( model , "game" , language , "messageBox" , view );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/outbox" )
|
||||
public String viewOutbox( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
MessageBoxView view = this.viewMessageBox( false , this.getSession( PlayerSession.class , request ) , 0 );
|
||||
return this.render( model , "game" , language , "messageBox" , view );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/outbox-{page}" )
|
||||
public String viewOutbox( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable( "page" ) String sPage )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int page;
|
||||
try {
|
||||
page = Integer.parseInt( sPage );
|
||||
} catch ( NumberFormatException e ) {
|
||||
page = 0;
|
||||
}
|
||||
|
||||
MessageBoxView view = this.viewMessageBox( false , this.getSession( PlayerSession.class , request ) , page );
|
||||
return this.render( model , "game" , language , "messageBox" , view );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/outbox-from-{id}" )
|
||||
public String viewOutboxFrom( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
long id;
|
||||
try {
|
||||
id = Integer.parseInt( sId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
id = 0;
|
||||
}
|
||||
|
||||
MessageBoxView view = this.viewMessageBoxFrom( false , this.getSession( PlayerSession.class , request ) , id );
|
||||
return this.render( model , "game" , language , "messageBox" , view );
|
||||
}
|
||||
|
||||
|
||||
private MessageBoxView viewMessageBox( boolean inbox , PlayerSession pSession , int page )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
GetMessagesResponse mResponse = pSession.getMessages( inbox );
|
||||
MessageBoxView view = new MessageBoxView( mResponse.getPage( ) , inbox );
|
||||
List< MessageListEntry > messages = mResponse.getMessages( );
|
||||
|
||||
// Handle paging
|
||||
messages = this.setPage( view , messages , page );
|
||||
this.prepareMessages( view , messages );
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
private MessageBoxView viewMessageBoxFrom( boolean inbox , PlayerSession pSession , long fromId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
GetMessagesResponse mResponse = pSession.getMessages( inbox );
|
||||
MessageBoxView view = new MessageBoxView( mResponse.getPage( ) , inbox );
|
||||
List< MessageListEntry > messages = mResponse.getMessages( );
|
||||
int page = 0;
|
||||
int nSeen = -1;
|
||||
for ( MessageListEntry e : messages ) {
|
||||
nSeen++;
|
||||
if ( e.getId( ) != fromId ) {
|
||||
continue;
|
||||
}
|
||||
page = ( nSeen - nSeen % MessagePages.perPage ) / MessagePages.perPage;
|
||||
break;
|
||||
}
|
||||
|
||||
// Handle paging
|
||||
messages = this.setPage( view , messages , page );
|
||||
this.prepareMessages( view , messages );
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
private void prepareMessages( MessageBoxView view , List< MessageListEntry > messages )
|
||||
{
|
||||
for ( MessageListEntry message : messages ) {
|
||||
message.setTitle( this.formatter.cleanMessage( message.getTitle( ) ) );
|
||||
view.addMessage( message );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List< MessageListEntry > setPage( MessageBoxView view , List< MessageListEntry > messages , int page )
|
||||
{
|
||||
int nMessages = messages.size( );
|
||||
int mod = nMessages % MessagePages.perPage;
|
||||
int nPages = ( nMessages - mod ) / MessagePages.perPage + ( mod > 0 ? 1 : 0 );
|
||||
if ( page < 0 ) {
|
||||
page = 0;
|
||||
} else if ( page >= nPages ) {
|
||||
page = nPages - 1;
|
||||
}
|
||||
if ( !messages.isEmpty( ) ) {
|
||||
messages = messages.subList( page * MessagePages.perPage , Math.min( ( page + 1 ) * MessagePages.perPage ,
|
||||
nMessages ) );
|
||||
}
|
||||
|
||||
view.setPages( nPages );
|
||||
view.setcPage( page );
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/inbox-message-{id}" )
|
||||
public String viewInboxMessage( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.viewMessage( request , language , model , sId , true );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/outbox-message-{id}" )
|
||||
public String viewOutboxMessage( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.viewMessage( request , language , model , sId , false );
|
||||
}
|
||||
|
||||
|
||||
private String viewMessage( HttpServletRequest request , String language , Model model , String sId , boolean inbox )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
long id;
|
||||
try {
|
||||
id = Long.parseLong( sId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( inbox ? "messages" : "outbox" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ReadMessageResponse response = pSession.readMessage( inbox , id );
|
||||
Message message = response.getMessage( );
|
||||
if ( message == null ) {
|
||||
return this.redirect( inbox ? "messages" : "outbox" );
|
||||
}
|
||||
|
||||
boolean internal = ( message.getType( ) == MessageType.INTERNAL );
|
||||
message.setTitle( this.formatter.cleanMessage( message.getTitle( ) ) );
|
||||
message.setContents( this.formatter.formatMessage( message.getContents( ) , internal ) );
|
||||
|
||||
return this.render( model , "game" , language , "message" , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/messages.action" , method = RequestMethod.POST )
|
||||
public String mbAction( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "inbox" ) String sInbox , @RequestParam( "page" ) String sPage ,
|
||||
@RequestParam( "target" ) String sTarget , @RequestParam( "action" ) String action ,
|
||||
@RequestParam( value = "selection" , required = false ) String[] sSelection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
boolean inbox = "1".equals( sInbox );
|
||||
if ( !inbox ) {
|
||||
action = "d";
|
||||
}
|
||||
|
||||
boolean useSelected = "0".equals( sTarget );
|
||||
long selection[];
|
||||
if ( useSelected ) {
|
||||
List< Long > rSel = new LinkedList< Long >( );
|
||||
if ( sSelection != null ) {
|
||||
for ( String sItem : sSelection ) {
|
||||
Long value;
|
||||
try {
|
||||
value = Long.parseLong( sItem );
|
||||
} catch ( NumberFormatException e ) {
|
||||
continue;
|
||||
}
|
||||
rSel.add( value );
|
||||
}
|
||||
|
||||
selection = new long[ rSel.size( ) ];
|
||||
int i = 0;
|
||||
for ( Long value : rSel ) {
|
||||
selection[ i++ ] = value;
|
||||
}
|
||||
} else {
|
||||
selection = new long[ 0 ];
|
||||
}
|
||||
} else {
|
||||
selection = null;
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
if ( selection == null || selection.length > 0 ) {
|
||||
if ( "d".equals( action ) ) {
|
||||
pSession.deleteMessages( inbox , selection );
|
||||
} else if ( "r".equals( action ) ) {
|
||||
pSession.markRead( selection );
|
||||
} else if ( "u".equals( action ) ) {
|
||||
pSession.markUnread( selection );
|
||||
}
|
||||
}
|
||||
|
||||
int page;
|
||||
try {
|
||||
page = Integer.parseInt( sPage );
|
||||
} catch ( NumberFormatException e ) {
|
||||
page = 0;
|
||||
}
|
||||
return this.redirect( ( inbox ? "inbox" : "outbox" ) + "-" + page );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/message.action" , method = RequestMethod.POST )
|
||||
public String msgAction( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "inbox" ) String sInbox , @RequestParam( "id" ) String sId ,
|
||||
@RequestParam( "next" ) String sNext , @RequestParam( value = "delete" , required = false ) String delete ,
|
||||
@RequestParam( value = "reply" , required = false ) String reply )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
boolean inbox = "1".equals( sInbox );
|
||||
|
||||
long id;
|
||||
try {
|
||||
id = Long.parseLong( sId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( inbox ? "messages" : "outbox" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
if ( delete != null ) {
|
||||
pSession.deleteMessages( inbox , new long[] {
|
||||
id
|
||||
} );
|
||||
|
||||
try {
|
||||
id = Long.parseLong( sNext );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( inbox ? "messages" : "outbox" );
|
||||
}
|
||||
return this.redirect( ( inbox ? "inbox" : "outbox" ) + "-message-" + id );
|
||||
} else if ( reply != null ) {
|
||||
ComposeMessageResponse response;
|
||||
response = pSession.replyTo( inbox , id );
|
||||
return this.showWriter( language , model , response );
|
||||
}
|
||||
return this.redirect( inbox ? "messages" : "outbox" );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/compose-message" )
|
||||
public String composeNew( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "messageWriter" , pSession.initNewMessage( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/msg-empire-{id}" )
|
||||
public String messageEmpire( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.newMessageTo( request , language , model , MessageType.EMPIRE , sId );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/msg-alliance-{id}" )
|
||||
public String messageAlliance( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.newMessageTo( request , language , model , MessageType.ALLIANCE , sId );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/msg-admin-{id}" )
|
||||
public String messageAdmin( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable( "id" ) String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return this.newMessageTo( request , language , model , MessageType.ADMINISTRATOR , sId );
|
||||
}
|
||||
|
||||
|
||||
private String newMessageTo( HttpServletRequest request , String language , Model model , MessageType type ,
|
||||
String sId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt( sId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "compose-message" );
|
||||
}
|
||||
|
||||
ComposeMessageResponse response;
|
||||
response = this.getSession( PlayerSession.class , request ).messageTo( type , id );
|
||||
return this.showWriter( language , model , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/send-message.action" , method = RequestMethod.POST )
|
||||
public String sendMessage( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @RequestParam( "toType" ) String sToType , @RequestParam( "toName" ) String toName ,
|
||||
@RequestParam( "title" ) String title , @RequestParam( "contents" ) String contents ,
|
||||
@RequestParam( value = "rtInbox" , required = false ) String sRtInbox ,
|
||||
@RequestParam( value = "rtId" , required = false ) String sRtId ,
|
||||
@RequestParam( value = "cancel" , required = false ) String sCancel )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
// Handle cancellation
|
||||
if ( sCancel != null ) {
|
||||
return this.cancelSendRedirect( sRtInbox , sRtId );
|
||||
}
|
||||
|
||||
// Get message type
|
||||
MessageType type;
|
||||
try {
|
||||
type = MessageType.valueOf( sToType );
|
||||
} catch ( IllegalArgumentException e ) {
|
||||
type = MessageType.INTERNAL;
|
||||
}
|
||||
if ( type == MessageType.INTERNAL ) {
|
||||
type = MessageType.EMPIRE;
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ComposeMessageResponse response;
|
||||
if ( sRtInbox == null || sRtId == null ) {
|
||||
response = pSession.sendMessage( type , toName , title , contents );
|
||||
} else {
|
||||
boolean inbox = "1".equals( sRtInbox );
|
||||
long rtId;
|
||||
try {
|
||||
rtId = Long.parseLong( sRtId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( inbox ? "messages" : "outbox" );
|
||||
}
|
||||
|
||||
response = pSession.sendReply( inbox , rtId , type , toName , title , contents );
|
||||
}
|
||||
|
||||
if ( !response.isError( ) ) {
|
||||
return this.cancelSendRedirect( sRtInbox , sRtId );
|
||||
}
|
||||
return this.showWriter( language , model , response );
|
||||
}
|
||||
|
||||
|
||||
private String showWriter( String language , Model model , ComposeMessageResponse response )
|
||||
{
|
||||
if ( response.getReplyTo( ) != null ) {
|
||||
Message message = response.getReplyTo( );
|
||||
message.setTitle( this.formatter.cleanMessage( message.getTitle( ) ) );
|
||||
message.setContents( this.formatter.formatMessage( message.getContents( ) , false ) );
|
||||
}
|
||||
return this.render( model , "game" , language , "messageWriter" , response );
|
||||
}
|
||||
|
||||
|
||||
private String cancelSendRedirect( String sRtInbox , String sRtId )
|
||||
{
|
||||
if ( sRtInbox == null || sRtId == null ) {
|
||||
return this.redirect( "messages" );
|
||||
}
|
||||
|
||||
boolean inbox = "1".equals( sRtInbox );
|
||||
long rtId;
|
||||
try {
|
||||
rtId = Long.parseLong( sRtId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( inbox ? "messages" : "outbox" );
|
||||
}
|
||||
|
||||
return this.redirect( ( inbox ? "inbox" : "outbox" ) + "-message-" + rtId );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/message-targets" )
|
||||
public String listTargets( HttpServletRequest request , Model model , @ModelAttribute( "language" ) String language )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "messageTargets" , pSession.listMessageTargets( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class OverviewPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/overview" )
|
||||
public String overview( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "overview" , pSession.getOverview( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/implement-{tech}.action" , method = RequestMethod.POST )
|
||||
public String implement( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String tech )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int techId;
|
||||
try {
|
||||
techId = Integer.parseInt( tech );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "overview" , pSession.implementTechnology( techId ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class PlanetListPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/planets" )
|
||||
public String planetList( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planets" , pSession.listPlanets( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,236 @@
|
|||
package com.deepclone.lw.web.main.game;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.intercept.SessionRequirement;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.view.PageControllerBase;
|
||||
import com.deepclone.lw.web.csess.PlayerSession;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionRequirement( value = true , redirectTo = "player-session" , subType = "game" )
|
||||
@SessionAttributes( "language" )
|
||||
public class PlanetPage
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/planet-{planetId}" )
|
||||
public String view( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String planetId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.getPlanetView( id ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-rename.action" , method = RequestMethod.POST )
|
||||
public String rename( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String planetId , @RequestParam( "name" ) String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.rename( pId , name ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-abandon.action" , method = RequestMethod.POST )
|
||||
public String abandon( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String planetId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.abandon( pId ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-cancel-abandon.action" , method = RequestMethod.POST )
|
||||
public String cancelAbandon( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String planetId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.cancelAbandon( pId ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-build-civ.action" , method = RequestMethod.POST )
|
||||
public String construct( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String planetId , @RequestParam( "type" ) String type ,
|
||||
@RequestParam( "amount" ) String amount )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
int tId;
|
||||
try {
|
||||
tId = Integer.parseInt( type );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "planet-" + pId + "#buildings" );
|
||||
}
|
||||
|
||||
int x;
|
||||
try {
|
||||
x = Integer.parseInt( amount );
|
||||
} catch ( NumberFormatException e ) {
|
||||
x = 0;
|
||||
}
|
||||
if ( x <= 0 ) {
|
||||
return this.redirect( "planet-" + pId + "#buildings" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.constructBuildings( pId , tId , x ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-destroy.action" , method = RequestMethod.POST )
|
||||
public String destroy( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String planetId , @RequestParam( "type" ) String type ,
|
||||
@RequestParam( "amount" ) String amount )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
int tId;
|
||||
try {
|
||||
tId = Integer.parseInt( type );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "planet-" + pId + "#buildings" );
|
||||
}
|
||||
|
||||
int x;
|
||||
try {
|
||||
x = Integer.parseInt( amount );
|
||||
} catch ( NumberFormatException e ) {
|
||||
x = 0;
|
||||
}
|
||||
if ( x <= 0 ) {
|
||||
return this.redirect( "planet-" + pId + "#buildings" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.destroyBuildings( pId , tId , x ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-build-mil.action" , method = RequestMethod.POST )
|
||||
public String buildShips( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@PathVariable String planetId , @RequestParam( "type" ) String type ,
|
||||
@RequestParam( "amount" ) String amount )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
int tId;
|
||||
try {
|
||||
tId = Integer.parseInt( type );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "planet-" + pId + "#ships" );
|
||||
}
|
||||
|
||||
int x;
|
||||
try {
|
||||
x = Integer.parseInt( amount );
|
||||
} catch ( NumberFormatException e ) {
|
||||
x = 0;
|
||||
}
|
||||
if ( x <= 0 ) {
|
||||
return this.redirect( "planet-" + pId + "#ships" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.buildShips( pId , tId , x ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-flush-civ.action" , method = RequestMethod.POST )
|
||||
public String flushCivQueue( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable String planetId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.flushQueue( pId , false ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/planet-{planetId}-flush-mil.action" , method = RequestMethod.POST )
|
||||
public String flushMilQueue( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model , @PathVariable String planetId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
int pId;
|
||||
try {
|
||||
pId = Integer.parseInt( planetId );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return this.redirect( "overview" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.render( model , "game" , language , "planet" , pSession.flushQueue( pId , true ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
log4j.rootLogger=warn, stdout
|
0
legacyworlds-web-main/src/test/java/.empty
Normal file
0
legacyworlds-web-main/src/test/java/.empty
Normal file
0
legacyworlds-web-main/src/test/resources/.empty
Normal file
0
legacyworlds-web-main/src/test/resources/.empty
Normal file
Reference in a new issue