Importing SVN archives - Trunk
This commit is contained in:
parent
fc4c6bd340
commit
ff53af6668
507 changed files with 8866 additions and 2450 deletions
legacyworlds-web/legacyworlds-web-main
|
@ -1,4 +1,4 @@
|
|||
<@page title="Legacy Worlds Beta 6 - Milestone 1">
|
||||
<@page title="Legacy Worlds Beta 6 - Milestone 2">
|
||||
<p>
|
||||
Welcome to the first milestone release for Legacy Worlds' Beta 6.
|
||||
</p>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<@page title="Empire">
|
||||
|
||||
<#assign ov = data.overview >
|
||||
<#assign rs = data.research >
|
||||
|
||||
<@tabs>
|
||||
|
||||
|
@ -61,56 +60,6 @@
|
|||
|
||||
</@right_column>
|
||||
</@tab>
|
||||
|
||||
<@tab id="research" title="Research">
|
||||
<#if rs?size == 0>
|
||||
<p>Our scientists are still settling in.</p>
|
||||
</#if>
|
||||
<#list rs as research>
|
||||
<div>
|
||||
<h3>${research.name?xhtml}</h3>
|
||||
<p>${research.description?xhtml}</p>
|
||||
|
||||
<@left_column>
|
||||
<#if research.implemented?size == 0>
|
||||
<p>No usable technologies.</p>
|
||||
<#else>
|
||||
<@dt_main>
|
||||
<#list research.implemented as tech>
|
||||
<@dt_status>
|
||||
${tech.name?xhtml}
|
||||
<div class="auto-hide">${tech.description?xhtml}</div>
|
||||
</@dt_status>
|
||||
</#list>
|
||||
</@dt_main>
|
||||
</#if>
|
||||
</@left_column>
|
||||
|
||||
<#if research.current?has_content>
|
||||
<@right_column>
|
||||
<@dt_main>
|
||||
<@dt_status>
|
||||
Current research: <strong>${research.current.name?xhtml}</strong>
|
||||
<p>
|
||||
${research.current.description?xhtml}
|
||||
</p>
|
||||
</@dt_status>
|
||||
<@dt_entry title="Progress">${research.current.researched}%</@dt_entry>
|
||||
<#if research.current.cost?has_content>
|
||||
<@dt_entry title="Cost">${research.current.cost?string(",##0")} <@abbr_bgc/></@dt_entry>
|
||||
<#if data.page.cash gte research.current.cost && data.page.special! != 'v'>
|
||||
<@dt_status><form action="implement-${research.id}.action#research" method="post">
|
||||
<div><@ff_submit label="Implement technology" /></div>
|
||||
</form></@dt_status>
|
||||
</#if>
|
||||
</#if>
|
||||
</@dt_main>
|
||||
</@right_column>
|
||||
</#if>
|
||||
|
||||
</div>
|
||||
</#list>
|
||||
</@tab>
|
||||
|
||||
</@tabs>
|
||||
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
<#macro render_entry identifier title category description>
|
||||
<div class="research-entry" id="research-${identifier?xhtml}">
|
||||
<div class="title">${title?xhtml}</div>
|
||||
<div class="category">Category: <b>${category?xhtml}</b></div>
|
||||
<div class="description">${description?xhtml}</div>
|
||||
<#nested>
|
||||
</div>
|
||||
</#macro>
|
||||
<#macro render_implementable entry>
|
||||
<@render_entry entry.identifier entry.name entry.category entry.description>
|
||||
<div class="cost">Cost: <b>${entry.cost?string(",##0")}</b> <@abbr_bgc/></div>
|
||||
<#if data.page.cash >= entry.cost>
|
||||
<form class="implement" name="implement-${entry.identifier?xhtml}" action="implement-tech.action" method="POST">
|
||||
<input type="hidden" name="technology" value="${entry.identifier?xhtml}" />
|
||||
<input type="submit" class="input" value="Implement technology" />
|
||||
</form>
|
||||
</#if>
|
||||
</@render_entry>
|
||||
</#macro>
|
||||
<#macro render_research entry title description display_priority_form>
|
||||
<@render_entry entry.identifier title entry.category description>
|
||||
<div class="progress">Progress: <span class="progress">${entry.completion}%</span></div>
|
||||
<#if display_priority_form>
|
||||
<div class="priority">
|
||||
Priority:
|
||||
<span class="priority">
|
||||
<input type="text" maxlength="3" size="4" class="input priority-field" name="priority-${entry.identifier?xhtml}" id="priority-${entry.identifier?xhtml}" value="${entry.priority}" />%
|
||||
</span>
|
||||
</div>
|
||||
</#if>
|
||||
</@render_entry>
|
||||
</#macro>
|
||||
<#macro render_unidentified entry display_priority_form>
|
||||
<@render_research entry "Unidentified technology" "Our researchers are working on something new, but they have no clue where it will lead at this time." display_priority_form />
|
||||
</#macro>
|
||||
<#macro render_research_list entries>
|
||||
<#local priority_form_started = false>
|
||||
<#local priority_form_checked = false>
|
||||
<#local display_priority_form = false>
|
||||
<#local counter = 0>
|
||||
<#-- List of in-progress research topics as well as implementable technologies -->
|
||||
<#list entries as entry>
|
||||
<#if entry.cost?has_content>
|
||||
<#-- Technology that can be implemented -->
|
||||
<#local counter = counter + 1>
|
||||
<@render_implementable entry />
|
||||
<#else>
|
||||
<#if ! priority_form_checked>
|
||||
<#-- Check whether we need to display the priority form -->
|
||||
<#if entries?size - counter > 1>
|
||||
<#local display_priority_form = true>
|
||||
</#if>
|
||||
<#local priority_form_checked = true>
|
||||
</#if>
|
||||
<#-- Start of the research priority form, if necessary -->
|
||||
<#if display_priority_form && ! priority_form_started>
|
||||
<#local priority_form_started = true>
|
||||
<form name="priority" action="set-research-priority.action" method="POST">
|
||||
</#if>
|
||||
<#if entry.name?has_content>
|
||||
<#-- Identified technology being researched -->
|
||||
<@render_research entry entry.name entry.description display_priority_form />
|
||||
<#else>
|
||||
<#-- Unidentified technology -->
|
||||
<@render_unidentified entry display_priority_form />
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<#-- End of the research priority form, if necessary -->
|
||||
<#if priority_form_started>
|
||||
<div class="submit-priorities">
|
||||
<input type="submit" class="input" value="Update research priorities" />
|
||||
</div>
|
||||
</form>
|
||||
</#if>
|
||||
</#macro>
|
||||
<#macro find_tech_name id lists>
|
||||
<#local found=false>
|
||||
<#list lists as cat>
|
||||
<#list cat.technologies as tech>
|
||||
<#if tech.identifier == id><#local found=true>${tech.name?xhtml}<#break></#if>
|
||||
</#list>
|
||||
<#if found><#break></#if>
|
||||
</#list>
|
||||
</#macro>
|
||||
<#macro render_tech_dependencies deps fullLists>
|
||||
<ul>
|
||||
<#list deps as dependency>
|
||||
<li><a href="#tech-${dependency?xhtml}"><@find_tech_name dependency fullLists /></a></li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#macro>
|
||||
<#macro render_technology tech fullList>
|
||||
<div class="technology" id="tech-${tech.identifier?xhtml}">
|
||||
<div class="title">${tech.name?xhtml}</div>
|
||||
<div class="description">
|
||||
<p>${tech.description?xhtml}</p>
|
||||
</div>
|
||||
|
||||
<#if tech.dependsOn?size != 0>
|
||||
<div class="dependencies">
|
||||
<b>Depends on:</b>
|
||||
<@render_tech_dependencies tech.dependsOn fullList />
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<#if tech.dependencyOf?size != 0>
|
||||
<div class="rev-deps">
|
||||
<b>Required by:</b>
|
||||
<@render_tech_dependencies tech.dependencyOf fullList />
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
</div>
|
||||
</#macro>
|
||||
<#macro render_tech_list categories>
|
||||
<#-- List categories -->
|
||||
<#list categories as category>
|
||||
<div class="tech-category">
|
||||
<h2>${category.name?xhtml}</h2>
|
||||
<p>${category.description?xhtml}</p>
|
||||
<#-- List technologies in the category -->
|
||||
<#list category.technologies as technology>
|
||||
<@render_technology technology categories />
|
||||
</#list>
|
||||
</div>
|
||||
</#list>
|
||||
</#macro>
|
||||
<#macro render>
|
||||
<@page title="Technologies">
|
||||
|
||||
<#if data.research?size == 0 && data.implementedTechnologies?size == 0>
|
||||
<p>Our scientists are still settling in, please come back in a little while...</p>
|
||||
<#return>
|
||||
</#if>
|
||||
|
||||
<@tabs>
|
||||
|
||||
<#if data.research?size != 0>
|
||||
<@tab id="research" title="Research">
|
||||
<#if data.result?exists>
|
||||
<#switch data.result>
|
||||
<#case "ERR_RESOURCES">
|
||||
<@standalone_error>We do not possess the necessary resources anymore.</@standalone_error>
|
||||
<#break>
|
||||
<#case "ERR_STATE_CHANGED">
|
||||
<@standalone_error>Something changed... Please try again.</@standalone_error>
|
||||
<#break>
|
||||
<#case "ERR_INVALID">
|
||||
<@standalone_error>Invalid priorities.</@standalone_error>
|
||||
<#break>
|
||||
<#default>
|
||||
<#-- Ignore other error codes -->
|
||||
<#break>
|
||||
</#switch>
|
||||
</#if>
|
||||
<#-- Render the list -->
|
||||
<@render_research_list data.research />
|
||||
</@tab>
|
||||
</#if>
|
||||
|
||||
<#if data.implementedTechnologies?size != 0>
|
||||
<@tab id="implemented" title="Implemented technologies">
|
||||
<@render_tech_list data.implementedTechnologies />
|
||||
</@tab>
|
||||
</#if>
|
||||
|
||||
</@tabs>
|
||||
|
||||
</@page>
|
||||
</#macro>
|
|
@ -2,7 +2,6 @@
|
|||
<@page title="Empire">
|
||||
|
||||
<#assign ov = data.overview >
|
||||
<#assign rs = data.research >
|
||||
|
||||
<@tabs>
|
||||
|
||||
|
@ -61,56 +60,6 @@
|
|||
|
||||
</@right_column>
|
||||
</@tab>
|
||||
|
||||
<@tab id="research" title="Recherche">
|
||||
<#if rs?size == 0>
|
||||
<p>Nos scientifiques sont encore en train de s'installer.</p>
|
||||
</#if>
|
||||
<#list rs as research>
|
||||
<div>
|
||||
<h3>${research.name?xhtml}</h3>
|
||||
<p>${research.description?xhtml}</p>
|
||||
|
||||
<@left_column>
|
||||
<#if research.implemented?size == 0>
|
||||
<p>Aucune technologie utilisable.</p>
|
||||
<#else>
|
||||
<@dt_main>
|
||||
<#list research.implemented as tech>
|
||||
<@dt_status>
|
||||
${tech.name?xhtml}
|
||||
<div class="auto-hide">${tech.description?xhtml}</div>
|
||||
</@dt_status>
|
||||
</#list>
|
||||
</@dt_main>
|
||||
</#if>
|
||||
</@left_column>
|
||||
|
||||
<#if research.current?has_content>
|
||||
<@right_column>
|
||||
<@dt_main>
|
||||
<@dt_status>
|
||||
Recherche actuelle : <strong>${research.current.name?xhtml}</strong>
|
||||
<p>
|
||||
${research.current.description?xhtml}
|
||||
</p>
|
||||
</@dt_status>
|
||||
<@dt_entry title="Progression">${research.current.researched}%</@dt_entry>
|
||||
<#if research.current.cost?has_content>
|
||||
<@dt_entry title="Coût">${research.current.cost?string(",##0")} <@abbr_bgc/></@dt_entry>
|
||||
<#if data.page.cash gte research.current.cost && data.page.special! != 'v'>
|
||||
<@dt_status><form action="implement-${research.id}.action#research" method="post">
|
||||
<div><@ff_submit label="Appliquer la technologie" /></div>
|
||||
</form></@dt_status>
|
||||
</#if>
|
||||
</#if>
|
||||
</@dt_main>
|
||||
</@right_column>
|
||||
</#if>
|
||||
|
||||
</div>
|
||||
</#list>
|
||||
</@tab>
|
||||
|
||||
</@tabs>
|
||||
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
<#macro render_entry identifier title category description>
|
||||
<div class="research-entry" id="research-${identifier?xhtml}">
|
||||
<div class="title">${title?xhtml}</div>
|
||||
<div class="category">Catégorie: <b>${category?xhtml}</b></div>
|
||||
<div class="description">${description?xhtml}</div>
|
||||
<#nested>
|
||||
</div>
|
||||
</#macro>
|
||||
<#macro render_implementable entry>
|
||||
<@render_entry entry.identifier entry.name entry.category entry.description>
|
||||
<div class="cost">Coût: <b>${entry.cost?string(",##0")}</b> <@abbr_bgc/></div>
|
||||
<#if data.page.cash >= entry.cost>
|
||||
<form class="implement" name="implement-${entry.identifier?xhtml}" action="implement-tech.action" method="POST">
|
||||
<input type="hidden" name="technology" value="${entry.identifier?xhtml}" />
|
||||
<input type="submit" class="input" value="Appliquer la technologie" />
|
||||
</form>
|
||||
</#if>
|
||||
</@render_entry>
|
||||
</#macro>
|
||||
<#macro render_research entry title description display_priority_form>
|
||||
<@render_entry entry.identifier title entry.category description>
|
||||
<div class="progress">Progrès: <span class="progress">${entry.completion}%</span></div>
|
||||
<#if display_priority_form>
|
||||
<div class="priority">
|
||||
Priorité:
|
||||
<span class="priority">
|
||||
<input type="text" maxlength="3" size="4" class="input priority-field" name="priority-${entry.identifier?xhtml}" id="priority-${entry.identifier?xhtml}" value="${entry.priority}" />%
|
||||
</span>
|
||||
</div>
|
||||
</#if>
|
||||
</@render_entry>
|
||||
</#macro>
|
||||
<#macro render_unidentified entry display_priority_form>
|
||||
<@render_research entry "Technologie non identifiée" "Nos chercheurs travaillent sur une nouvelle technologie, mais ne savent pas encore où leurs travaux les mèneront." display_priority_form />
|
||||
</#macro>
|
||||
<#macro render_research_list entries>
|
||||
<#local priority_form_started = false>
|
||||
<#local priority_form_checked = false>
|
||||
<#local display_priority_form = false>
|
||||
<#local counter = 0>
|
||||
<#-- List of in-progress research topics as well as implementable technologies -->
|
||||
<#list entries as entry>
|
||||
<#if entry.cost?has_content>
|
||||
<#-- Technology that can be implemented -->
|
||||
<#local counter = counter + 1>
|
||||
<@render_implementable entry />
|
||||
<#else>
|
||||
<#if ! priority_form_checked>
|
||||
<#-- Check whether we need to display the priority form -->
|
||||
<#if entries?size - counter > 1>
|
||||
<#local display_priority_form = true>
|
||||
</#if>
|
||||
<#local priority_form_checked = true>
|
||||
</#if>
|
||||
<#-- Start of the research priority form, if necessary -->
|
||||
<#if display_priority_form && ! priority_form_started>
|
||||
<#local priority_form_started = true>
|
||||
<form name="priority" action="set-research-priority.action" method="POST">
|
||||
</#if>
|
||||
<#if entry.name?has_content>
|
||||
<#-- Identified technology being researched -->
|
||||
<@render_research entry entry.name entry.description display_priority_form />
|
||||
<#else>
|
||||
<#-- Unidentified technology -->
|
||||
<@render_unidentified entry display_priority_form />
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<#-- End of the research priority form, if necessary -->
|
||||
<#if priority_form_started>
|
||||
<div class="submit-priorities">
|
||||
<input type="submit" class="input" value="Modifier les priorités" />
|
||||
</div>
|
||||
</form>
|
||||
</#if>
|
||||
</#macro>
|
||||
<#macro find_tech_name id lists>
|
||||
<#local found=false>
|
||||
<#list lists as cat>
|
||||
<#list cat.technologies as tech>
|
||||
<#if tech.identifier == id><#local found=true>${tech.name?xhtml}<#break></#if>
|
||||
</#list>
|
||||
<#if found><#break></#if>
|
||||
</#list>
|
||||
</#macro>
|
||||
<#macro render_tech_dependencies deps fullLists>
|
||||
<ul>
|
||||
<#list deps as dependency>
|
||||
<li><a href="#tech-${dependency?xhtml}"><@find_tech_name dependency fullLists /></a></li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#macro>
|
||||
<#macro render_technology tech fullList>
|
||||
<div class="technology" id="tech-${tech.identifier?xhtml}">
|
||||
<div class="title">${tech.name?xhtml}</div>
|
||||
<div class="description">
|
||||
<p>${tech.description?xhtml}</p>
|
||||
</div>
|
||||
|
||||
<#if tech.dependsOn?size != 0>
|
||||
<div class="dependencies">
|
||||
<b>Dépend de:</b>
|
||||
<@render_tech_dependencies tech.dependsOn fullList />
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<#if tech.dependencyOf?size != 0>
|
||||
<div class="rev-deps">
|
||||
<b>Requise par:</b>
|
||||
<@render_tech_dependencies tech.dependencyOf fullList />
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
</div>
|
||||
</#macro>
|
||||
<#macro render_tech_list categories>
|
||||
<#-- List categories -->
|
||||
<#list categories as category>
|
||||
<div class="tech-category">
|
||||
<h2>${category.name?xhtml}</h2>
|
||||
<p>${category.description?xhtml}</p>
|
||||
<#-- List technologies in the category -->
|
||||
<#list category.technologies as technology>
|
||||
<@render_technology technology categories />
|
||||
</#list>
|
||||
</div>
|
||||
</#list>
|
||||
</#macro>
|
||||
<#macro render>
|
||||
<@page title="Technologies">
|
||||
|
||||
<#if data.research?size == 0 && data.implementedTechnologies?size == 0>
|
||||
<p>Nos chercheurs sont encore en train de s'installer, revenez dans un petit moment...</p>
|
||||
<#return>
|
||||
</#if>
|
||||
|
||||
<@tabs>
|
||||
|
||||
<#if data.research?size != 0>
|
||||
<@tab id="research" title="Recherche">
|
||||
<#if data.result?exists>
|
||||
<#switch data.result>
|
||||
<#case "ERR_RESOURCES">
|
||||
<@standalone_error>Nous ne possédons plus les ressources nécessaires.</@standalone_error>
|
||||
<#break>
|
||||
<#case "ERR_STATE_CHANGED">
|
||||
<@standalone_error>Quelque chose a changé... Veuillez réessayer.</@standalone_error>
|
||||
<#break>
|
||||
<#case "ERR_INVALID">
|
||||
<@standalone_error>Priorités invalides.</@standalone_error>
|
||||
<#break>
|
||||
<#default>
|
||||
<#-- Ignore other error codes -->
|
||||
<#break>
|
||||
</#switch>
|
||||
</#if>
|
||||
<#-- Render the list -->
|
||||
<@render_research_list data.research />
|
||||
</@tab>
|
||||
</#if>
|
||||
|
||||
<#if data.implementedTechnologies?size != 0>
|
||||
<@tab id="implemented" title="Technologies maîtrisées">
|
||||
<@render_tech_list data.implementedTechnologies />
|
||||
</@tab>
|
||||
</#if>
|
||||
|
||||
</@tabs>
|
||||
|
||||
</@page>
|
||||
</#macro>
|
|
@ -1,2 +1,2 @@
|
|||
<#macro version>Milestone 1</#macro>
|
||||
<#macro full_version>Beta 6 milestone 1 (5.99.1)</#macro>
|
||||
<#macro version>Milestone 2</#macro>
|
||||
<#macro full_version>Beta 6 milestone 2 (5.99.2)</#macro>
|
|
@ -839,4 +839,61 @@ tr.alliance-msg * {
|
|||
|
||||
tr.empire-msg * {
|
||||
color: #afafaf;
|
||||
}
|
||||
|
||||
/* Research and technologies */
|
||||
div.research-entry {
|
||||
padding: 0 0 15px 0;
|
||||
}
|
||||
|
||||
div.research-entry div {
|
||||
padding: 0 0 0 20px;
|
||||
}
|
||||
|
||||
div.research-entry div.title {
|
||||
color: white;
|
||||
font-size: 110%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.research-entry div.description {
|
||||
padding: 0 0 5px 20px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.research-entry div.progress {
|
||||
padding: 0 0 5px 20px;
|
||||
}
|
||||
|
||||
div.research-entry span.progress {
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.research-entry form.implement {
|
||||
padding: 5px 0 0 40px;
|
||||
}
|
||||
|
||||
div.tech-category {
|
||||
padding: 0 0 15px 0;
|
||||
}
|
||||
|
||||
div.technology {
|
||||
padding: 15px 0 0 20px;
|
||||
}
|
||||
|
||||
div.technology div {
|
||||
padding: 0 0 0 20px;
|
||||
}
|
||||
|
||||
div.technology div.title {
|
||||
color: white;
|
||||
font-size: 105%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.technology div.description {
|
||||
padding: 0;
|
||||
}
|
|
@ -4,12 +4,12 @@
|
|||
<parent>
|
||||
<artifactId>legacyworlds-web</artifactId>
|
||||
<groupId>com.deepclone.lw</groupId>
|
||||
<version>5.99.1</version>
|
||||
<version>5.99.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.deepclone.lw</groupId>
|
||||
<artifactId>legacyworlds-web-main</artifactId>
|
||||
<version>5.99.1</version>
|
||||
<version>5.99.2</version>
|
||||
<packaging>war</packaging>
|
||||
<name>Legacy Worlds main site</name>
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@ 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;
|
||||
|
@ -35,21 +33,4 @@ public class OverviewPage
|
|||
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,143 @@
|
|||
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.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
import com.deepclone.lw.cmd.player.gdata.empire.ResearchData;
|
||||
import com.deepclone.lw.cmd.player.research.ResearchOperationResponse;
|
||||
import com.deepclone.lw.cmd.player.research.ViewResearchResponse;
|
||||
import com.deepclone.lw.cmd.player.research.ResearchOperationResponse.Result;
|
||||
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 TechnologyPages
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@RequestMapping( "/technologies" )
|
||||
public String viewTechnologies( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
return this.renderPage( model , language , pSession.viewResearch( ) );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/implement-tech.action" , method = RequestMethod.POST )
|
||||
public String implement( HttpServletRequest request , @ModelAttribute( "language" ) String language , Model model ,
|
||||
@RequestParam( "technology" ) String tech )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
if ( tech == null || tech.equals( "" ) ) {
|
||||
return this.redirect( "technologies" );
|
||||
}
|
||||
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ResearchOperationResponse response = pSession.implementTechnology( tech );
|
||||
if ( response.getResult( ) == Result.OK ) {
|
||||
return this.redirect( "technologies" );
|
||||
}
|
||||
return this.renderPage( model , language , response );
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( value = "/set-research-priority.action" , method = RequestMethod.POST )
|
||||
public String setPriorities( HttpServletRequest request , @ModelAttribute( "language" ) String language ,
|
||||
Model model )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
PlayerSession pSession = this.getSession( PlayerSession.class , request );
|
||||
ResearchOperationResponse response;
|
||||
|
||||
Map< String , Integer > priorities = new HashMap< String , Integer >( );
|
||||
if ( this.getPriorityValues( priorities , request ) ) {
|
||||
response = pSession.setResearchPriorities( priorities );
|
||||
if ( response.getResult( ) == Result.OK ) {
|
||||
return this.redirect( "technologies" );
|
||||
}
|
||||
} else {
|
||||
response = this.createInvalidResponse( pSession , priorities );
|
||||
}
|
||||
|
||||
return this.renderPage( model , language , response );
|
||||
}
|
||||
|
||||
|
||||
private String renderPage( Model model , String language , ViewResearchResponse data )
|
||||
{
|
||||
return this.render( model , "game" , language , "technologies" , data );
|
||||
}
|
||||
|
||||
|
||||
private ResearchOperationResponse createInvalidResponse( PlayerSession pSession , Map< String , Integer > priorities )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ViewResearchResponse view = pSession.viewResearch( );
|
||||
for ( ResearchData research : view.getResearch( ) ) {
|
||||
Integer nPrio = priorities.get( research.getIdentifier( ) );
|
||||
if ( nPrio != null && research.getPriority( ) != null ) {
|
||||
research.setPriority( nPrio );
|
||||
}
|
||||
}
|
||||
return new ResearchOperationResponse( view.getPage( ) , view.getResearch( ) ,
|
||||
view.getImplementedTechnologies( ) , Result.ERR_INVALID );
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
private boolean getPriorityValues( Map< String , Integer > priorities , HttpServletRequest request )
|
||||
{
|
||||
Map< String , String[] > parameters = request.getParameterMap( );
|
||||
int total = 0;
|
||||
boolean ok = true;
|
||||
|
||||
for ( String pName : parameters.keySet( ) ) {
|
||||
if ( !pName.matches( "^priority-[A-Za-z0-9\\-]+" ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String tName = pName.substring( "priority-".length( ) );
|
||||
String pValues[] = parameters.get( pName );
|
||||
if ( pValues.length != 1 || pValues[ 0 ] == null ) {
|
||||
ok = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
int value;
|
||||
try {
|
||||
value = Integer.parseInt( pValues[ 0 ] );
|
||||
} catch ( NumberFormatException e ) {
|
||||
ok = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
priorities.put( tName , value );
|
||||
total += value;
|
||||
|
||||
ok = ok && ! ( value < 0 || value > 100 );
|
||||
}
|
||||
|
||||
return ok && total == 100 && priorities.size( ) >= 2;
|
||||
}
|
||||
}
|
Reference in a new issue