Documentation ¶
Index ¶
- Constants
- Variables
- func DropDownSymbols(scene *GameScene) error
- func GetPlayResultCurIndex(prs []*PlayResult) int
- func LoadGameConfig(fn string, cfg interface{}) error
- func PlayResult2JSON(pr *PlayResult) ([]byte, error)
- func RandWithWeights(plugin sgc7plugin.IPlugin, max int, arr []int) (int, error)
- func RemoveSymbolWithResult(scene *GameScene, result *PlayResult) error
- type BasicGame
- func (game *BasicGame) AddGameMod(gmod IGameMod) error
- func (game *BasicGame) CheckStake(stake *Stake) error
- func (game *BasicGame) FreePlugin(plugin sgc7plugin.IPlugin)
- func (game *BasicGame) GetConfig() *Config
- func (game *BasicGame) Initialize() IPlayerState
- func (game *BasicGame) NewPlayerState() IPlayerState
- func (game *BasicGame) NewPlugin() sgc7plugin.IPlugin
- func (game *BasicGame) Play(plugin sgc7plugin.IPlugin, cmd string, param string, ps IPlayerState, ...) (*PlayResult, error)
- func (game *BasicGame) SetVer(ver string)
- type BasicGameConfig
- type BasicGameMod
- func (mod *BasicGameMod) GetName() string
- func (mod *BasicGameMod) NewPlayResult(gamemodparams interface{}) *PlayResult
- func (mod *BasicGameMod) NewPlayResult2(gamemodparams interface{}, prs []*PlayResult, parentIndex int, modType string) *PlayResult
- func (mod *BasicGameMod) OnPlay(game IGame, plugin sgc7plugin.IPlugin, cmd string, param string, stake *Stake, ...) (*PlayResult, error)
- func (mod *BasicGameMod) RandomScene(game IGame, plugin sgc7plugin.IPlugin, reelsName string, gs *GameScene) (*GameScene, error)
- type BasicPlayerPrivateState
- type BasicPlayerPublicState
- type BasicPlayerState
- type Config
- func (cfg *Config) LoadLine(fn string, reels int) error
- func (cfg *Config) LoadLine3(fn string) error
- func (cfg *Config) LoadLine5(fn string) error
- func (cfg *Config) LoadLine6(fn string) error
- func (cfg *Config) LoadPayTables(fn string, reels int) error
- func (cfg *Config) LoadPayTables3(fn string) error
- func (cfg *Config) LoadPayTables5(fn string) error
- func (cfg *Config) LoadPayTables6(fn string) error
- func (cfg *Config) LoadReels(name string, fn string, reels int) error
- func (cfg *Config) LoadReels3(name string, fn string) error
- func (cfg *Config) LoadReels5(name string, fn string) error
- func (cfg *Config) LoadSymboloWeightReels(name string, fn string, reels int) error
- func (cfg *Config) SetDefaultSceneString(str string) error
- type FastReelsRandomSP
- type FuncCountSymbolExIsSymbol
- type FuncCountSymbolInReel
- type FuncForEach
- type FuncIsSameSymbol
- type FuncIsSameSymbolEx
- type FuncIsScatter
- type FuncIsSymbol
- type FuncIsValidSymbol
- type FuncIsValidSymbolEx
- type FuncIsWild
- type FuncNewBasicPlayerState
- type FuncOnSelectReelIndex
- type GameScene
- func NewGameScene(width int, height int) (*GameScene, error)
- func NewGameSceneEx(heights []int) (*GameScene, error)
- func NewGameSceneWithArr(w, h int, arr []int) (*GameScene, error)
- func NewGameSceneWithArr2(arr [][]int) (*GameScene, error)
- func NewGameSceneWithArr2Ex(arr [][]int) (*GameScene, error)
- func NewGameSceneWithReels(reels *ReelsData, w, h int, arr []int) (*GameScene, error)
- func (gs *GameScene) Clone() *GameScene
- func (gs *GameScene) CountSymbol(s int) int
- func (gs *GameScene) CountSymbolEx(issymbol FuncCountSymbolExIsSymbol) int
- func (gs *GameScene) CountSymbols(arr []int) []int
- func (gs *GameScene) Fill(reels *ReelsData, arr []int)
- func (gs *GameScene) ForEach(funcEach FuncForEach)
- func (gs *GameScene) ForEachAround(x, y int, funcEachAround FuncForEach)
- func (gs *GameScene) HasSymbol(s int) bool
- func (gs *GameScene) Init(w int, h int) error
- func (gs *GameScene) InitEx(h []int) error
- func (gs *GameScene) InitWithArr(w int, h int, arr []int) error
- func (gs *GameScene) InitWithArr2(arr [][]int) error
- func (gs *GameScene) InitWithArr2Ex(arr [][]int) error
- func (gs *GameScene) RandReels(game IGame, plugin sgc7plugin.IPlugin, reelsName string) error
- func (gs *GameScene) ResetReelIndex(game IGame, reelsName string, x int, index int) error
- type IGame
- type IGameMod
- type IPlayerState
- type LineData
- type PayTables
- type PlayResult
- type ReelsData
- type Result
- func CalcFullLine(scene *GameScene, pt *PayTables, bet int, isValidSymbolEx FuncIsValidSymbolEx, ...) []*Result
- func CalcFullLineEx(scene *GameScene, pt *PayTables, bet int, isValidSymbolEx FuncIsValidSymbolEx, ...) []*Result
- func CalcLine(scene *GameScene, pt *PayTables, ld []int, bet int, ...) *Result
- func CalcScatter(scene *GameScene, pt *PayTables, scatter int, bet int, coins int, ...) *Result
- func CalcScatterEx(scene *GameScene, scatter int, nums int, isScatter FuncIsScatter) *Result
- type ResultType
- type Stake
- type SymbolWeightReelData
- type SymbolWeightReels
- type SymbolWeightReelsData
- type SymbolWeightReelsDataSet
Constants ¶
const ( // RTScatter - scatter RTScatter = 1 // RTLine - line RTLine = 2 // RTFullLine - full line // 243线游戏,最多会出现243条记录,某些游戏必须要这种方式 RTFullLine = 3 // RTFullLineEx - full line ex // 全线游戏的汇总记录,243线最多3条记录 RTFullLineEx = 4 // RTScatterEx - scatter只计数量 RTScatterEx = 5 )
Variables ¶
var ( // ErrUnkonow - unknow error ErrUnkonow = errors.New("unknow error") // ErrInvalidReelsName - invalid reels name ErrInvalidReelsName = errors.New("invalid reels name") // ErrInvalidStake - invalid stake ErrInvalidStake = errors.New("invalid stake") // ErrDuplicateGameMod - duplicate gamemod ErrDuplicateGameMod = errors.New("duplicate gamemod") // ErrInvalidGameMod - invalid GameMod ErrInvalidGameMod = errors.New("invalid GameMod") // ErrInvalidWHGameMod - invalid Width or Height in GameMod ErrInvalidWHGameMod = errors.New("invalid Width or Height in GameMod") // ErrInvalidCommand - invalid command ErrInvalidCommand = errors.New("invalid command") // ErrInvalidBasicPlayerState - invalid BasicPlayerState ErrInvalidBasicPlayerState = errors.New("invalid BasicPlayerState") // ErrInvalidPlayerPublicState - invalid PlayerPublicState ErrInvalidPlayerPublicState = errors.New("invalid PlayerPublicState") // ErrInvalidPlayerPrivateState - invalid PlayerPrivateState ErrInvalidPlayerPrivateState = errors.New("invalid PlayerPrivateState") // ErrNonGameModCalcScene - non CalcScene in GameMod ErrNonGameModCalcScene = errors.New("non CalcScene in GameMod") // ErrNonGameModPayout - non Payout in GameMod ErrNonGameModPayout = errors.New("non Payout in GameMod") // ErrInvalidWeights - invalid weights ErrInvalidWeights = errors.New("invalid weights") // ErrNullConfig - null config ErrNullConfig = errors.New("null config") // ErrInvalidArray - invalid array ErrInvalidArray = errors.New("invalid array") // ErrInvalidSceneX - invalid scene x ErrInvalidSceneX = errors.New("invalid scene x") // ErrInvalidReels - invalid reels ErrInvalidReels = errors.New("invalid reels") // ErrInvalidSymbolWeightReelsSetType1 - invalid settype1 in SymbolWeightReels ErrInvalidSymbolWeightReelsSetType1 = errors.New("invalid settype1 in SymbolWeightReels") // ErrInvalidSymbolWeightReelsSetType2 - invalid settype2 in SymbolWeightReels ErrInvalidSymbolWeightReelsSetType2 = errors.New("invalid settype2 in SymbolWeightReels") // ErrInvalidSymbolWeightWidthReels - invalid width in SymbolWeightReels ErrInvalidSymbolWeightWidthReels = errors.New("invalid width in SymbolWeightReels") )
Functions ¶
func DropDownSymbols ¶
DropDownSymbols - drop down symbols
func GetPlayResultCurIndex ¶
func GetPlayResultCurIndex(prs []*PlayResult) int
GetPlayResultCurIndex - get current index
func LoadGameConfig ¶
LoadGameConfig - load configuration
func PlayResult2JSON ¶
func PlayResult2JSON(pr *PlayResult) ([]byte, error)
PlayResult2JSON - PlayResult => json
func RandWithWeights ¶
RandWithWeights - random with the weights
func RemoveSymbolWithResult ¶
func RemoveSymbolWithResult(scene *GameScene, result *PlayResult) error
RemoveSymbolWithResult - remove symbol with win result
Types ¶
type BasicGame ¶
type BasicGame struct { Cfg *Config MapGameMods map[string]IGameMod MgrPlugins *sgc7plugin.PluginsMgr }
BasicGame - basic game
func NewBasicGame ¶
func NewBasicGame(funcNewPlugin sgc7plugin.FuncNewPlugin) *BasicGame
NewBasicGame - new a BasicGame
func (*BasicGame) AddGameMod ¶
AddGameMod - add a gamemod
func (*BasicGame) CheckStake ¶
CheckStake - check stake
func (*BasicGame) FreePlugin ¶
func (game *BasicGame) FreePlugin(plugin sgc7plugin.IPlugin)
FreePlugin - free a plugin
func (*BasicGame) Initialize ¶
func (game *BasicGame) Initialize() IPlayerState
Initialize - initialize PlayerState
func (*BasicGame) NewPlayerState ¶
func (game *BasicGame) NewPlayerState() IPlayerState
NewPlayerState - new playerstate
func (*BasicGame) NewPlugin ¶
func (game *BasicGame) NewPlugin() sgc7plugin.IPlugin
NewPlugin - new a plugin
func (*BasicGame) Play ¶
func (game *BasicGame) Play(plugin sgc7plugin.IPlugin, cmd string, param string, ps IPlayerState, stake *Stake, prs []*PlayResult) (*PlayResult, error)
Play - play
type BasicGameConfig ¶
type BasicGameConfig struct { LineData string `yaml:"linedata"` PayTables string `yaml:"paytables"` Reels map[string]string `yaml:"reels"` }
BasicGameConfig - configuration for basic game
func (BasicGameConfig) Init5 ¶
func (bgc BasicGameConfig) Init5(ig IGame) error
Init5 - initial with 5 reels
type BasicGameMod ¶
BasicGameMod - basic gameMod
func NewBasicGameMod ¶
func NewBasicGameMod(name string, w int, h int) *BasicGameMod
NewBasicGameMod - new a BasicGameMod
func (*BasicGameMod) NewPlayResult ¶
func (mod *BasicGameMod) NewPlayResult(gamemodparams interface{}) *PlayResult
NewPlayResult - new a PlayResult
func (*BasicGameMod) NewPlayResult2 ¶
func (mod *BasicGameMod) NewPlayResult2(gamemodparams interface{}, prs []*PlayResult, parentIndex int, modType string) *PlayResult
NewPlayResult2 - new a PlayResult
func (*BasicGameMod) OnPlay ¶
func (mod *BasicGameMod) OnPlay(game IGame, plugin sgc7plugin.IPlugin, cmd string, param string, stake *Stake, prs []*PlayResult) (*PlayResult, error)
OnPlay - on play
func (*BasicGameMod) RandomScene ¶
func (mod *BasicGameMod) RandomScene(game IGame, plugin sgc7plugin.IPlugin, reelsName string, gs *GameScene) (*GameScene, error)
RandomScene - on random scene
type BasicPlayerPrivateState ¶
type BasicPlayerPrivateState struct { }
BasicPlayerPrivateState - basic PlayerPrivateState
type BasicPlayerPublicState ¶
type BasicPlayerPublicState struct { CurGameMod string `json:"curgamemod"` NextM int `json:"nextm"` }
BasicPlayerPublicState - basic PlayerPublicState
type BasicPlayerState ¶
type BasicPlayerState struct { Public *BasicPlayerPublicState Private *BasicPlayerPrivateState }
BasicPlayerState - basic PlayerState
func NewBPSNoBoostData ¶
func NewBPSNoBoostData() *BasicPlayerState
NewBPSNoBoostData - new a BasicPlayerState without boostdata
func NewBasicPlayerState ¶
func NewBasicPlayerState(curgamemod string) *BasicPlayerState
NewBasicPlayerState - new BasicPlayerState
func (*BasicPlayerState) GetPrivate ¶
func (ps *BasicPlayerState) GetPrivate() interface{}
GetPrivate - get player private state
func (*BasicPlayerState) GetPublic ¶
func (ps *BasicPlayerState) GetPublic() interface{}
GetPublic - get player public state
func (*BasicPlayerState) SetPrivate ¶
func (ps *BasicPlayerState) SetPrivate(pri interface{}) error
SetPrivate - set player private state
func (*BasicPlayerState) SetPublic ¶
func (ps *BasicPlayerState) SetPublic(pub interface{}) error
SetPublic - set player public state
type Config ¶
type Config struct { Lines *LineData `json:"lines"` Reels map[string]*ReelsData `json:"reels"` PayTables *PayTables `json:"paytables"` Width int `json:"width"` Height int `json:"height"` DefaultScene *GameScene `json:"defaultscene"` Ver string `json:"ver"` CoreVer string `json:"corever"` SWReels map[string]*SymbolWeightReels `json:"-"` }
Config - config
func (*Config) LoadPayTables ¶
LoadPayTables - load paytables for reels
func (*Config) LoadPayTables3 ¶
LoadPayTables3 - load paytables for reels 3
func (*Config) LoadPayTables5 ¶
LoadPayTables5 - load paytables for reels 5
func (*Config) LoadPayTables6 ¶
LoadPayTables6 - load paytables for reels 6
func (*Config) LoadReels3 ¶
LoadReels3 - load reels 3
func (*Config) LoadReels5 ¶
LoadReels5 - load reels 5
func (*Config) LoadSymboloWeightReels ¶
LoadSymboloWeightReels - load reels for SymbolWeightReels
func (*Config) SetDefaultSceneString ¶
SetDefaultSceneString - [][]int in json
type FastReelsRandomSP ¶
FastReelsRandomSP - fast random for a special scene, it's like scatter x 5
func NewFastReelsRandomSP ¶
func NewFastReelsRandomSP(reels *ReelsData, onSelectReelIndex FuncOnSelectReelIndex) *FastReelsRandomSP
NewFastReelsRandomSP - new a FastReelsRandomSP
func (*FastReelsRandomSP) Random ¶
func (frr *FastReelsRandomSP) Random(plugin sgc7plugin.IPlugin) ([]int, error)
Random - random
type FuncCountSymbolExIsSymbol ¶
FuncCountSymbolExIsSymbol -
type FuncCountSymbolInReel ¶
FuncCountSymbolInReel - count symbol nums in a reel
type FuncIsSameSymbol ¶
FuncIsSameSymbol - cursymbol == startsymbol
type FuncIsSameSymbolEx ¶
FuncIsSameSymbolEx - cursymbol == startsymbol
type FuncIsScatter ¶
FuncIsScatter - cursymbol == scatter
type FuncIsValidSymbol ¶
FuncIsValidSymbol - is it a valid symbol?
type FuncIsValidSymbolEx ¶
FuncIsValidSymbolEx - is it a valid symbol?
type FuncNewBasicPlayerState ¶
type FuncNewBasicPlayerState func() *BasicPlayerState
FuncNewBasicPlayerState - new BasicPlayerState and set PlayerBoostData
type FuncOnSelectReelIndex ¶
FuncOnSelectReelIndex - onSelectReelIndex
type GameScene ¶
type GameScene struct { Arr [][]int `json:"arr"` Width int `json:"-"` Height int `json:"-"` Indexes []int `json:"indexes"` ValidRow []int `json:"validrow"` HeightEx []int `json:"-"` }
GameScene - game scene
func NewGameScene ¶
NewGameScene - new a GameScene
func NewGameSceneEx ¶
NewGameSceneEx - new a GameScene
func NewGameSceneWithArr ¶
NewGameSceneWithArr - new a GameScene
func NewGameSceneWithArr2 ¶
NewGameSceneWithArr2 - new a GameScene
func NewGameSceneWithArr2Ex ¶
NewGameSceneWithArr2Ex - new a GameScene
func NewGameSceneWithReels ¶
NewGameSceneWithReels - new a GameScene
func (*GameScene) CountSymbol ¶
CountSymbol - count a symbol
func (*GameScene) CountSymbolEx ¶
func (gs *GameScene) CountSymbolEx(issymbol FuncCountSymbolExIsSymbol) int
CountSymbolEx - count a symbol
func (*GameScene) CountSymbols ¶
CountSymbols - count some symbols
func (*GameScene) ForEach ¶
func (gs *GameScene) ForEach(funcEach FuncForEach)
ForEach - for each all positions
func (*GameScene) ForEachAround ¶
func (gs *GameScene) ForEachAround(x, y int, funcEachAround FuncForEach)
ForEachAround - for each around positions
func (*GameScene) InitWithArr ¶
InitWithArr - init scene
func (*GameScene) InitWithArr2 ¶
InitWithArr2 - init scene
func (*GameScene) InitWithArr2Ex ¶
InitWithArr2Ex - init scene
type IGame ¶
type IGame interface { // NewPlugin - new a plugin NewPlugin() sgc7plugin.IPlugin // FreePlugin - free a plugin FreePlugin(plugin sgc7plugin.IPlugin) // NewPlayerState - new playerstate NewPlayerState() IPlayerState // SetVer - set server version SetVer(ver string) // GetConfig - get config GetConfig() *Config // Initialize - initialize PlayerState Initialize() IPlayerState // CheckStake - check stake CheckStake(stake *Stake) error // Play - play Play(plugin sgc7plugin.IPlugin, cmd string, param string, ps IPlayerState, stake *Stake, prs []*PlayResult) (*PlayResult, error) // AddGameMod - add a gamemod AddGameMod(gmod IGameMod) error }
IGame - game
type IGameMod ¶
type IGameMod interface { // GetName - get mode name GetName() string // OnPlay - on play OnPlay(game IGame, plugin sgc7plugin.IPlugin, cmd string, param string, stake *Stake, prs []*PlayResult) (*PlayResult, error) }
IGameMod - game
type IPlayerState ¶
type IPlayerState interface { // SetPublic - set player public state SetPublic(pub interface{}) error // SetPrivate - set player private state SetPrivate(pri interface{}) error // GetPublic - get player public state GetPublic() interface{} // GetPrivate - get player private state GetPrivate() interface{} }
IPlayerState - player state
type LineData ¶
type LineData struct {
Lines [][]int `json:"lines"`
}
LineData - line data
func LoadLine3JSON ¶
LoadLine3JSON - load json file
func LoadLine5JSON ¶
LoadLine5JSON - load json file
func LoadLine6JSON ¶
LoadLine6JSON - load json file
type PayTables ¶
PayTables - pay tables
func LoadPayTables3JSON ¶
LoadPayTables3JSON - load json file
func LoadPayTables5JSON ¶
LoadPayTables5JSON - load json file
func LoadPayTables6JSON ¶
LoadPayTables6JSON - load json file
type PlayResult ¶
type PlayResult struct { CurGameMod string `json:"curgamemod"` CurGameModParams interface{} `json:"curgamemodparams"` NextGameMod string `json:"nextgamemod"` Scenes []*GameScene `json:"scenes"` OtherScenes []*GameScene `json:"otherscenes"` PrizeScenes []*GameScene `json:"prizescenes"` PrizeCoinWin int `json:"prizecoinwin"` PrizeCashWin int64 `json:"prizecashwin"` JackpotCoinWin int `json:"jackpotcoinwin"` JackpotCashWin int64 `json:"jackpotcashwin"` JackpotType int `json:"jackpottype"` Results []*Result `json:"results"` MulPos []int `json:"mulpos"` NextCmds []string `json:"-"` NextCmdParams []string `json:"-"` CoinWin int `json:"-"` CashWin int64 `json:"-"` IsFinish bool `json:"-"` IsWait bool `json:"-"` CurIndex int `json:"-"` ParentIndex int `json:"-"` ModType string `json:"-"` }
PlayResult - result for play
func JSON2PlayResult ¶
func JSON2PlayResult(buf []byte, pr *PlayResult) (*PlayResult, error)
JSON2PlayResult - json => PlayResult
func NewPlayResult ¶
func NewPlayResult(curGameMod string, curIndex int, parentIndex int, modType string) *PlayResult
NewPlayResult - new a PlayResult
func (*PlayResult) CountEndingSymbols ¶
func (pr *PlayResult) CountEndingSymbols(symbols []int) []int
CountEndingSymbols - count symbol number
type ReelsData ¶
type ReelsData struct {
Reels [][]int `json:"reels"`
}
ReelsData - reels data
func LoadReels3JSON ¶
LoadReels3JSON - load json file
func LoadReels5JSON ¶
LoadReels5JSON - load json file
type Result ¶
type Result struct { Type ResultType `json:"type"` LineIndex int `json:"lineindex"` Symbol int `json:"symbol"` Mul int `json:"mul"` CoinWin int `json:"coinwin"` CashWin int `json:"cashwin"` Pos []int `json:"pos"` OtherMul int `json:"othermul"` Wilds int `json:"wilds"` SymbolNums int `json:"symbolnums"` }
Result - result for slots game
func CalcFullLine ¶
func CalcFullLine(scene *GameScene, pt *PayTables, bet int, isValidSymbolEx FuncIsValidSymbolEx, isWild FuncIsWild, isSameSymbol FuncIsSameSymbol) []*Result
CalcFullLine - calc fullline & no wild in reel0
还是用算线的方式来计算全线游戏,效率会低一些,数据量也会大一些,但某些特殊类型的游戏只能这样计算 也没有考虑第一轴有wild的情况(后续可调整算法)
func CalcFullLineEx ¶
func CalcFullLineEx(scene *GameScene, pt *PayTables, bet int, isValidSymbolEx FuncIsValidSymbolEx, isWild FuncIsWild, isSameSymbol FuncIsSameSymbol) []*Result
CalcFullLineEx - calc fullline & no wild in reel0
用数个数的方式来计算全线游戏,第一轴不能有wild
func CalcLine ¶
func CalcLine(scene *GameScene, pt *PayTables, ld []int, bet int, isValidSymbol FuncIsValidSymbol, isWild FuncIsWild, isSameSymbol FuncIsSameSymbol) *Result
CalcLine - calc line
func CalcScatter ¶
func CalcScatter(scene *GameScene, pt *PayTables, scatter int, bet int, coins int, isScatter FuncIsScatter) *Result
CalcScatter - calc scatter
func CalcScatterEx ¶
func CalcScatterEx(scene *GameScene, scatter int, nums int, isScatter FuncIsScatter) *Result
CalcScatterEx - calc scatter
type SymbolWeightReelData ¶
SymbolWeightReelData - symbol weight reel data
type SymbolWeightReels ¶
type SymbolWeightReels struct { Sets []*SymbolWeightReelsDataSet Width int }
SymbolWeightReels - symbol weight reels
func LoadSymbolWeightReels5JSON ¶
func LoadSymbolWeightReels5JSON(fn string) (*SymbolWeightReels, error)
LoadSymbolWeightReels5JSON - load json file
func (*SymbolWeightReels) RandomScene ¶
func (swr *SymbolWeightReels) RandomScene(gs *GameScene, plugin sgc7plugin.IPlugin, si1 int, si2 int, nocheck bool) error
RandomScene -
type SymbolWeightReelsData ¶
type SymbolWeightReelsData struct {
Reels []*SymbolWeightReelData
}
SymbolWeightReelsData - symbol weight reels data
type SymbolWeightReelsDataSet ¶
type SymbolWeightReelsDataSet struct {
Arr []*SymbolWeightReelsData
}
SymbolWeightReelsDataSet - symbol weight reels data