gamecollection

package
v0.13.140 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidGameCode - invalid gameCode
	ErrInvalidGameCode = errors.New("invalid gameCode")
	// ErrInvalidGameParams - invalid GameParams
	ErrInvalidGameParams = errors.New("invalid GameParams")
)

Functions

func AddPlayResult

func AddPlayResult(sv grpcserv.IService, pr *sgc7pb.ReplyPlay, results []*sgc7game.PlayResult)

AddPlayResult - []*sgc7game.PlayResult => *PlayResult

func Hash

func Hash(data []byte) string

func ProcCheat

func ProcCheat(plugin sgc7plugin.IPlugin, cheat string) error

ProcCheat - process cheat

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client - GameLogicCollectionClient

func NewClient

func NewClient(servAddr string) (*Client, error)

NewClient - new GameLogicClient

func (*Client) GetGameConfig

func (client *Client) GetGameConfig(ctx context.Context, gameCode string) (*sgc7pb.ReplyGameConfig, error)

GetGameConfig - get config

func (*Client) InitGame

func (client *Client) InitGame(ctx context.Context, gameCode string, data string) (*sgc7pb.ReplyInitGame, error)

InitGame - init game

func (*Client) InitializeGamePlayer

func (client *Client) InitializeGamePlayer(ctx context.Context, gameCode string) (*sgc7pb.ReplyInitializeGamePlayer, error)

InitializeGamePlayer - initialize a player

func (*Client) PlayGame

func (client *Client) PlayGame(ctx context.Context, gameCode string, ps *sgc7pb.PlayerState,
	cheat string, stake *sgc7pb.Stake, clientParams string, cmd string) (*sgc7pb.ReplyPlayGame, error)

PlayGame - play game

type GameData

type GameData struct {
	GameCode string
	HashCode string
	Data     []byte
	Game     *lowcode.Game
	Service  grpcserv.IService
}

func NewGameData

func NewGameData(gameCode string, data []byte, funcNewRNG lowcode.FuncNewRNG) (*GameData, error)

func NewGameDataWithHash

func NewGameDataWithHash(gameCode string, data []byte, hash string, funcNewRNG lowcode.FuncNewRNG) (*GameData, error)

func (*GameData) Play

func (gameD *GameData) Play(req *sgc7pb.RequestPlay) (*sgc7pb.ReplyPlay, error)

Play - play game

type GameMgr

type GameMgr struct {
	sync.Mutex
	MapGames map[string]*GameData
	// contains filtered or unexported fields
}

func NewGameMgr

func NewGameMgr(funcNewRNG lowcode.FuncNewRNG) *GameMgr

func (*GameMgr) GetGameConfig

func (mgr *GameMgr) GetGameConfig(gameCode string) (*sgc7game.Config, error)

func (*GameMgr) InitGame

func (mgr *GameMgr) InitGame(gameCode string, data []byte) error

func (*GameMgr) InitializeGamePlayer

func (mgr *GameMgr) InitializeGamePlayer(gameCode string) (*sgc7pb.PlayerState, error)

func (*GameMgr) PlayGame

func (mgr *GameMgr) PlayGame(gameCode string, req *sgc7pb.RequestPlay) (*sgc7pb.ReplyPlay, error)

PlayGame - play game

type Serv

type Serv struct {
	sgc7pb.UnimplementedGameLogicCollectionServer
	// contains filtered or unexported fields
}

Serv - Service

func NewServ

func NewServ(bindaddr string, version string, useOpenTelemetry bool, funcNewRNG lowcode.FuncNewRNG) (*Serv, error)

NewServ -

func (*Serv) GetGameConfig

func (serv *Serv) GetGameConfig(ctx context.Context, req *sgc7pb.RequestGameConfig) (*sgc7pb.ReplyGameConfig, error)

GetGameConfig - get game config

func (*Serv) InitGame

func (serv *Serv) InitGame(ctx context.Context, req *sgc7pb.RequestInitGame) (*sgc7pb.ReplyInitGame, error)

initGame - initial game

func (*Serv) InitializeGamePlayer

func (serv *Serv) InitializeGamePlayer(ctx context.Context, req *sgc7pb.RequestInitializeGamePlayer) (*sgc7pb.ReplyInitializeGamePlayer, error)

InitializeGamePlayer - initialize a player

func (*Serv) PlayGame

PlayGame - play game

func (*Serv) PlayGame2

func (serv *Serv) PlayGame2(ctx context.Context, req *sgc7pb.RequestPlayGame) (*sgc7pb.ReplyPlayGame, error)

PlayGame2 - play game

func (*Serv) Start

func (serv *Serv) Start(ctx context.Context) error

Start - start a service

func (*Serv) Stop

func (serv *Serv) Stop()

Stop - stop service

type Service

type Service struct {
	*grpcserv.BasicService2
}

Service - service

func NewService

func NewService() *Service

func (*Service) BuildPBGameModParam

func (sv *Service) BuildPBGameModParam(gp interface{}) (*any.Any, error)

BuildPBGameModParam - interface{} -> *any.Any

func (*Service) BuildPBGameModParamFromAny

func (sv *Service) BuildPBGameModParamFromAny(msg *any.Any) (interface{}, error)

BuildPBGameModParamFromAny - interface{} -> *any.Any

Jump to

Keyboard shortcuts

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