Documentation ¶
Index ¶
- type AcceptFriendRequestParams
- type AcceptGameInvitationParams
- type ActivationToken
- type AddCardToPlayerHandParams
- type AddPlayerToGameParams
- type Card
- type CreateFriendshipParams
- type CreateGameInvitationWithUsernameParams
- type CreateSessionParams
- type CreateUserParams
- type DBTX
- type DeclareWinnerRow
- type DeleteGameInvitationParams
- type Dessert
- type DessertPlayed
- type DoesInvitationExistParams
- type DrawCardTxParams
- type DrawCardTxResult
- type EndTurnTxResult
- type Friend
- type Game
- type GameDeck
- type GameInvitation
- type GetGameByPlayerGameIDRow
- type GetGameScoresRow
- type GetPlayerHandRow
- type InsertActivationTokenParams
- type InsertIntoGameDeckParams
- type IsCardInPlayerHandParams
- type IsUserGameCreatorParams
- type ListActiveGamesParams
- type ListActivePlayerGamesRow
- type ListGamePlayersParams
- type ListPendingFriendRequestsRow
- type ListUserFriendsParams
- type ListUsersParams
- type PlayDessertTxParams
- type PlayedCard
- type PlayerGame
- type PlayerHand
- type PlayerTurnAction
- type Querier
- type Queries
- func (q *Queries) AcceptFriendRequest(ctx context.Context, arg AcceptFriendRequestParams) error
- func (q *Queries) AcceptGameInvitation(ctx context.Context, arg AcceptGameInvitationParams) error
- func (q *Queries) ActivateUser(ctx context.Context, id int64) error
- func (q *Queries) AddCardToPlayerHand(ctx context.Context, arg AddCardToPlayerHandParams) (int64, error)
- func (q *Queries) AddPlayerToGame(ctx context.Context, arg AddPlayerToGameParams) error
- func (q *Queries) BlockSession(ctx context.Context, id uuid.UUID) error
- func (q *Queries) CheckAllActionsCompleted(ctx context.Context, playerGameID int64) (sql.NullBool, error)
- func (q *Queries) CheckCardDrawn(ctx context.Context, playerGameID int64) (bool, error)
- func (q *Queries) CheckDessertPlayed(ctx context.Context, playerGameID int64) (bool, error)
- func (q *Queries) CheckSpecialCardPlayed(ctx context.Context, playerGameID int64) (bool, error)
- func (q *Queries) CreateFriendship(ctx context.Context, arg CreateFriendshipParams) (Friend, error)
- func (q *Queries) CreateGame(ctx context.Context, createdBy int64) (Game, error)
- func (q *Queries) CreateGameInvitationWithUsername(ctx context.Context, arg CreateGameInvitationWithUsernameParams) error
- func (q *Queries) CreatePlayerTurnActions(ctx context.Context, playerGameID int64) error
- func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
- func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
- func (q *Queries) DeclareWinner(ctx context.Context, gameID int64) (DeclareWinnerRow, error)
- func (q *Queries) DeleteActivationToken(ctx context.Context, userID int64) error
- func (q *Queries) DeleteFriendship(ctx context.Context, friendshipID int64) error
- func (q *Queries) DeleteGameInvitation(ctx context.Context, arg DeleteGameInvitationParams) error
- func (q *Queries) DeleteUser(ctx context.Context, id int64) error
- func (q *Queries) DoesInvitationExist(ctx context.Context, arg DoesInvitationExistParams) (bool, error)
- func (q *Queries) DrawTopCard(ctx context.Context, gameID int64) (int64, error)
- func (q *Queries) EndGame(ctx context.Context, gameID int64) error
- func (q *Queries) GetActivationToken(ctx context.Context, activationToken string) (ActivationToken, error)
- func (q *Queries) GetCardByID(ctx context.Context, cardID int64) (Card, error)
- func (q *Queries) GetCardByName(ctx context.Context, name string) (Card, error)
- func (q *Queries) GetDessertByName(ctx context.Context, name string) (Dessert, error)
- func (q *Queries) GetDessertIDByName(ctx context.Context, name string) (int64, error)
- func (q *Queries) GetDessertsPlayedByPlayer(ctx context.Context, playerGameID int64) ([]int64, error)
- func (q *Queries) GetFriendshipByID(ctx context.Context, friendshipID int64) (Friend, error)
- func (q *Queries) GetGameByID(ctx context.Context, gameID int64) (Game, error)
- func (q *Queries) GetGameByPlayerGameID(ctx context.Context, playerGameID int64) (GetGameByPlayerGameIDRow, error)
- func (q *Queries) GetGameDeck(ctx context.Context, gameID int64) (GameDeck, error)
- func (q *Queries) GetGameScores(ctx context.Context, gameID int64) ([]GetGameScoresRow, error)
- func (q *Queries) GetPlayedCards(ctx context.Context, playerGameID int64) ([]PlayedCard, error)
- func (q *Queries) GetPlayerGame(ctx context.Context, playerGameID int64) (PlayerGame, error)
- func (q *Queries) GetPlayerHand(ctx context.Context, playerGameID int64) ([]GetPlayerHandRow, error)
- func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error)
- func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)
- func (q *Queries) GetUserByID(ctx context.Context, id int64) (User, error)
- func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)
- func (q *Queries) InsertActivationToken(ctx context.Context, arg InsertActivationTokenParams) (ActivationToken, error)
- func (q *Queries) InsertIntoGameDeck(ctx context.Context, arg InsertIntoGameDeckParams) (int64, error)
- func (q *Queries) IsCardInPlayerHand(ctx context.Context, arg IsCardInPlayerHandParams) (bool, error)
- func (q *Queries) IsDeckEmpty(ctx context.Context, gameID int64) (bool, error)
- func (q *Queries) IsGameWon(ctx context.Context, playerGameID int64) (sql.NullBool, error)
- func (q *Queries) IsUserGameCreator(ctx context.Context, arg IsUserGameCreatorParams) (bool, error)
- func (q *Queries) ListActiveGames(ctx context.Context, arg ListActiveGamesParams) ([]Game, error)
- func (q *Queries) ListActivePlayerGames(ctx context.Context, playerID int64) ([]ListActivePlayerGamesRow, error)
- func (q *Queries) ListCardIDs(ctx context.Context) ([]int64, error)
- func (q *Queries) ListCards(ctx context.Context) ([]Card, error)
- func (q *Queries) ListCardsByType(ctx context.Context, type_ string) ([]Card, error)
- func (q *Queries) ListGameInvitationsForUser(ctx context.Context, inviteePlayerID int64) ([]GameInvitation, error)
- func (q *Queries) ListGamePlayers(ctx context.Context, arg ListGamePlayersParams) ([]PlayerGame, error)
- func (q *Queries) ListPendingFriendRequests(ctx context.Context, friendeeID int64) ([]ListPendingFriendRequestsRow, error)
- func (q *Queries) ListPlayerGames(ctx context.Context, playerID int64) ([]PlayerGame, error)
- func (q *Queries) ListUserFriends(ctx context.Context, arg ListUserFriendsParams) ([]Friend, error)
- func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
- func (q *Queries) RecordDessertPlayed(ctx context.Context, arg RecordDessertPlayedParams) error
- func (q *Queries) RecordPlayedCard(ctx context.Context, arg RecordPlayedCardParams) error
- func (q *Queries) RemoveCardFromDeck(ctx context.Context, arg RemoveCardFromDeckParams) error
- func (q *Queries) RemoveCardFromPlayerHand(ctx context.Context, arg RemoveCardFromPlayerHandParams) error
- func (q *Queries) ResetTurnActions(ctx context.Context, playerGameID int64) error
- func (q *Queries) StartGame(ctx context.Context, arg StartGameParams) error
- func (q *Queries) UpdateCardDrawnStatus(ctx context.Context, playerGameID int64) error
- func (q *Queries) UpdateDessertPlayedStatus(ctx context.Context, playerGameID int64) error
- func (q *Queries) UpdateGameState(ctx context.Context, arg UpdateGameStateParams) error
- func (q *Queries) UpdateGameStatus(ctx context.Context, arg UpdateGameStatusParams) error
- func (q *Queries) UpdatePlayerNumber(ctx context.Context, arg UpdatePlayerNumberParams) error
- func (q *Queries) UpdatePlayerScore(ctx context.Context, arg UpdatePlayerScoreParams) (PlayerGame, error)
- func (q *Queries) UpdatePlayerStatus(ctx context.Context, arg UpdatePlayerStatusParams) error
- func (q *Queries) UpdateSpecialCardPlayedStatus(ctx context.Context, playerGameID int64) error
- func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
- func (q *Queries) WithTx(tx *sql.Tx) *Queries
- type RecordDessertPlayedParams
- type RecordPlayedCardParams
- type RegisterTxResult
- type RemoveCardFromDeckParams
- type RemoveCardFromPlayerHandParams
- type SQLStore
- func (store *SQLStore) DrawCard(ctx context.Context, arg DrawCardTxParams) (DrawCardTxResult, error)
- func (store *SQLStore) EndTurnTx(ctx context.Context, gameID int64, playerGameID int64) (EndTurnTxResult, error)
- func (store *SQLStore) InitializeDeck(ctx context.Context, gameID int64, cardIDs []int64) (int64, error)
- func (store *SQLStore) PlayDessertTx(ctx context.Context, arg PlayDessertTxParams) (PlayerGame, error)
- func (store *SQLStore) RefreshPlayerPantryTx(ctx context.Context, playerGameID int64, cardID int64) error
- func (store *SQLStore) RegisterTx(ctx context.Context, arg CreateUserParams) (RegisterTxResult, error)
- func (store *SQLStore) StartGameTx(ctx context.Context, arg StartGameTxParams) (StartGameTxResult, error)
- func (store *SQLStore) StealRandomCardFromPlayerTx(ctx context.Context, playerGameID int64, cardID int64) (StealRandomCardFromPlayerTxResult, error)
- type Session
- type StartGameParams
- type StartGameTxParams
- type StartGameTxResult
- type StealRandomCardFromPlayerTxResult
- type Store
- type UpdateGameStateParams
- type UpdateGameStatusParams
- type UpdatePlayerNumberParams
- type UpdatePlayerScoreParams
- type UpdatePlayerStatusParams
- type UpdateUserParams
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivationToken ¶
type AddPlayerToGameParams ¶
type Card ¶
type Card struct { CardID int64 `json:"card_id"` Type string `json:"type"` Name string `json:"name"` }
Details of each card used in the game
type CreateFriendshipParams ¶
type CreateSessionParams ¶
type CreateUserParams ¶
type DeclareWinnerRow ¶
type DessertPlayed ¶
type DrawCardTxParams ¶
type DrawCardTxParams struct { GameID int64 `json:"game_id"` PlayerID int64 `json:"player_id"` PlayerNumber int32 `json:"player_number"` }
DrawTxParams holds parameters for the StartGameTx function
type DrawCardTxResult ¶
type EndTurnTxResult ¶
type EndTurnTxResult struct {
Game Game `json:"game"`
}
type Game ¶
type Game struct { GameID int64 `json:"game_id"` Status string `json:"status"` CreatedBy int64 `json:"created_by"` NumberOfPlayers int32 `json:"number_of_players"` CurrentTurn int32 `json:"current_turn"` CurrentPlayerNumber sql.NullInt32 `json:"current_player_number"` StartTime time.Time `json:"start_time"` LastActionTime sql.NullTime `json:"last_action_time"` EndTime sql.NullTime `json:"end_time"` }
Represents a game session
type GameInvitation ¶
type GetGameByPlayerGameIDRow ¶
type GetGameByPlayerGameIDRow struct { GameID int64 `json:"game_id"` Status string `json:"status"` CreatedBy int64 `json:"created_by"` NumberOfPlayers int32 `json:"number_of_players"` CurrentTurn int32 `json:"current_turn"` CurrentPlayerNumber sql.NullInt32 `json:"current_player_number"` StartTime time.Time `json:"start_time"` LastActionTime sql.NullTime `json:"last_action_time"` EndTime sql.NullTime `json:"end_time"` PlayerGameID int64 `json:"player_game_id"` PlayerID int64 `json:"player_id"` GameID_2 int64 `json:"game_id_2"` PlayerNumber sql.NullInt32 `json:"player_number"` PlayerScore int32 `json:"player_score"` PlayerStatus string `json:"player_status"` }
type GetGameScoresRow ¶
type GetPlayerHandRow ¶
type IsUserGameCreatorParams ¶
type ListActiveGamesParams ¶
type ListActivePlayerGamesRow ¶
type ListActivePlayerGamesRow struct { PlayerGameID int64 `json:"player_game_id"` PlayerID int64 `json:"player_id"` GameID int64 `json:"game_id"` NumberOfPlayers int32 `json:"number_of_players"` PlayerNumber sql.NullInt32 `json:"player_number"` PlayerScore int32 `json:"player_score"` PlayerStatus string `json:"player_status"` Status string `json:"status"` CreatedBy int64 `json:"created_by"` CurrentTurn int32 `json:"current_turn"` CurrentPlayerNumber sql.NullInt32 `json:"current_player_number"` }
type ListGamePlayersParams ¶
type ListUserFriendsParams ¶
type ListUsersParams ¶
type PlayDessertTxParams ¶
type PlayedCard ¶
type PlayerGame ¶
type PlayerGame struct { PlayerGameID int64 `json:"player_game_id"` PlayerID int64 `json:"player_id"` GameID int64 `json:"game_id"` PlayerNumber sql.NullInt32 `json:"player_number"` PlayerScore int32 `json:"player_score"` PlayerStatus string `json:"player_status"` }
Associates users with their game sessions and tracks their progress
type PlayerHand ¶
type PlayerTurnAction ¶
type Querier ¶
type Querier interface { AcceptFriendRequest(ctx context.Context, arg AcceptFriendRequestParams) error AcceptGameInvitation(ctx context.Context, arg AcceptGameInvitationParams) error ActivateUser(ctx context.Context, id int64) error AddCardToPlayerHand(ctx context.Context, arg AddCardToPlayerHandParams) (int64, error) AddPlayerToGame(ctx context.Context, arg AddPlayerToGameParams) error BlockSession(ctx context.Context, id uuid.UUID) error // Checks if all actions for a turn are completed for a player CheckAllActionsCompleted(ctx context.Context, playerGameID int64) (sql.NullBool, error) // Checks if draw card action for a turn has been completed for a player CheckCardDrawn(ctx context.Context, playerGameID int64) (bool, error) // Checks if play dessert card action for a turn has been completed for a player CheckDessertPlayed(ctx context.Context, playerGameID int64) (bool, error) // Checks if play special card action for a turn has been completed for a player CheckSpecialCardPlayed(ctx context.Context, playerGameID int64) (bool, error) CreateFriendship(ctx context.Context, arg CreateFriendshipParams) (Friend, error) CreateGame(ctx context.Context, createdBy int64) (Game, error) CreateGameInvitationWithUsername(ctx context.Context, arg CreateGameInvitationWithUsernameParams) error CreatePlayerTurnActions(ctx context.Context, playerGameID int64) error CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) // Declare the winner of the game DeclareWinner(ctx context.Context, gameID int64) (DeclareWinnerRow, error) DeleteActivationToken(ctx context.Context, userID int64) error DeleteFriendship(ctx context.Context, friendshipID int64) error DeleteGameInvitation(ctx context.Context, arg DeleteGameInvitationParams) error DeleteUser(ctx context.Context, id int64) error DoesInvitationExist(ctx context.Context, arg DoesInvitationExistParams) (bool, error) DrawTopCard(ctx context.Context, gameID int64) (int64, error) EndGame(ctx context.Context, gameID int64) error GetActivationToken(ctx context.Context, activationToken string) (ActivationToken, error) // Get card by ID GetCardByID(ctx context.Context, cardID int64) (Card, error) // Get card by Name GetCardByName(ctx context.Context, name string) (Card, error) GetDessertByName(ctx context.Context, name string) (Dessert, error) GetDessertIDByName(ctx context.Context, name string) (int64, error) GetDessertsPlayedByPlayer(ctx context.Context, playerGameID int64) ([]int64, error) GetFriendshipByID(ctx context.Context, friendshipID int64) (Friend, error) GetGameByID(ctx context.Context, gameID int64) (Game, error) GetGameByPlayerGameID(ctx context.Context, playerGameID int64) (GetGameByPlayerGameIDRow, error) GetGameDeck(ctx context.Context, gameID int64) (GameDeck, error) GetGameScores(ctx context.Context, gameID int64) ([]GetGameScoresRow, error) GetPlayedCards(ctx context.Context, playerGameID int64) ([]PlayedCard, error) GetPlayerGame(ctx context.Context, playerGameID int64) (PlayerGame, error) GetPlayerHand(ctx context.Context, playerGameID int64) ([]GetPlayerHandRow, error) GetSession(ctx context.Context, id uuid.UUID) (Session, error) GetUserByEmail(ctx context.Context, email string) (User, error) GetUserByID(ctx context.Context, id int64) (User, error) GetUserByUsername(ctx context.Context, username string) (User, error) InsertActivationToken(ctx context.Context, arg InsertActivationTokenParams) (ActivationToken, error) InsertIntoGameDeck(ctx context.Context, arg InsertIntoGameDeckParams) (int64, error) IsCardInPlayerHand(ctx context.Context, arg IsCardInPlayerHandParams) (bool, error) IsDeckEmpty(ctx context.Context, gameID int64) (bool, error) // Check if a player has reached the winning condition IsGameWon(ctx context.Context, playerGameID int64) (sql.NullBool, error) IsUserGameCreator(ctx context.Context, arg IsUserGameCreatorParams) (bool, error) ListActiveGames(ctx context.Context, arg ListActiveGamesParams) ([]Game, error) ListActivePlayerGames(ctx context.Context, playerID int64) ([]ListActivePlayerGamesRow, error) // List all cards ListCardIDs(ctx context.Context) ([]int64, error) // List all cards ListCards(ctx context.Context) ([]Card, error) // List cards by type ListCardsByType(ctx context.Context, type_ string) ([]Card, error) ListGameInvitationsForUser(ctx context.Context, inviteePlayerID int64) ([]GameInvitation, error) ListGamePlayers(ctx context.Context, arg ListGamePlayersParams) ([]PlayerGame, error) ListPendingFriendRequests(ctx context.Context, friendeeID int64) ([]ListPendingFriendRequestsRow, error) ListPlayerGames(ctx context.Context, playerID int64) ([]PlayerGame, error) ListUserFriends(ctx context.Context, arg ListUserFriendsParams) ([]Friend, error) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error) RecordDessertPlayed(ctx context.Context, arg RecordDessertPlayedParams) error RecordPlayedCard(ctx context.Context, arg RecordPlayedCardParams) error RemoveCardFromDeck(ctx context.Context, arg RemoveCardFromDeckParams) error RemoveCardFromPlayerHand(ctx context.Context, arg RemoveCardFromPlayerHandParams) error // Resets the turn actions for a player after their turn ResetTurnActions(ctx context.Context, playerGameID int64) error StartGame(ctx context.Context, arg StartGameParams) error // Updates the card drawn status for a player UpdateCardDrawnStatus(ctx context.Context, playerGameID int64) error // Updates the dessert played status for a player UpdateDessertPlayedStatus(ctx context.Context, playerGameID int64) error UpdateGameState(ctx context.Context, arg UpdateGameStateParams) error UpdateGameStatus(ctx context.Context, arg UpdateGameStatusParams) error UpdatePlayerNumber(ctx context.Context, arg UpdatePlayerNumberParams) error UpdatePlayerScore(ctx context.Context, arg UpdatePlayerScoreParams) (PlayerGame, error) UpdatePlayerStatus(ctx context.Context, arg UpdatePlayerStatusParams) error // Updates the special card played status for a player UpdateSpecialCardPlayedStatus(ctx context.Context, playerGameID int64) error UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error) }
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) AcceptFriendRequest ¶
func (q *Queries) AcceptFriendRequest(ctx context.Context, arg AcceptFriendRequestParams) error
func (*Queries) AcceptGameInvitation ¶
func (q *Queries) AcceptGameInvitation(ctx context.Context, arg AcceptGameInvitationParams) error
func (*Queries) AddCardToPlayerHand ¶
func (*Queries) AddPlayerToGame ¶
func (q *Queries) AddPlayerToGame(ctx context.Context, arg AddPlayerToGameParams) error
func (*Queries) BlockSession ¶
func (*Queries) CheckAllActionsCompleted ¶
func (q *Queries) CheckAllActionsCompleted(ctx context.Context, playerGameID int64) (sql.NullBool, error)
Checks if all actions for a turn are completed for a player
func (*Queries) CheckCardDrawn ¶
Checks if draw card action for a turn has been completed for a player
func (*Queries) CheckDessertPlayed ¶
Checks if play dessert card action for a turn has been completed for a player
func (*Queries) CheckSpecialCardPlayed ¶
Checks if play special card action for a turn has been completed for a player
func (*Queries) CreateFriendship ¶
func (*Queries) CreateGame ¶
func (*Queries) CreateGameInvitationWithUsername ¶
func (q *Queries) CreateGameInvitationWithUsername(ctx context.Context, arg CreateGameInvitationWithUsernameParams) error
func (*Queries) CreatePlayerTurnActions ¶
func (*Queries) CreateSession ¶
func (*Queries) CreateUser ¶
func (*Queries) DeclareWinner ¶
Declare the winner of the game
func (*Queries) DeleteActivationToken ¶
func (*Queries) DeleteFriendship ¶
func (*Queries) DeleteGameInvitation ¶
func (q *Queries) DeleteGameInvitation(ctx context.Context, arg DeleteGameInvitationParams) error
func (*Queries) DoesInvitationExist ¶
func (*Queries) DrawTopCard ¶
func (*Queries) GetActivationToken ¶
func (*Queries) GetCardByID ¶
Get card by ID
func (*Queries) GetCardByName ¶
Get card by Name
func (*Queries) GetDessertByName ¶
func (*Queries) GetDessertIDByName ¶
func (*Queries) GetDessertsPlayedByPlayer ¶
func (*Queries) GetFriendshipByID ¶
func (*Queries) GetGameByID ¶
func (*Queries) GetGameByPlayerGameID ¶
func (*Queries) GetGameDeck ¶
func (*Queries) GetGameScores ¶
func (*Queries) GetPlayedCards ¶
func (*Queries) GetPlayerGame ¶
func (*Queries) GetPlayerHand ¶
func (*Queries) GetSession ¶
func (*Queries) GetUserByEmail ¶
func (*Queries) GetUserByID ¶
func (*Queries) GetUserByUsername ¶
func (*Queries) InsertActivationToken ¶
func (q *Queries) InsertActivationToken(ctx context.Context, arg InsertActivationTokenParams) (ActivationToken, error)
func (*Queries) InsertIntoGameDeck ¶
func (*Queries) IsCardInPlayerHand ¶
func (*Queries) IsDeckEmpty ¶
func (*Queries) IsUserGameCreator ¶
func (*Queries) ListActiveGames ¶
func (*Queries) ListActivePlayerGames ¶
func (*Queries) ListCardIDs ¶
List all cards
func (*Queries) ListCardsByType ¶
List cards by type
func (*Queries) ListGameInvitationsForUser ¶
func (*Queries) ListGamePlayers ¶
func (q *Queries) ListGamePlayers(ctx context.Context, arg ListGamePlayersParams) ([]PlayerGame, error)
func (*Queries) ListPendingFriendRequests ¶
func (*Queries) ListPlayerGames ¶
func (*Queries) ListUserFriends ¶
func (*Queries) RecordDessertPlayed ¶
func (q *Queries) RecordDessertPlayed(ctx context.Context, arg RecordDessertPlayedParams) error
func (*Queries) RecordPlayedCard ¶
func (q *Queries) RecordPlayedCard(ctx context.Context, arg RecordPlayedCardParams) error
func (*Queries) RemoveCardFromDeck ¶
func (q *Queries) RemoveCardFromDeck(ctx context.Context, arg RemoveCardFromDeckParams) error
func (*Queries) RemoveCardFromPlayerHand ¶
func (q *Queries) RemoveCardFromPlayerHand(ctx context.Context, arg RemoveCardFromPlayerHandParams) error
func (*Queries) ResetTurnActions ¶
Resets the turn actions for a player after their turn
func (*Queries) StartGame ¶
func (q *Queries) StartGame(ctx context.Context, arg StartGameParams) error
func (*Queries) UpdateCardDrawnStatus ¶
Updates the card drawn status for a player
func (*Queries) UpdateDessertPlayedStatus ¶
Updates the dessert played status for a player
func (*Queries) UpdateGameState ¶
func (q *Queries) UpdateGameState(ctx context.Context, arg UpdateGameStateParams) error
func (*Queries) UpdateGameStatus ¶
func (q *Queries) UpdateGameStatus(ctx context.Context, arg UpdateGameStatusParams) error
func (*Queries) UpdatePlayerNumber ¶
func (q *Queries) UpdatePlayerNumber(ctx context.Context, arg UpdatePlayerNumberParams) error
func (*Queries) UpdatePlayerScore ¶
func (q *Queries) UpdatePlayerScore(ctx context.Context, arg UpdatePlayerScoreParams) (PlayerGame, error)
func (*Queries) UpdatePlayerStatus ¶
func (q *Queries) UpdatePlayerStatus(ctx context.Context, arg UpdatePlayerStatusParams) error
func (*Queries) UpdateSpecialCardPlayedStatus ¶
Updates the special card played status for a player
func (*Queries) UpdateUser ¶
type RecordPlayedCardParams ¶
type RegisterTxResult ¶
type RegisterTxResult struct {
User User `json:"user"`
}
type SQLStore ¶
type SQLStore struct { *Queries // contains filtered or unexported fields }
SQLStore provides all functions to execute SQL queries and transactions
func (*SQLStore) DrawCard ¶
func (store *SQLStore) DrawCard(ctx context.Context, arg DrawCardTxParams) (DrawCardTxResult, error)
DrawCard draws the top card from the deck for a given game.
func (*SQLStore) EndTurnTx ¶
func (store *SQLStore) EndTurnTx(ctx context.Context, gameID int64, playerGameID int64) (EndTurnTxResult, error)
EndTurnTx ends the current turn and updates the game to the next turn
func (*SQLStore) InitializeDeck ¶
func (store *SQLStore) InitializeDeck(ctx context.Context, gameID int64, cardIDs []int64) (int64, error)
InitializeDeck initializes the deck for a game.
func (*SQLStore) PlayDessertTx ¶
func (store *SQLStore) PlayDessertTx(ctx context.Context, arg PlayDessertTxParams) (PlayerGame, error)
Handles the database transactions related to playing a dessert
func (*SQLStore) RefreshPlayerPantryTx ¶
func (store *SQLStore) RefreshPlayerPantryTx(ctx context.Context, playerGameID int64, cardID int64) error
RefreshPlayerHand discards the player's hand and draws the same number of new cards.
func (*SQLStore) RegisterTx ¶
func (store *SQLStore) RegisterTx(ctx context.Context, arg CreateUserParams) (RegisterTxResult, error)
RegisterTx performs a new user registration. It creates a new user only, so there is no reason to actually use this besides getting practice for now, and adding new multi-operation database transaction features later **RegisterTxResult is also rather useless for now, but will be useful when we have actual transcations occuring.
func (*SQLStore) StartGameTx ¶
func (store *SQLStore) StartGameTx(ctx context.Context, arg StartGameTxParams) (StartGameTxResult, error)
StartGameTx starts a game and initializes the deck in a transaction
func (*SQLStore) StealRandomCardFromPlayerTx ¶
type Session ¶
type Session struct { ID uuid.UUID `json:"id"` Username string `json:"username"` RefreshToken string `json:"refresh_token"` UserAgent string `json:"user_agent"` ClientIp string `json:"client_ip"` IsBlocked bool `json:"is_blocked"` ExpiresAt time.Time `json:"expires_at"` CreatedAt time.Time `json:"created_at"` }
type StartGameParams ¶
type StartGameTxParams ¶
type StartGameTxParams struct { GameID int64 `json:"game_id"` CreatedBy int64 `json:"created_by"` PlayerIDs []int64 `json:"player_ids"` CardIDs []int64 `json:"card_ids"` }
StartGameTxParams holds parameters for the StartGameTx function
type StartGameTxResult ¶
type StartGameTxResult struct {
Game Game `json:"game"`
}
StartGameTxResult holds the result for the StartGameTx function
type Store ¶
type Store interface { Querier RegisterTx(ctx context.Context, arg CreateUserParams) (RegisterTxResult, error) StartGameTx(ctx context.Context, arg StartGameTxParams) (StartGameTxResult, error) InitializeDeck(ctx context.Context, gameID int64, cardIDs []int64) (int64, error) DrawCard(ctx context.Context, arg DrawCardTxParams) (DrawCardTxResult, error) PlayDessertTx(ctx context.Context, arg PlayDessertTxParams) (PlayerGame, error) RefreshPlayerPantryTx(ctx context.Context, playerGameID int64, cardID int64) error StealRandomCardFromPlayerTx(ctx context.Context, playerGameID int64, cardID int64) (StealRandomCardFromPlayerTxResult, error) EndTurnTx(ctx context.Context, gameID int64, playerGameID int64) (EndTurnTxResult, error) }
Store provides all functions to execure db queries and transactions Uses composition and extending the functionality of queries for single db operations
type UpdateGameStateParams ¶
type UpdateGameStatusParams ¶
type UpdatePlayerScoreParams ¶
type UpdateUserParams ¶
type User ¶
type User struct { ID int64 `json:"id"` Username string `json:"username"` Email string `json:"email"` Password []byte `json:"password"` Activated bool `json:"activated"` PasswordChangedAt time.Time `json:"password_changed_at"` CreatedAt time.Time `json:"created_at"` TotalScore int32 `json:"total_score"` TotalWins int32 `json:"total_wins"` TotalLosses int32 `json:"total_losses"` }
Stores user account information