Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 750ebf46 rédigé par Malo Grall's avatar Malo Grall
Parcourir les fichiers

Fixed PUML import

parent 35d02687
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #55882 réussi
@startuml
!include ./server-interfaces.puml
!include ./client-interfaces.puml
' START CLIENT
interface Client {
' Variables
- clientMiddleware: ClientMiddleware
- game: GamePublic
- player: Player
' Methods
+ refreshGameState (Pair(GameState, int)): void
' Check if card needs player to buy from neighbors
- canPlayCard(Card card): boolean
}
note left of Client::game
All data to display the game
end note
note left of Client::refreshGameState
Change menu data, status of the game (ex: number of players)
end note
interface ClientMiddleware {
' Variables
- server: ServerMiddleware
- client: Client
' Methods
+ getGameState (): Pair(GameState, int)
+ message(String command, String [] args)
+ message(String command)
}
note top of ClientMiddleware
Transform client function calls
to WebSocket Server calls
end note
Client -- ClientMiddleware
' END CLIENT
' START SERVER
interface ServerMiddleware {
' Variables
- clients: Map<String, ClientMiddleware>
- server: Server
' Methods
+ refreshClient (Player player): void
+ refreshAllClients (GamePublic gamePublic): void
+ refreshGameState (GameState gameState): void
+ broadCastLeaderBoard(Map<PlayerPublic, int> leaderboard): void
- message(String command, String [] args)
- message(String command)
}
note top of ServerMiddleware
Transform client WebSocket
calls to Java methods
end note
interface Server {
' Variables
- game: Game
- serverMiddleware: ServerMiddleware
' Methods
+ joinGame (String userId, String userName): boolean
+ leaveGame (String userId): void
+ startGame (): boolean
+ getGameState (): GameState
' Return if action valid
+ playCard(String playerId, Card card, Action action): boolean
' Resources have to be bought from neighbors (PlayerID, Resource, Quantity)
+ playCard(String playerId, Card card, Action action, List<Triplet<String, Resource, int>> buyFromNeighbors): boolean
}
note right of Server::getRoomState
Get the state of the game Room
end note
interface GamePublic {
- currentAge: Age
- gameTurn: int
- currentAgeCards: List<Card>
- gameState: GameState
- playersPublic: List<PlayerPublic>
- server: Server
}
interface Game extends GamePublic {
- players: List<Player>
'Methods
'Create a Player instance and add it to players
+ addPlayer(String userId, String userName)
' Initialize and start the game (UseCase preparation)
+ startGame(): void
' End the game
+ endGame(): void
' Get the current game with private informations hiden
+ getGamePublic(): GamePublic
' Set card as currentCard and remove card from handCards
+ playCard(String playerId, Card card, Action action): void
'Get the player with playerId
+ getPlayer(String playerId): Player
' Buy raw material from a player (neighbor)
- buyRessourceFrom(String buyerId, String sellerId, Resource resource): void
'Start the age to set the cards pool
- startAge(Age age): void
' Fill every Player::handCards with default cards from currentAgeCards
- distributeCards(): void
' Get the 2 neighbors of the player
- getNeighbors(Player p) : Pair<Player, Player>
' Give Player::handCards to player neighbor
- nextTurn(): void
' Give Player::handCards to player neighbor
- giveNeighbor(List<Card>): void
' At the end of Age, compare the army of the 2 neighbors of the player and attribute victory points accordingly
- fight(Player p): void
' Get the leaderboard of the game
- getLeaderboard(): Map<Player, int>
}
interface PlayerPublic {
- userId: String
- userName: String
- wonder: Wonder
- VictoryPoints: int
- DefeatPoints: int
- ConlictPoints: int
- Money: int
' Possessed resources
- resources: Map<Resource, int>
' Built cards
- builtCards: List<Card>
'Methods
+ <<create>> PlayerPublic(): PlayerPublic
}
interface Player extends PlayerPublic {
' Available cards to choose in
- handCards: List<Card>
' Methods
' Get the current player with private information hiden
+ getPlayerPublic(): PlayerPublic
}
interface Wonder {
- priceStage1: Pair<Resource, int>
- priceStage2: Pair<Resource, int>
- priceStage3: Pair<Resource, int>
- stage2Effect: Pair<Effect, int>
- victoryPointStage1: int
- victoryPointStage2: int
- victoryPointStage3: int
- currentStage: int
- defaultResource: Resource
}
enum Effect {
ADD_SHIELDS
ADD_RAW_MATERIAL
ADD_GOLD
' Add a science symbol chosen by the player at the end of the game
ADD_SCIENCE_SYMBOL
' Build 1 building free
BUILD_FREE
' Choose one card from the discard and build it for free
CHOOSE_CARD_FROM_DISCARD_THEN_BUILD_FREE
ADD_VICTORY_POINTS
}
enum Age {
AGE1
AGE2
AGE3
}
enum Action {
USE_CARD
UPGRADE_WONDER
DISCARD
}
enum gameState {
WAITING
STARTED
FULL
}
' Card enums
enum Resource {
' Matières premières
CLAY
STONE
WOOD
ORE
' Produits manufacturés
CLOTH
GLASS
PAPYRUS
}
interface Card {
- game: Game
+ <<create>> Card(Game game)
+ doAction() : void
}
ServerMiddleware -- Server
PlayerPublic -- Wonder
PlayerPublic -- Card
GamePublic -- Card
GamePublic -- PlayerPublic
Game -- Server
' END SERVER
ClientMiddleware .. ServerMiddleware
@enduml
\ No newline at end of file
@startuml
interface ServerMiddleware {
' Variables
- clients: Map<String, ClientMiddleware>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter