Package marauroa.server.game.rp
Class RPRuleProcessorImpl
java.lang.Object
marauroa.server.game.rp.RPRuleProcessorImpl
- All Implemented Interfaces:
IRPRuleProcessor
a default implementation of RPRuleProcessorImpl
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Notify it when a begin of actual turn happens.boolean
checkGameVersion(String game, String version)
Returns true if the version of the game is compatiblecreateAccount(String username, String password, String email)
Creates an account for the gamecreateAccountWithToken(String username, String tokenType, String token)
Create an account for a player in game.createCharacter(String username, String character, RPObject template)
Creates an new character for an account already logged into the gameprotected RPObject
createCharacterObject(String username, String character, RPObject template)
Creates an new character object that will used by createCharactervoid
endTurn()
Notify it when a end of actual turn happens.void
Execute an action in the name of a player.static IRPRuleProcessor
get()
gets the Rule singleton objectgetMimeTypeForResource(String resource)
gets the content type for the requested resourcegetResource(String resource)
gets an input stream to the requested resourceboolean
onActionAdd(RPObject caster, RPAction action, List<RPAction> actionList)
This method is called *before* adding an action by RPScheduler so you can choose not to allow the action to be added by returning falseboolean
Callback method called when a player exits the gameboolean
Callback method called when a new player enters in the gamevoid
Callback method called when a new player time out.void
setContext(RPServerManager rpman)
Set the context where the actions are executed.
-
Field Details
-
manager
RPServerManager
-
-
Constructor Details
-
RPRuleProcessorImpl
public RPRuleProcessorImpl()
-
-
Method Details
-
get
gets the Rule singleton object- Returns:
- Rule
-
setContext
Set the context where the actions are executed.- Specified by:
setContext
in interfaceIRPRuleProcessor
- Parameters:
rpman
- the RPServerManager object that is running our actions
-
checkGameVersion
Returns true if the version of the game is compatible- Specified by:
checkGameVersion
in interfaceIRPRuleProcessor
- Parameters:
game
- the game nameversion
- the game version- Returns:
- true, if the game and version is compatible
-
onTimeout
Callback method called when a new player time out. This method MUST logout the player- Specified by:
onTimeout
in interfaceIRPRuleProcessor
- Parameters:
object
- the new player that timeouts.- Throws:
RPObjectNotFoundException
- if the object was not found
-
onExit
Callback method called when a player exits the game- Specified by:
onExit
in interfaceIRPRuleProcessor
- Parameters:
object
- the new player that exits the game.- Returns:
- true to allow player to exit
- Throws:
RPObjectNotFoundException
- if the object was not found
-
onInit
Callback method called when a new player enters in the game- Specified by:
onInit
in interfaceIRPRuleProcessor
- Parameters:
object
- the new player that enters in the game.- Returns:
- true if object has been added.
- Throws:
RPObjectInvalidException
- if the object was not accepted
-
beginTurn
public void beginTurn()Notify it when a begin of actual turn happens.- Specified by:
beginTurn
in interfaceIRPRuleProcessor
-
onActionAdd
This method is called *before* adding an action by RPScheduler so you can choose not to allow the action to be added by returning false- Specified by:
onActionAdd
in interfaceIRPRuleProcessor
- Parameters:
caster
- the object that casted the actionaction
- the action that is going to be added.actionList
- the actions that this player already owns.- Returns:
- true if we approve the action to be added.
-
endTurn
public void endTurn()Notify it when a end of actual turn happens.- Specified by:
endTurn
in interfaceIRPRuleProcessor
-
execute
Execute an action in the name of a player.- Specified by:
execute
in interfaceIRPRuleProcessor
- Parameters:
caster
- the object that executesaction
- the action to execute
-
createAccount
Creates an account for the game- Specified by:
createAccount
in interfaceIRPRuleProcessor
- Parameters:
username
- the username who is going to be added.password
- the password for our username.email
- the email of the player for notifications or password reminders.- Returns:
- the Result of creating the account.
-
createAccountWithToken
Create an account for a player in game. Uses token instead of password for cases like 3rd party authentication (e.g. google sign-in).- Specified by:
createAccountWithToken
in interfaceIRPRuleProcessor
- Parameters:
username
- username for a new accounttokenType
- token typetoken
- auth token to verify, usually obtained from 3rd party- Returns:
- the Result of creating a new account
-
createCharacter
Creates an new character for an account already logged into the game- Specified by:
createCharacter
in interfaceIRPRuleProcessor
- Parameters:
username
- the username who owns the account of the character to be added.character
- the character to createtemplate
- the desired values of the avatar representing the character.- Returns:
- the Result of creating the character.
-
createCharacterObject
Creates an new character object that will used by createCharacter- Parameters:
username
- the username who owns the account of the character to be added.character
- the character to createtemplate
- the desired values of the avatar representing the character.- Returns:
- RPObject
-
getMimeTypeForResource
gets the content type for the requested resource- Specified by:
getMimeTypeForResource
in interfaceIRPRuleProcessor
- Parameters:
resource
- name of resource- Returns:
- mime content/type or
null
-
getResource
gets an input stream to the requested resource- Specified by:
getResource
in interfaceIRPRuleProcessor
- Parameters:
resource
- name of resource- Returns:
- InputStream or
null
-