You are here: Links of Interest » HEIG-VD » [GEN] Génie Logiciel » Ars Tactica: Rapport Intermédiaire » Ars Tactica: Rapport Intermédiaire - Protocole
Ars Tactica: Rapport Intermédiaire - Protocole
Table of Contents
Ars Tactica: Rapport Intermédiaire - Protocole
Authentification
<uml title=“Authentication Packets”> hide empty methods hide empty fields
abstract class Packet {
+ id: long
}
Packet <|– ResponsePacket abstract class ResponsePacket {
+ responseTo: long
}
Packet <|– LoginRequest class LoginRequest «(P,Salmon)» {
+ username: String + password: String <i>hashed</i>
}
ResponsePacket <|– LoginResponse abstract class LoginResponse
LoginResponse <|– LoginSuccess class LoginSuccess «(P,Salmon)» {
+ sessionId: String + user: User
}
LoginResponse <|– LoginFailure class LoginFailure «(P,Salmon)» {
+ message: String
} </uml>
Authentification
<uml title=“Authentication Network Exchange”> Client → Server: LoginRequest(username, password) Server –> UserManager: authenticate(username) Server ←- UserManager: «success» Server → Client: LoginSuccess(user, sessionId) alt Failure Server ←- UserManager: «failure» Server → Client: LoginFailure(reason) end </uml>
<uml title=“Authentication Workflow”> title authenticate(user) start if (user in database?) then (no)
:LoginFailure;
elseif (password matches?) then (no)
:LoginFailure;
elseif (banned?) then (yes)
:LoginFailure;
else
:create session id; :LoginSuccess;
endif stop </uml>
Création de Compte
<uml title=“Account Creation Network Exchange”> Client → Server: CreateAccount(username, …) Server –> UserManager: createAccount(…) Server ←- UserManager: «success» Client ← Server: CreateSuccess() alt Failue Server ←- UserManager: «failure» Client ← Server: CreateFailure() end </uml>
Matchmaking
<uml title=“Matchmaking Packets”> hide empty methods hide empty fields
enum QueueType {
1v1 2v2 3v3
}
Packet <|– EnterQueue EnterQueue – QueueType : type
Packet <|– EnterLobby class EnterLobby «(P,Salmon)» {
+ lobby: Lobby
}
Packet <|– PlayerReady class PlayerReady «(P,Salmon)» {
+ player: User
}
Packet <|– EnterGame class EnterGame «(P,Salmon)» {
+ gameId: long
} </uml>
<uml title=“Matchmaking Workflow”> actor ClientA actor ClientB box “Server Software” participant Server participant “1v1 Queue” as Queue participant “Lobby #1” as Lobby participant “Game #1” as Game end box note over Queue: is empty
ClientA → Server: EnterQueue(1v1) Server –> Queue: enterQueue(ClientA, 1v1) activate Queue
ClientB → Server: EnterQueue(1v1) Server –> Queue: enterQueue(ClientB, 1v1)
Queue –> Lobby: «new» deactivate Queue activate Lobby
ClientA ← Lobby: EnterLobby(#1) ClientB ← Lobby: EnterLobby(#1)
ClientA → Lobby: PlayerReady(ClientA) hnote over Lobby broadcast PlayerReady(ClientA) endnote
ClientB → Lobby: PlayerReady(ClientB) hnote over Lobby broadcast PlayerReady(ClientB) endnote
Lobby –> Game: «new» activate Game Lobby –> Game: start() deactivate Lobby
ClientA ← Game: EnterGame(#1) ClientB ← Game: EnterGame(#1) deactivate Game </uml>
Partie de Jeu
<uml title=“Game Packets”> hide empty methods hide empty fields
abstract class Packet {
+id: long
}
Packet <|– EnterGame class EnterGame «(P,Salmon)» {
+gameId: long
}
Packet <|– EndGame class EndGame «(P,Salmon)» {
+winner: PlayerRef
}
Packet <|– MoveTurn class MoveTurn «(P,Salmon)» {
+nextPlayer: PlayerRef
}
Packet <|– SyncGameState class SyncGameState «(P,Salmon)» {
+gameWorld: GameWorld
}
Packet <|– SyncEntityState class SyncEntityState «(P,Salmon)» {
+entityId: long +components: Component[]
} </uml>
<uml title=“Game Workflow”> actor Player box “Server Software” participant GameHandler participant TurnHandler participant StateHandler participant ActionFactory participant Action participant GameWorld end box
Start of Game
Player ← GameHandler: EnterGame(#1)
GameHandler –> TurnHandler: initialize() activate TurnHandler GameHandler ←- TurnHandler: «done» deactivate TurnHandler GameHandler –> StateHandler: initialize() activate StateHandler StateHandler –> GameWorld: construct() activate GameWorld StateHandler ←- GameWorld: «done» deactivate GameWorld GameHandler ←- StateHandler: «done» deactivate StateHandler Player ← GameHandler: SyncGameState(world)
Player Turn
Player –> Player: Select Actor Player –> Player: Request Action Player → GameHandler: PerformAction(entity, action) GameHandler –> TurnHandler: isTurnOf activate TurnHandler alt Out of Turn GameHandler ←- TurnHandler: «false» Player ← GameHandler: Error(“Out of Turn”) end GameHandler ←- TurnHandler: «true» deactivate TurnHandler GameHandler –> StateHandler: performAction() activate StateHandler
StateHandler –> ActionFactory: getAction() activate ActionFactory ActionFactory –> Action: «create» activate Action StateHandler ←- ActionFactory: «return Action» deactivate ActionFactory
StateHandler –> Action: isValid? note left: Checks if the entity is able to perform the action
StateHandler –> GameWorld: beginAction() activate GameWorld #LightBlue note left: Tracks changes to entities
StateHandler –> Action: apply() activate Action #DarkSalmon Action –> GameWorld: «changes» StateHandler ←- Action: «done» deactivate Action deactivate Action
StateHandler ←- GameWorld: getChanges() deactivate GameWorld
hnote over StateHandler broadcast SyncEntityState(changes) endnote
StateHandler –> StateHandler: checkVictory()
alt Player Wins hnote over StateHandler broadcast GameEnd(victor) endnote end
GameHandler ←- StateHandler: «done» deactivate StateHandler
… Passing Turn …
Player → GameHandler: EndTurn() GameHandler –> TurnHandler: nextTurn() activate TurnHandler GameHandler ←- TurnHandler: «new player» deactivate TurnHandler hnote over GameHandler broadcast MoveTurn(new player) endnote
</uml>