game

package
v0.0.0-...-5c7a00c Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Games = make(map[string]Data)

Games hold the running games

Functions

func CreateGame

func CreateGame(db *sql.DB, h *ws.Hub) http.HandlerFunc

CreateGame will dispatch the creation of a game to the corresponding game creation handler after adding it to the in memory games map

func DeleteGame

func DeleteGame(h *ws.Hub) http.HandlerFunc

DeleteGame will delete game from in memory map

func GetAllGames

func GetAllGames() http.HandlerFunc

GetAllGames lists all in memory games

func GetSpecificGame

func GetSpecificGame() http.HandlerFunc

GetSpecificGame lists a specific in memory game

func GetSpecificGameDisplay

func GetSpecificGameDisplay() http.HandlerFunc

GetSpecificGameDisplay lists a specific in memory game and only provides the data necessary to display the Scoreboard information (small data size)

func InsertThrow

func InsertThrow(h *ws.Hub) http.HandlerFunc

InsertThrow will handle to add a throw to a game

func NextPlayer

func NextPlayer(h *ws.Hub) http.HandlerFunc

NextPlayer will switch to next player in game

func Rematch

func Rematch(h *ws.Hub) http.HandlerFunc

Rematch will handle the rematch action per game

func Undo

func Undo(h *ws.Hub) http.HandlerFunc

Undo will handle the undo actions per game

func UndoATCIncreaseNumber

func UndoATCIncreaseNumber(action undo.Action)

UndoATCIncreaseNumber is the undo action for ATCINCREASENUMBER

func UndoBustAndWin

func UndoBustAndWin(action undo.Action, base *BaseGame)

UndoBustAndWin is the undo action for X01BUST and DOWIN

func UndoCloseControllerNumber

func UndoCloseControllerNumber(action undo.Action, base *BaseGame)

UndoCloseControllerNumber is the undo action for CLOSECONTROLLERNUMBER

func UndoClosePlayerNumber

func UndoClosePlayerNumber(action undo.Action)

UndoClosePlayerNumber is the undo action for CLOSEPLAYERNUMBER

func UndoClosePlayerThrowRound

func UndoClosePlayerThrowRound(action undo.Action, base *BaseGame)

UndoClosePlayerThrowRound is the undo action for CLOSEPLAYERTHROWROUND

func UndoCreateThrow

func UndoCreateThrow(action undo.Action)

UndoCreateThrow is the undo action for CREATETHROW

func UndoCreateThrowRound

func UndoCreateThrowRound(action undo.Action)

UndoCreateThrowRound is the undo action for CREATETHROWROUND

func UndoDoPodium

func UndoDoPodium(action undo.Action, base *BaseGame)

UndoDoPodium is the undo action for DOPODIUM

func UndoGainPoints

func UndoGainPoints(action undo.Action)

UndoGainPoints is the undo action for GAINPOINTS

func UndoIncreaseHitCount

func UndoIncreaseHitCount(action undo.Action)

UndoIncreaseHitCount is the undo action for INCREASEHITCOUNT

func UndoIncreaseThrowRound

func UndoIncreaseThrowRound(action undo.Action, base *BaseGame)

UndoIncreaseThrowRound is the undo action for INCREASETHROWROUND

func UndoNextPlayer

func UndoNextPlayer(action undo.Action, base *BaseGame)

UndoNextPlayer is the undo action for NEXTPLAYER

func UndoRevealNumber

func UndoRevealNumber(action undo.Action, base *BaseGame)

UndoRevealNumber is the undo action for REVEALNUMBER

func UndoScore

func UndoScore(action undo.Action)

UndoScore is the undo action for UPDATESCORE

func UndoScoreAndPark

func UndoScoreAndPark(action undo.Action)

UndoScoreAndPark is the undo action for UPDATESCOREANDPARK

func UndoUpdateSplitScore

func UndoUpdateSplitScore(action undo.Action)

UndoUpdateSplitScore is the undo action for UPDATESPLITSCORE

func UndoWin

func UndoWin(action undo.Action, base *BaseGame)

UndoWin is the undo action for DOWIN

Types

type ATCGame

type ATCGame struct {
	Base BaseGame
}

ATCGame will hold the ATC game information

func (*ATCGame) GetStatus

func (g *ATCGame) GetStatus() BaseGame

GetStatus will satisfy interface Game for ATC

func (*ATCGame) GetStatusDisplay

func (g *ATCGame) GetStatusDisplay() BaseGame

GetStatusDisplay will satisfy interface Game for game ATC

func (*ATCGame) NextPlayer

func (g *ATCGame) NextPlayer(h *ws.Hub)

NextPlayer will satisfy interface Game for game ATC

func (*ATCGame) Rematch

func (g *ATCGame) Rematch(h *ws.Hub) error

Rematch will satisfy interface Game for game ATC

func (*ATCGame) RequestThrow

func (g *ATCGame) RequestThrow(number, modifier int, h *ws.Hub) error

RequestThrow will satisfy inteface Game for ATC

func (*ATCGame) StartGame

func (g *ATCGame) StartGame() error

StartGame will satisfy interface Game for ATC

func (*ATCGame) Undo

func (g *ATCGame) Undo(h *ws.Hub) error

Undo will satisfy interface Game for game ATC

type BaseGame

type BaseGame struct {
	UID               string
	Game              string
	Player            []player.Player
	Variant           string
	In                string
	Out               string
	ActivePlayer      int
	ThrowRound        int
	GameState         string
	Message           string
	Settings          *settings.Settings
	UndoLog           *undo.Log
	Podium            *podium.Podium
	CricketController *CricketGameController
	SoundToPlay       string
}

BaseGame will hold all the game specific stuff for all games combined

type CricketGame

type CricketGame struct {
	Base BaseGame
}

CricketGame will hold the Cricket game information

func (*CricketGame) GetStatus

func (g *CricketGame) GetStatus() BaseGame

GetStatus will satisfy interface Game for game Cricket

func (*CricketGame) GetStatusDisplay

func (g *CricketGame) GetStatusDisplay() BaseGame

GetStatusDisplay will satisfy interface Game for game Cricket

func (*CricketGame) NextPlayer

func (g *CricketGame) NextPlayer(h *ws.Hub)

NextPlayer will satisfy interface Game for game Cricket

func (*CricketGame) Rematch

func (g *CricketGame) Rematch(h *ws.Hub) error

Rematch will satisfy interface Game for game Cricket

func (*CricketGame) RequestThrow

func (g *CricketGame) RequestThrow(number, modifier int, h *ws.Hub) error

RequestThrow will satisfy interface Game for game Cricket

func (*CricketGame) StartGame

func (g *CricketGame) StartGame() error

StartGame will satisfy interface Game for game Cricket

func (*CricketGame) Undo

func (g *CricketGame) Undo(h *ws.Hub) error

Undo will satisfy interface Game for game Cricket

type CricketGameController

type CricketGameController struct {
	NumberClosed   []bool
	Numbers        []int
	NumberRevealed []bool // For Ghost Cricket
	Random         bool
	Ghost          bool
}

CricketGameController will hold the status of different numbers This will hold information if the number is closed in game and can be hit or not Also it maps the 7 numbers to actual dart values Classic is 15-20 + 25 Otherwise random or ghost can be used

type Data

type Data struct {
	UID           string `json:"uid"`
	Player        []int  `json:"player"`
	Game          string `json:"game"`
	Variant       string `json:"variant"`
	In            string `json:"in"`
	Out           string `json:"out"`
	Punisher      bool   `json:"punisher"`
	Sound         bool   `json:"sound"`
	Podium        bool   `json:"podium"`
	AutoSwitch    bool   `json:"autoswitch"`
	CricketRandom bool   `json:"cricketrandom"`
	CricketGhost  bool   `json:"cricketghost"`
	GameObject    Game
}

Data stuct will hold the generic game data handed over by the frontend. It might be used in the different game types

type EliminiationGame

type EliminiationGame struct {
	Base BaseGame
}

EliminiationGame will hold the Eliminiation game information

func (*EliminiationGame) GetStatus

func (g *EliminiationGame) GetStatus() BaseGame

GetStatus will satisfy interface Game for game Eliminiation

func (*EliminiationGame) GetStatusDisplay

func (g *EliminiationGame) GetStatusDisplay() BaseGame

GetStatusDisplay will satisfy interface Game for game Eliminiation

func (*EliminiationGame) NextPlayer

func (g *EliminiationGame) NextPlayer(h *ws.Hub)

NextPlayer will satisfy interface Game for game Eliminiation

func (*EliminiationGame) Rematch

func (g *EliminiationGame) Rematch(h *ws.Hub) error

Rematch will satisfy interface Game for game Eliminiation

func (*EliminiationGame) RequestThrow

func (g *EliminiationGame) RequestThrow(number, modifier int, h *ws.Hub) error

RequestThrow will satisfy interface Game for game Eliminiation

func (*EliminiationGame) StartGame

func (g *EliminiationGame) StartGame() error

StartGame will satisfy interface Game for game Eliminiation

func (*EliminiationGame) Undo

func (g *EliminiationGame) Undo(h *ws.Hub) error

Undo will satisfy interface Game for game Eliminiation

type Game

type Game interface {
	StartGame() error
	GetStatus() BaseGame
	GetStatusDisplay() BaseGame
	NextPlayer(h *ws.Hub)
	RequestThrow(number, modifier int, h *ws.Hub) error
	Undo(h *ws.Hub) error
	Rematch(h *ws.Hub) error
}

Game will be the interface for different games

type ShanghaiGame

type ShanghaiGame struct {
	Base BaseGame
}

ShanghaiGame will hold the Shanghai game information

func (*ShanghaiGame) GetStatus

func (g *ShanghaiGame) GetStatus() BaseGame

GetStatus will satisfy interface Game for Shanghai

func (*ShanghaiGame) GetStatusDisplay

func (g *ShanghaiGame) GetStatusDisplay() BaseGame

GetStatusDisplay will satisfy interface Game for game Shanghai

func (*ShanghaiGame) NextPlayer

func (g *ShanghaiGame) NextPlayer(h *ws.Hub)

NextPlayer will satisfy interface Game for game Shanghai

func (*ShanghaiGame) Rematch

func (g *ShanghaiGame) Rematch(h *ws.Hub) error

Rematch will satisfy interface Game for game Shanghai

func (*ShanghaiGame) RequestThrow

func (g *ShanghaiGame) RequestThrow(number, modifier int, h *ws.Hub) error

RequestThrow will satisfy inteface Game for Shanghai

func (*ShanghaiGame) StartGame

func (g *ShanghaiGame) StartGame() error

StartGame will satisfy interface Game for Shanghai

func (*ShanghaiGame) Undo

func (g *ShanghaiGame) Undo(h *ws.Hub) error

Undo will satisfy interface Game for game Shanghai

type SplitGame

type SplitGame struct {
	Base BaseGame
}

SplitGame will hold the Split game information

func (*SplitGame) GetStatus

func (g *SplitGame) GetStatus() BaseGame

GetStatus will satisfy interface Game for game Split

func (*SplitGame) GetStatusDisplay

func (g *SplitGame) GetStatusDisplay() BaseGame

GetStatusDisplay will satisfy interface Game for game Split

func (*SplitGame) NextPlayer

func (g *SplitGame) NextPlayer(h *ws.Hub)

NextPlayer will satisfy interface Game for game Split

func (*SplitGame) Rematch

func (g *SplitGame) Rematch(h *ws.Hub) error

Rematch will satisfy interface Game for game Split

func (*SplitGame) RequestThrow

func (g *SplitGame) RequestThrow(number, modifier int, h *ws.Hub) error

RequestThrow will satisfy interface Game for game Split

func (*SplitGame) StartGame

func (g *SplitGame) StartGame() error

StartGame will satisfy interface Game for game Split

func (*SplitGame) Undo

func (g *SplitGame) Undo(h *ws.Hub) error

Undo will satisfy interface Game for game Split

type X01Game

type X01Game struct {
	Base BaseGame
}

X01Game will hold the X01 game information

func (*X01Game) GetStatus

func (g *X01Game) GetStatus() BaseGame

GetStatus will satisfy interface Game for game X01

func (*X01Game) GetStatusDisplay

func (g *X01Game) GetStatusDisplay() BaseGame

GetStatusDisplay will satisfy interface Game for game X01

func (*X01Game) NextPlayer

func (g *X01Game) NextPlayer(h *ws.Hub)

NextPlayer will satisfy interface Game for game X01

func (*X01Game) Rematch

func (g *X01Game) Rematch(h *ws.Hub) error

Rematch will satisfy interface Game for game X01

func (*X01Game) RequestThrow

func (g *X01Game) RequestThrow(number, modifier int, h *ws.Hub) error

RequestThrow will satisfy interface Game for game X01

func (*X01Game) StartGame

func (g *X01Game) StartGame() error

StartGame will satisfy interface Game for game X01

func (*X01Game) Undo

func (g *X01Game) Undo(h *ws.Hub) error

Undo will satisfy interface Game for game X01

Jump to

Keyboard shortcuts

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