Documentation ¶
Index ¶
- func EmitEvent(event Event)
- func StartEventDispatcher(handleEvent func(Event))
- type CardDrawnData
- type DessertPlayedData
- type DrawCardHandlerParams
- type EndGameData
- type EndTurnData
- type Event
- type EventType
- type GameService
- func (s *GameService) DrawCardHandler(ctx context.Context, arg DrawCardHandlerParams) error
- func (s *GameService) EndGameHandler(ctx context.Context, gameID int64, playerGameID int64) error
- func (s *GameService) EndTurnHandler(ctx context.Context, gameID int64, playerGameID int64) error
- func (s *GameService) PlayDessertHandler(ctx context.Context, arg PlayDessertHandlerParams) error
- func (s *GameService) UpdateScoresForAllPlayers(ctx context.Context, gameID int64) error
- type PlayDessertHandlerParams
- type ScoreUpdateData
- type SpecialCardPlayedData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartEventDispatcher ¶
func StartEventDispatcher(handleEvent func(Event))
Types ¶
type CardDrawnData ¶
type CardDrawnData struct { CardID int64 `json:"card_id"` CardName string `json:"name"` PlayerGameID int64 `json:"player_game_id"` PlayerHandID int64 `json:"player_hand_id"` GameID int64 `json:"game_id"` }
CardDrawnData carries data for a card drawn event
type DessertPlayedData ¶
type DessertPlayedData struct { GameID int64 `json:"game_id"` PlayerGameID int64 `json:"player_game_id"` PlayerNumber int32 `json:"player_number"` DessertName string `json:"dessert_name"` DessertScore int32 `json:"dessert_score"` Score int32 `json:"score"` GameOver bool `json:"game_over"` Success bool `json:"success"` }
DessertPlayedData carries data for a dessert played event
type DrawCardHandlerParams ¶
type EndGameData ¶
type EndGameData struct { GameID int64 `json:"game_id"` Status string `json:"status"` WinningPlayerGameID int64 `json:"winner_player_game_id"` WinningPlayerNumber int32 `json:"winner_player_number"` WinningScore int32 `json:"winning_score"` }
EndGameData carries data for an end game event
type EndTurnData ¶
type EndTurnData 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 int32 `json:"current_player_number"` }
EndTurnData carries data for an end turn event
type GameService ¶
type GameService struct {
// contains filtered or unexported fields
}
func NewGameService ¶
func NewGameService(store db.Store) *GameService
NewGameService creates a new instance of GameService with the provided store
func (*GameService) DrawCardHandler ¶
func (s *GameService) DrawCardHandler(ctx context.Context, arg DrawCardHandlerParams) error
Handles the coordination of services when a player draws a card
func (*GameService) EndGameHandler ¶
Handles the coordination of services the game is over
func (*GameService) EndTurnHandler ¶
Handles the coordination of services when a player's turn is over
func (*GameService) PlayDessertHandler ¶
func (s *GameService) PlayDessertHandler(ctx context.Context, arg PlayDessertHandlerParams) error
Handles the coordination of services when a player play's a dessert
func (*GameService) UpdateScoresForAllPlayers ¶
func (s *GameService) UpdateScoresForAllPlayers(ctx context.Context, gameID int64) error
type ScoreUpdateData ¶
type ScoreUpdateData struct { PlayerGameID int64 `json:"player_game_id"` PlayerID int64 `json:"player_id"` GameID int64 `json:"game_id"` PlayerNumber int32 `json:"player_number"` PlayerScore int32 `json:"player_score"` PlayerStatus string `json:"player_status"` }
ScoreUpdateData carries data for a score update event
type SpecialCardPlayedData ¶
type SpecialCardPlayedData struct { }
SpecialCardPlayedData carries data for a special card played event