@startuml player-class-diagram title CR-Core — Player domain (class diagram) skinparam classAttributeIconSize 0 hide empty members ' === Common abstractions === package "fr.luc.crcore.util.common" { interface Identifiable { + getId(): UUID } interface ScoreHolder { + getScore(name): int + hasScore(name): boolean + getScores(): Map + getTotalScore(): int + addScore(name, delta): int + setScore(name, value): int + resetScore(name): boolean + resetAllScores(): void } abstract class AbstractEntity { - id: UUID + getId(): UUID } interface "Repository" as Repository { + save(entity: T): T + findById(id): Optional + findAll(): Collection + delete(id): boolean } AbstractEntity ..|> Identifiable } ' === Player domain === package "fr.luc.crcore.features.player" { class PlayerProfile { - scores: Map + PlayerProfile(playerId: UUID) + getPlayerId(): UUID } class PlayerRanking <> { + rank: int + profile: PlayerProfile + score: int } interface PlayerProfileRepository class InMemoryPlayerProfileRepository { - profiles: Map } interface PlayerProfileService { + getOrCreateProfile(playerId): PlayerProfile + getProfile(playerId): Optional + deleteProfile(playerId): boolean + getAllProfiles(): Collection -- + addScore(playerId, name, delta): int + setScore(playerId, name, value): int + getScore(playerId, name): int + resetScore(playerId, name): boolean + resetAllScores(playerId): void -- + getRankingByScore(name): List + getGlobalRanking(): List + getTopRankingByScore(name, limit): List + getTopGlobalRanking(limit): List } class PlayerProfileServiceImpl { - repository: PlayerProfileRepository -- # newProfile(playerId): PlayerProfile # newRanking(rank, profile, score): PlayerRanking # rank(scoreFn): List -- # onProfileCreated(profile): void # onProfileDeleted(profile): void # onScoreChanged(profile, name, oldV, newV): void } class PlayerException class PlayerProfileNotFoundException PlayerProfile --|> AbstractEntity PlayerProfile ..|> ScoreHolder PlayerProfileRepository --|> Repository InMemoryPlayerProfileRepository ..|> PlayerProfileRepository PlayerProfileServiceImpl ..|> PlayerProfileService PlayerRanking --> PlayerProfile PlayerProfileServiceImpl o--> PlayerProfileRepository PlayerProfileService ..> PlayerRanking : produces PlayerException --|> RuntimeException PlayerProfileNotFoundException --|> PlayerException } @enduml