storage

package
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMoveToMemory

func AddMoveToMemory(move Move, pool *pgxpool.Pool) error

AddMoveToMemory() adds a move to the moves table

func AddNewUser

func AddNewUser(username, passwordHash string, pool *pgxpool.Pool) (uuid.UUID, error)

func DeleteGameMemory

func DeleteGameMemory(ctx context.Context, gameID string, writePool *pgxpool.Pool) error

uses a transaction to delete from both tables all at once or not at all/

func InitiateNewGame

func InitiateNewGame(playerA, playerB uuid.UUID, writePool *pgxpool.Pool) (uuid.UUID, error)

func PingPooledConnections

func PingPooledConnections(ctx context.Context, p *pooledConnections) error

check that the pools are working one at a time

func UpdateGameOutcome

func UpdateGameOutcome(gameID uuid.UUID, outcome string, pool *pgxpool.Pool) error

Types

type Game

type Game struct {
	GameID        uuid.UUID `db:"game_id"`
	PlayerAID     uuid.UUID `db:"playerA_id"`
	PlayerBID     uuid.UUID `db:"playerB_id"`
	Outcome       string    `db:"outcome"`
	GameStartTime time.Time `db:"game_start_time"`
}

func FetchOngoingGames

func FetchOngoingGames(gameID, playerID *uuid.UUID, readPool *pgxpool.Pool) ([]Game, error)

type Move

type Move struct {
	MoveID          int       `db:"move_id"`
	GameID          uuid.UUID `db:"game_id"`
	PlayerID        uuid.UUID `db:"player_id"`
	PlayerCode      string    `db:"player_code"`
	PlayerGameCode  string    `db:"player_game_code"`
	MoveDescription string    `db:"move_description"`
	MoveTime        time.Time `db:"move_time"`
	// Assuming from the latest three moves function
	MoveCounter int `db:"move_counter"`
}

func FetchAllMovesForGameID

func FetchAllMovesForGameID(gameID uuid.UUID, readPool *pgxpool.Pool) ([]Move, error)

func FetchLatestThreeMovesInGame

func FetchLatestThreeMovesInGame(gameID uuid.UUID, readPool *pgxpool.Pool) ([]Move, error)

func FetchParticularPlayersMoves

func FetchParticularPlayersMoves(playerGameCode uuid.UUID, readPool *pgxpool.Pool) ([]Move, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL