simserv

package
v0.13.177 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const BasicURL = "/game"

BasicURL - basic url

Variables

View Source
var (
	// ErrUnkonow - unknow error
	ErrUnkonow = errors.New("unknow error")

	// ErrNonStatusOK - non statusOK
	ErrNonStatusOK = errors.New("non statusOK")
)

Functions

func AddPlayResult

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

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

Types

type BasicService

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

BasicService - basic service

func NewBasicService

func NewBasicService(game sgc7game.IGame) (*BasicService, error)

NewBasicService - new a BasicService

func (*BasicService) BuildPBPlayerState

func (bs *BasicService) BuildPBPlayerState(ps sgc7game.IPlayerState) (*sgc7pb.PlayerState, error)

BuildPBPlayerState - sgc7game.IPlayerState -> *sgc7pb.PlayerState

func (*BasicService) BuildPlayerStateFromPB

func (bs *BasicService) BuildPlayerStateFromPB(ps sgc7game.IPlayerState, pspb *sgc7pb.PlayerState) error

BuildPlayerStateFromPB - *sgc7pb.PlayerState -> sgc7game.IPlayerState

func (*BasicService) GetGame

func (serv *BasicService) GetGame() sgc7game.IGame

GetGame - get game

type Client

type Client struct {
	ServURL string
}

Client - client

func NewClient

func NewClient(servurl string) *Client

NewClient - new Client, servurl is like http://127.0.0.1:7891/game/

func (*Client) GetConfig

func (client *Client) GetConfig() (*sgc7game.Config, error)

GetConfig - get configuration

func (*Client) Initialize

func (client *Client) Initialize() (*sgc7pb.PlayerState, error)

Initialize - initialize a player

func (*Client) Initialize2

func (client *Client) Initialize2() (string, error)

Initialize2 - initialize a player

func (*Client) PlayEx

func (client *Client) PlayEx(param *sgc7pb.RequestPlay) (*sgc7pb.ReplyPlay, error)

PlayEx - play with string parameter

func (*Client) PlayEx2

func (client *Client) PlayEx2(param string) (string, error)

PlayEx2 - play with string parameter

type Config

type Config struct {
	GameCode    string `yaml:"gamecode"`
	BindAddr    string `yaml:"bindaddr"`
	IsDebugMode bool   `yaml:"isdebugmode"`
	LogLevel    string `yaml:"loglevel"`
}

Config - configuration

func LoadConfig

func LoadConfig(fn string) (*Config, error)

LoadConfig - load configuration

type IService

type IService interface {
	// GetGame - get game
	GetGame() sgc7game.IGame
	// BuildPlayerStateFromPB - *sgc7pb.PlayerState -> sgc7game.IPlayerState
	BuildPlayerStateFromPB(ps sgc7game.IPlayerState, pspb *sgc7pb.PlayerState) error
	// BuildPBPlayerState - sgc7game.IPlayerState -> *sgc7pb.PlayerState
	BuildPBPlayerState(ps sgc7game.IPlayerState) (*sgc7pb.PlayerState, error)
	// BuildPBGameModParam - any -> *any.Any
	BuildPBGameModParam(gp any) (*anypb.Any, error)
	// BuildPBGameModParamFromAny - any -> *any.Any
	BuildPBGameModParamFromAny(msg *anypb.Any) (any, error)
}

IService - service

type Serv

type Serv struct {
	*sgc7http.Serv
	Service IService
	Cfg     *Config
}

Serv -

func NewServ

func NewServ(service IService, cfg *Config) *Serv

NewServ - new a serv

func (*Serv) ProcCheat

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

ProcCheat - process cheat

Jump to

Keyboard shortcuts

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