@startuml
skinparam class {
    BackgroundColor LightYellow
    BackgroundColor<<child>> PaleGreen
    BackgroundColor<<embedded>> LightBlue
}

entity game {
  * pk: g#UUID
  * sk: #game#hostUserId
  --
  * kind: 'game'
  * status
  * chatRoomId
  * hostUser
  * createDate
  * gameRuleSetName
  * minPlayers
  * maxPlayers
  * players
  * options
  * deckSetId
  * deckName
  * deckImageBaseURL
  * deckCards
  * gameState
  * calcPlayersNeeded

  GSI_1: list of joinable games - #status#createDate#calcPlayersNeeded
  optional_attribute
}

entity gamePlayer <<child>> {
* pk: g#UUID
* sk: #players
* kind: 'gamePlayer'
* userId
* pronouns
* handle
* isDealer
* isActivePlayer
* didExit
* computerPlayerId
}
game ||--|{ gamePlayer

entity gameState <<child>>{
* pk: g#UUID
* sk: #state
* kind: 'gameState'
* currentRound
* completedRounds
* score
}
game ||--|| gameState

entity round <<embedded>> {
    *roundNumber
    *numTricksThisRound
    *playerBids
    *playerWonTricks: array<userId, number>
    *currentTrick: trick
}
gameState ||--|{ round

entity trick <<embedded>> {
    *isTrumpsBroken: boolean
    *playerCards
}

entity hand <<embedded>> {
    userId: array<UUID>
    cards:  array<suit, face>
}


entity gameConfig<<child>>{
* pk: g#UUID
* sk: #options
* kind: 'gameConfig'
}
game ||--|| gameConfig

entity chatRoom {
  * pk : chrm#UUID or chrm#front
  * sk : chrm#UUID or chrm#front
  --
  * kind: 'chatRoom'
  * channelName
  * ownerUserId
  * members: array<{wscn, uid} websocketConnection UserId
  * isprivate
  * LogLength
  * LogDuration
  * chatLog (last LogLength chats)
}

entity chat <<child>> {
  * pk: chrm#UUID or chrm#front
  * sk: chrm#UUID#ch#UUID 
  --
  * kind: 'chat'
  * actionDateTime
  * text
  * fromConnectionId
  * fromUserId
  * fromHandle
  * fromPronouns
  * targetChannelId
  --
  index for most recent chats in channel
}
game ||--|{ chat
chatRoom ||--|{ chat

entity user {
  * pk: u#UUID
  * sk: handle
  --
  kind: 'user'
  email
  handle
  pronouns
}

entity deck {
  * pk: d#UUID
  * sk: #name
  --
  * kind: 'deck'
  * name
  * deckImageBaseURL
  * cards[{suit, value, path}]
}
game ||--|| deck


@enduml