network

package
v0.0.0-...-83cae81 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertFromGetGameResponse

func ConvertFromGetGameResponse(g GetGameResponse) model.Game

func ModelCardsFromStrings

func ModelCardsFromStrings(cs ...string) []model.Card

Types

type ActiveGame

type ActiveGame struct {
	GameID  model.GameID       `json:"gameID"`
	Players []ActiveGamePlayer `json:"players"`

	Created  string `json:"created"`
	LastMove string `json:"lastMove"`
}

type ActiveGamePlayer

type ActiveGamePlayer struct {
	ID    model.PlayerID `json:"id"`
	Name  string         `json:"name"`
	Color string         `json:"color"`
}

type Card

type Card struct {
	Suit  string `json:"suit"`
	Value int    `json:"value"`
	Name  string `json:"name"`
}

type CreateGameRequest

type CreateGameRequest struct {
	PlayerIDs []model.PlayerID `json:"playerIDs"`
}

type CreateGameResponse

type CreateGameResponse struct {
	ID              model.GameID              `json:"id"`
	Players         []Player                  `json:"players"`
	PlayerColors    map[model.PlayerID]string `json:"player_colors,omitempty"`
	BlockingPlayers map[model.PlayerID]string `json:"blocking_players,omitempty"`
	CurrentDealer   model.PlayerID            `json:"current_dealer"`
}

func ConvertToCreateGameResponse

func ConvertToCreateGameResponse(g model.Game) CreateGameResponse

type CreateInteractionRequest

type CreateInteractionRequest struct {
	PlayerID      model.PlayerID `json:"playerID"`
	LocalhostPort string         `json:"localhost_port,omitempty"`
	NPCType       model.PlayerID `json:"npc_type,omitempty"`
}

type CreatePlayerRequest

type CreatePlayerRequest struct {
	Player Player `json:"player"`
}

type CreatePlayerResponse

type CreatePlayerResponse struct {
	Player Player `json:"player"`
}

func ConvertToCreatePlayerResponse

func ConvertToCreatePlayerResponse(pm model.Player) CreatePlayerResponse

type GetActiveGamesForPlayerResponse

type GetActiveGamesForPlayerResponse struct {
	Player      Player       `json:"player"`
	ActiveGames []ActiveGame `json:"activeGames"`
}

func ConvertToGetActiveGamesForPlayerResponse

func ConvertToGetActiveGamesForPlayerResponse(
	p model.Player,
	games map[model.GameID]model.Game,
) GetActiveGamesForPlayerResponse

type GetGameResponse

type GetGameResponse struct {
	ID              model.GameID              `json:"id"`
	Teams           []GetGameResponseTeam     `json:"teams"`
	Phase           string                    `json:"phase"`
	CurrentPeg      int                       `json:"current_peg"`
	BlockingPlayers map[model.PlayerID]string `json:"blocking_players,omitempty"`
	CurrentDealer   model.PlayerID            `json:"current_dealer"`
	Hands           map[model.PlayerID][]Card `json:"hands,omitempty"`
	Crib            []Card                    `json:"crib,omitempty"`
	CutCard         Card                      `json:"cut_card"`
	PeggedCards     []PeggedCard              `json:"pegged_cards,omitempty"`
}

func ConvertToGetGameResponse

func ConvertToGetGameResponse(g model.Game) GetGameResponse

func ConvertToGetGameResponseForPlayer

func ConvertToGetGameResponseForPlayer(g model.Game, pID model.PlayerID) (GetGameResponse, error)

type GetGameResponseTeam

type GetGameResponseTeam struct {
	Players      []Player `json:"players"`
	Color        string   `json:"color,omitempty"`
	CurrentScore int      `json:"current_score"`
	LagScore     int      `json:"lag_score"`
}

type GetPlayerResponse

type GetPlayerResponse struct {
	Player Player `json:"player"`
}

func ConvertToGetPlayerResponse

func ConvertToGetPlayerResponse(p model.Player) GetPlayerResponse

type GetSuggestHandResponse

type GetSuggestHandResponse struct {
	Hand    []string   `json:"hand"`
	Toss    []string   `json:"toss"`
	HandPts PointStats `json:"handPts"`
	CribPts PointStats `json:"cribPts"`
}

func ConvertToGetSuggestHandResponse

func ConvertToGetSuggestHandResponse(
	summaries []model.TossSummary,
) []GetSuggestHandResponse

type PeggedCard

type PeggedCard struct {
	Card   Card           `json:"card"`
	Player model.PlayerID `json:"player"`
}

type Player

type Player struct {
	ID   model.PlayerID `json:"id"`
	Name string         `json:"name"`
}

type PointStats

type PointStats struct {
	Min    int     `json:"min"`
	Median float64 `json:"median"`
	Avg    float64 `json:"avg"`
	Max    int     `json:"max"`
}

Jump to

Keyboard shortcuts

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