Improved I18N support:

* GamePageData now includes the selected language's code.
* Added support for multiple fetches in one call to the Translator
service.
This commit is contained in:
Emmanuel BENOîT 2012-04-05 11:25:08 +02:00
parent c7949e41cc
commit 9a7bc03171
9 changed files with 316 additions and 50 deletions
legacyworlds-session/src/main/java/com/deepclone/lw/cmd/player/gdata

View file

@ -8,23 +8,91 @@ import java.util.List;
/**
* General information included in a game response
*
* <p>
* This class stores common information which is included in most in-game responses. This
* information includes some essential preferences, the general state of the empire, and some
* information about the server's state.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class GamePageData
implements Serializable
{
/**
* The serialisation version identifier
*
* <ul>
* <li>Introduced in B6M1 with ID 1
* <li>Modified in B6M2, ID set to 2
* </ul>
*/
private static final long serialVersionUID = 1L;
/** The name of the current empire */
private final String empire;
/**
* State of the account
*
* <p>
* This field indicates the "special" state of the account: <code>q</code> is for accounts that
* are quitting, <code>v</code> for accounts in vacation mode and <code>s</code> for accounts
* that are about to enter vacation mode. <code>null</code> indicates "none of the above".
*/
private final Character special;
/** Alliance tag, or <code>null</code> if not a full member of any alliance */
private final String alliance;
/**
* Current cash of the empire
*
* <p>
* FIXME: will be replaced with actual resources
*/
private final long cash;
/** Timestamp from the server's system */
private final Date serverTime;
/** Current game time (from last update identifier) */
private final GameTime gameTime;
/** Planets owned by the empire */
private final List< NameIdPair > planets;
/** Whether the player wants to see "real" times or in-game times */
private final boolean useRLTime;
/** Code of selected language */
private final String language;
/**
* Initialise the general game information record
*
* @param empire
* the empire's name
* @param special
* the special account state character (see {@link #special})
* @param alliance
* current alliance tag
* @param cash
* current cash
* @param gameTime
* last update identifier
* @param planets
* list of planets owned by the empire
* @param useRLTime
* whether the player wants to see "real" times or in-game times
* @param language
* selected language code
*/
public GamePageData( String empire , Character special , String alliance , long cash , long gameTime ,
List< NameIdPair > planets , boolean useRLTime )
List< NameIdPair > planets , boolean useRLTime , String language )
{
this.empire = empire;
this.special = special;
@ -34,54 +102,107 @@ public class GamePageData
this.gameTime = new GameTime( gameTime );
this.planets = Collections.unmodifiableList( planets );
this.useRLTime = useRLTime;
this.language = language;
}
/**
* Gets the name of the current empire.
*
* @return the name of the current empire
*/
public String getEmpire( )
{
return empire;
return this.empire;
}
/**
* Gets the state of the account
*
* @return the state of the account
*/
public Character getSpecial( )
{
return special;
return this.special;
}
/**
* Gets the alliance tag
*
* @return the alliance tag, or <code>null</code> if not a full member of any alliance
*/
public String getAlliance( )
{
return alliance;
return this.alliance;
}
/**
* Gets the current cash of the empire
*
* @return the current cash of the empire
*/
public long getCash( )
{
return cash;
return this.cash;
}
/**
* Gets the timestamp from the server's system.
*
* @return the timestamp from the server's system
*/
public Date getServerTime( )
{
return serverTime;
return this.serverTime;
}
/**
* Gets the current game time
*
* @return the current game time
*/
public GameTime getGameTime( )
{
return gameTime;
return this.gameTime;
}
/**
* Gets the planets owned by the empire.
*
* @return the list of planets owned by the empire
*/
public List< NameIdPair > getPlanets( )
{
return planets;
return this.planets;
}
/**
* Checks if the player wants to see "real" times or in-game times.
*
* @return <code>true</code> if the player wants to see "real" times, <code>false</code> for
* in-game times
*/
public boolean isUseRLTime( )
{
return useRLTime;
return this.useRLTime;
}
/**
* Gets the code of selected language.
*
* @return the code of selected language
*/
public String getLanguage( )
{
return this.language;
}
}