GameDesign: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 1:
= Basic idea behind GameManager =
The idea behind the Game Manager is to handle all the "business logic". This Manager decides how to reply to each individual message.
= GameManager =
The logic is similar to this:
<pre>
GameManager
{
NetworkManager read Message
switch(Message type)
{
case ...;
}
}
</pre>
So let's define the reply to each message. Before explaining how to process eahc message, let's clarify that the best way of modelling this system is using finite automates, (finite state machine) where, based on the input, we change the state we are currently in and produce an output.
<pre>
Process C2S Login ( STATE_BEGIN_LOGIN )
Precondition: The state MUST be NULL
Test if there is room for more players.
if there is no more room
{
reply S2C Login NACK( SERVER_FULL )
state = NULL
}
if check username, password in database is correct
{
create clientid
add PlayerEntry
notify database
reply S2C Login ACK
get characters list of the player
reply S2C CharacterList
state = STATE_LOGIN_COMPLETE
}
else
{
notify database
reply S2C Login NACK( LOGIN_INCORRECT )
state = NULL
}
Postcondition: The state MUST be NULL or STATE_LOGIN_COMPLETE
and a we have created a PlayerEntry for this player with an unique correct clientid.
Process C2S ChooseCharacter ( STATE_LOGIN_COMPLETE )
Precondition: The state MUST be STATE_LOGIN_COMPLETE
if character exists in database
{
add character to Player's PlayerEntry
add character to game
reply S2C Choose Character ACK
state = STATE_GAME_BEGIN
}
else
{
reply S2C Choose Character NACK
state = STATE_LOGIN_COMPLETE
}
Postcondition: The state MUST be STATE_GAME_BEGIN and the PlayerStructure
should be completely filled or if the character choise was wrong the state is STATE_LOGIN_COMPLETE
Process C2S Logout ( STATE_GAME_END )
Precondition: The state can be anything but STATE_LOGIN_BEGIN
if( rpEngine allows player to logout )
{
reply S2C Logout ACK
state = NULL
store character in database
remove character from game
delete PlayerEntry
}
else
{
reply S2C Logout NACK
}
Postcondition: Either the same as the input state or the state currently in
Process C2S Perception ACK
Precondition: The state must be STATE_LOGIN_BEGIN
notify that the player received the perception.
Postcondition: The state is STATE_LOGIN_BEGIN and Timestamp field in
PlayerContainer is updated.
Process C2S Transfer ACK
Precondition: The state must be STATE_LOGIN_BEGIN
foreach content waiting for this player
{
if client acked it
{
send content to client
}
}
Postcondition: The state is STATE_LOGIN_BEGIN and the content waiting for player is clear.
</pre>
3.a Database Tables and Relationships
Last updated: 2003/10/07
| |||