gatiserv

package
v0.13.52 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BasicURL = "/v2/games/"

BasicURL - basic url

Variables

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

	// ErrInvalidPlayerState - invalid PlayerState
	ErrInvalidPlayerState = errors.New("invalid PlayerState")

	// ErrInvalidCriticalComponentID - invalid CriticalComponentID
	ErrInvalidCriticalComponentID = errors.New("invalid CriticalComponentID")

	// ErrInvalidObjectiveID - invalid ObjectiveID
	ErrInvalidObjectiveID = errors.New("invalid ObjectiveID")

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

Functions

func AddPlayResult

func AddPlayResult(pr *PlayResult, stake Stake, results []*sgc7game.PlayResult)

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

func AddWinResult

func AddWinResult(pr *PlayResult, stake Stake, playResult *sgc7game.PlayResult) error

AddWinResult - add sgc7game.PlayResult

func BuildIPlayerState

func BuildIPlayerState(ips sgc7game.IPlayerState, ps *PlayerState) error

BuildIPlayerState - PlayerState => sgc7game.IPlayerState

func BuildPlayerStateString

func BuildPlayerStateString(ps sgc7game.IPlayerState) (string, error)

BuildPlayerStateString - sgc7game.IPlayerState => string

func BuildStake

func BuildStake(stake Stake) *sgc7game.Stake

BuildStake - PlayerState => sgc7game.IPlayerState

func Checksum

func Checksum(fn string) (string, error)

Checksum - it's like sha1sum fn

func ParsePlayerState

func ParsePlayerState(str string, ps *PlayerState) error

ParsePlayerState - json => PlayerState

func SaveGATIGameInfo

func SaveGATIGameInfo(gi *GATIGameInfo, fn string) error

SaveGATIGameInfo - save

Types

type AnalyticEvent

type AnalyticEvent struct {
	EventID string `json:"eventId"`
	Data    string `json:"data"`
}

AnalyticEvent - analytic event

type AnalyticsData

type AnalyticsData struct {
	GameEvents   []AnalyticEvent `json:"gameEvents"`
	ResultEvents []ResultEvent   `json:"resultEvents"`
}

AnalyticsData - analytics data

type BasicMissionBoostData

type BasicMissionBoostData struct {
	ObjectiveID string `json:"objectiveId"`
	Counter     int    `json:"counter"`
	Arr         []int  `json:"arr"`
	Type        int    `json:"type"` // 0 - counter, 1 - arr
}

BasicMissionBoostData -

type BasicMissionBoostDataMap

type BasicMissionBoostDataMap struct {
	MapBoostData map[string]*BasicMissionBoostData `json:"mapboostdata"`
}

BasicMissionBoostDataMap -

type BasicMissionState

type BasicMissionState struct {
	ObjectiveID string `json:"objectiveId"`
	Goal        int    `json:"goal"`
	Current     int    `json:"current"`
	Arr         []int  `json:"arr"`
}

BasicMissionState -

type BasicMissionStateMap

type BasicMissionStateMap struct {
	MapState map[string]*BasicMissionState `json:"mapstate"`
}

BasicMissionStateMap -

type BasicService

type BasicService struct {
	Game       sgc7game.IGame
	GameInfo   *GATIGameInfo
	GameConfig *GATIGameConfig
}

BasicService - basic service

func NewBasicService

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

NewBasicService - new a BasicService

func (*BasicService) Checksum

func (sv *BasicService) Checksum(lst []*CriticalComponent) ([]*ComponentChecksum, error)

Checksum - checksum

func (*BasicService) Config

func (sv *BasicService) Config() *sgc7game.Config

Config - get configuration

func (*BasicService) Evaluate

func (sv *BasicService) Evaluate(params *EvaluateParams, id string) (*EvaluateResult, error)

Evaluate -

func (*BasicService) GetGameConfig

func (sv *BasicService) GetGameConfig() *GATIGameConfig

GetGameConfig - get GATIGameConfig

func (*BasicService) Initialize

func (sv *BasicService) Initialize() *PlayerState

Initialize - initialize a player

func (*BasicService) OnPlayBoostData

func (sv *BasicService) OnPlayBoostData(params *PlayParams, result *PlayResult) error

OnPlayBoostData - after call Play

func (*BasicService) Play

func (sv *BasicService) Play(params *PlayParams) (*PlayResult, error)

Play - play game

func (*BasicService) ProcCheat

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

ProcCheat - process cheat

func (*BasicService) Validate

func (sv *BasicService) Validate(params *ValidateParams) []ValidationError

Validate - validate game

func (*BasicService) Version

func (sv *BasicService) Version() *VersionInfo

Version - version

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/v2/games/1019/

func (*Client) Checksum

func (client *Client) Checksum(arr []*CriticalComponent) ([]*ComponentChecksum, error)

Checksum - checksum

func (*Client) GetConfig

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

GetConfig - get configuration

func (*Client) Initialize

func (client *Client) Initialize(ps *PlayerState) error

Initialize - initialize a player

func (*Client) PlayEx

func (client *Client) PlayEx(param string) (*PlayResult, error)

PlayEx - play with string parameter

type ComponentChecksum

type ComponentChecksum struct {
	ID       int    `json:"id"`
	Checksum string `json:"checksum"`
}

ComponentChecksum -

type Config

type Config struct {
	GameID      string
	BindAddr    string
	IsDebugMode bool
}

Config - configuration

type CriticalComponent

type CriticalComponent struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Location string `json:"location"`
}

CriticalComponent -

type EvaluateParams

type EvaluateParams struct {
	BoostData []*BasicMissionBoostDataMap `json:"boostData"`
	State     *BasicMissionStateMap       `json:"state"`
}

EvaluateParams -

type EvaluateResult

type EvaluateResult struct {
	Progress int                   `json:"progress"`
	State    *BasicMissionStateMap `json:"state"`
}

EvaluateResult -

type GATICriticalComponent

type GATICriticalComponent struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Location string `json:"location"`
	Filename string `json:"filename"`
	Checksum string `json:"checksum"`
}

GATICriticalComponent -

type GATICriticalComponents

type GATICriticalComponents struct {
	Components map[int]*GATICriticalComponent `json:"components"`
}

GATICriticalComponents -

func GenChecksum

func GenChecksum(lst []*GATICriticalComponent) (*GATICriticalComponents, error)

GenChecksum -

type GATIGameConfig

type GATIGameConfig struct {
	GameObjectives []*MissionObject `json:"gameObjectives"`
}

GATIGameConfig - game_configuration.json

func LoadGATIGameConfig

func LoadGATIGameConfig(fn string) (*GATIGameConfig, error)

LoadGATIGameConfig - load

type GATIGameInfo

type GATIGameInfo struct {
	Components map[int]*GATICriticalComponent `json:"components"`
	Info       VersionInfo                    `json:"info"`
}

GATIGameInfo - GATIGameInfo

func LoadGATIGameInfo

func LoadGATIGameInfo(fn string) (*GATIGameInfo, error)

LoadGATIGameInfo - load

func NewGATIGameInfo

func NewGATIGameInfo() *GATIGameInfo

NewGATIGameInfo -

func (*GATIGameInfo) FindComponentChecksum

func (gatiGI *GATIGameInfo) FindComponentChecksum(cc *CriticalComponent) *ComponentChecksum

Checksum - checksum

type IService

type IService interface {
	// Config - get configuration
	Config() *sgc7game.Config
	// Initialize - initialize a player
	Initialize() *PlayerState
	// Validate - validate game
	Validate(params *ValidateParams) []ValidationError
	// Play - play game
	Play(params *PlayParams) (*PlayResult, error)
	// Checksum - checksum
	Checksum(lst []*CriticalComponent) ([]*ComponentChecksum, error)
	// Version - version
	Version() *VersionInfo
	// OnPlayBoostData - after call Play
	OnPlayBoostData(params *PlayParams, result *PlayResult) error
	// GetGameConfig - get GATIGameConfig
	GetGameConfig() *GATIGameConfig
	// Evaluate -
	Evaluate(params *EvaluateParams, id string) (*EvaluateResult, error)
}

IService - service

type Jackpot

type Jackpot struct {
	Value float64 `json:"value"`
}

Jackpot - jackpot

type MissionObject

type MissionObject struct {
	ObjectiveID string `json:"objectiveId"`
	Description string `json:"description"`
	Goal        int    `json:"goal"`
	Period      int    `json:"period"`
}

MissionObject -

type PlayParams

type PlayParams struct {
	PlayerState       *PlayerState       `json:"playerState"`
	Cheat             string             `json:"cheat"`
	Stake             Stake              `json:"stakeValue"`
	Params            string             `json:"clientParams"`
	Cmd               string             `json:"command"`
	JackpotStakeValue float64            `json:"jackpotStakeValue"`
	FreespinsActive   bool               `json:"freespinsActive"`
	JackpotValues     map[string]Jackpot `json:"jackpotValues"`
}

PlayParams - play input parameters for the game

func ParsePlayParams

func ParsePlayParams(str string, ps *PlayerState) (*PlayParams, error)

ParsePlayParams - string => *PlayParams

type PlayResult

type PlayResult struct {
	RandomNumbers []*sgc7utils.RngInfo      `json:"randomNumbers"`
	PlayerState   *PlayerState              `json:"playerState"`
	JackpotData   []string                  `json:"jackpotData"`
	Finished      bool                      `json:"finished"`
	Results       []*Result                 `json:"results"`
	NextCommands  []string                  `json:"nextCommands"`
	AnalyticsData *AnalyticsData            `json:"analyticsData"`
	BoostData     *BasicMissionBoostDataMap `json:"boostData"`
}

PlayResult - play output parameters for the game

func ParsePlayResult

func ParsePlayResult(str string) (*PlayResult, error)

ParsePlayResult - string => *PlayResult

type PlayerState

type PlayerState struct {
	Public  any `json:"playerStatePublic"`
	Private any `json:"playerStatePrivate"`
}

PlayerState - player state

func BuildPlayerState

func BuildPlayerState(ips sgc7game.IPlayerState) (*PlayerState, error)

BuildPlayerState - sgc7game.IPlayerState => PlayerState

type Result

type Result struct {
	CoinWin    int                  `json:"coinWin"`
	CashWin    float64              `json:"cashWin"`
	ClientData *sgc7game.PlayResult `json:"clientData"`
}

Result - game result

type ResultEvent

type ResultEvent struct {
	ResultIndex int             `json:"resultIndex"`
	Events      []AnalyticEvent `json:"events"`
}

ResultEvent - result event

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) RegMission

func (serv *Serv) RegMission(id string)

RegMission -

type Stake

type Stake struct {
	CoinBet  float64 `json:"coinBet"`
	CashBet  float64 `json:"cashBet"`
	Currency string  `json:"currency"`
}

Stake - stake

type ValidateParams

type ValidateParams struct {
	PlayerState PlayerState `json:"playerState"`
	Stake       Stake       `json:"stakeValue"`
	Params      string      `json:"clientParams"`
	Cmd         string      `json:"command"`
}

ValidateParams - validate input parameters for the game

type ValidationError

type ValidationError struct {
	ErrorCode int    `json:"errorCode"`
	Reason    string `json:"reason"`
	Data      string `json:"data"`
}

ValidationError - validate error

type VersionInfo

type VersionInfo struct {
	GameTitle     string `json:"gameTitle"`
	GameVersion   string `json:"gameVersion"`
	VCSVersion    string `json:"vcsVersion"`
	BuildChecksum string `json:"buildChecksum"`
	BuildTime     string `json:"buildTime"`
	Vendor        string `json:"vendor"`
}

VersionInfo -

Jump to

Keyboard shortcuts

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