happy

package module
v0.0.0-...-c314f80 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 13 Imported by: 0

README

happy

happy on desk manager

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PanicDoneExit = errors.New("done exit")
	PanicGameEnd  = errors.New("game end")
)

Functions

This section is empty.

Types

type CostMode

type CostMode int
const (
	CostModeFree            CostMode = iota // 免费
	CostModeJoin                            // 进入时
	CostModeFirstRoundBegin                 // 首局开始
	CostModeFirstRoundEnd                   // 首局结束
	CostModeRoundBegin                      // 每局开始
	CostModeRoundEnd                        // 每局结束
	CostModeFinish                          // 最后结束
)

type Event

type Event struct {
	RoundBegin        func(h Happy, curRound, maxRound uint32, pMgr *pmgr.PMgr, extend map[string]interface{})
	RoundEnd          func(h Happy, curRound, maxRound uint32, pMgr *pmgr.PMgr, extend map[string]interface{})
	PlayerJoinSuccess func(h Happy, key interface{}, pMgr *pmgr.PMgr, alreadyExist bool, extend map[string]interface{})
	PlayerJoinFail    func(h Happy, key interface{}, kind EventPlayerJoinFailKind, extend map[string]interface{})
	PlayerExit        func(h Happy, key interface{}, pMgr *pmgr.PMgr, extend map[string]interface{})
	PlayerReady       func(h Happy, key interface{}, pMgr *pmgr.PMgr, extend map[string]interface{})
	PlayerLine        func(h Happy, key interface{}, pMgr *pmgr.PMgr, extend map[string]interface{})
	PlayerOp          func(h Happy, key interface{}, pMgr *pmgr.PMgr, extend map[string]interface{})
	PlayerAuto        func(h Happy, key interface{}, pMgr *pmgr.PMgr, extend map[string]interface{})
	PlayerSite        func(h Happy, key interface{}, mgr *pmgr.PMgr, extend map[string]interface{})
	PlayerScore       func(h Happy, key interface{}, mgr *pmgr.PMgr, extend map[string]interface{})
	Cost              func(h Happy, mode CostMode, back bool, pMgr *pmgr.PMgr, extend map[string]interface{})
	DisbandAgree      func(h Happy, ts time.Duration, deadlineTs int64, userKey interface{}, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	DisbandReject     func(h Happy, ts time.Duration, deadlineTs int64, userKey interface{}, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	DisbandPass       func(h Happy, deadlineTs int64, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	DisbandFail       func(h Happy, deadlineTs int64, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	QuickAgree        func(h Happy, ts time.Duration, deadlineTs int64, userKey interface{}, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	QuickReject       func(h Happy, ts time.Duration, deadlineTs int64, userKey interface{}, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	QuickPass         func(h Happy, deadlineTs int64, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	QuickFail         func(h Happy, deadlineTs int64, pMgr *pmgr.PMgr, op map[interface{}]bool, extend map[string]interface{})
	Finish            func(h Happy, curRound, maxRound uint32, pMgr *pmgr.PMgr, disband bool, extend map[string]interface{})
}

type EventPlayerJoinFailKind

type EventPlayerJoinFailKind int
const (
	EventPlayerJoinFailKindFull             EventPlayerJoinFailKind = iota // 人数已满
	EventPlayerJoinFailKindViewOff                                         // 禁止观战
	EventPlayerJoinFailKindLocationOff                                     // 定位未开启
	EventPlayerJoinFailKindLocationIpSame                                  // 定位IP相同
	EventPlayerJoinFailKindLocationTooClose                                // 定位距离过近
)

type GameBase

type GameBase struct {
	Ctx   context.Context
	PMgr  proxy.GamePMgr
	PMsg  proxy.PlayerMsg
	Delay proxy.GameDelay
	Log   proxy.GameLog
}

func (*GameBase) Auto

func (g *GameBase) Auto() *proxy.GameAuto

func (*GameBase) Begin

func (g *GameBase) Begin(quick bool)

func (*GameBase) DisbandTs

func (g *GameBase) DisbandTs() time.Duration

func (*GameBase) DistanceLimit

func (g *GameBase) DistanceLimit() int

func (*GameBase) End

func (g *GameBase) End()

func (*GameBase) Finish

func (g *GameBase) Finish(disband bool)

func (*GameBase) GameEnd

func (g *GameBase) GameEnd()

func (*GameBase) Init

func (g *GameBase) Init(ctx context.Context, delay proxy.GameDelay, pMgr proxy.GamePMgr, pMsg proxy.PlayerMsg, log proxy.GameLog) error

func (*GameBase) IpLimit

func (g *GameBase) IpLimit() bool

func (*GameBase) Msg

func (g *GameBase) Msg(userKey interface{}, data interface{})

func (*GameBase) PlayerAuto

func (g *GameBase) PlayerAuto(userKey interface{})

func (*GameBase) PlayerExit

func (g *GameBase) PlayerExit(userKey interface{}, view bool)

func (*GameBase) PlayerJoin

func (g *GameBase) PlayerJoin(userKey interface{}, exist bool, view bool)

func (*GameBase) PlayerMaxNum

func (g *GameBase) PlayerMaxNum() int

func (*GameBase) PlayerOfflineKickOut

func (g *GameBase) PlayerOfflineKickOut() time.Duration

func (*GameBase) PlayerOp

func (g *GameBase) PlayerOp(userKey interface{}, exist bool, view bool)

func (*GameBase) Quick

func (g *GameBase) Quick(num int) bool

func (*GameBase) QuickTs

func (g *GameBase) QuickTs() time.Duration

func (*GameBase) View

func (g *GameBase) View() bool

type Happy

type Happy interface {
	Context() context.Context
	Init() error
	Resume(begin bool, curRound uint32)
	Run(resume bool)
	Cost(mode CostMode)
	Event(e *Event)
	Heartbeat(interval time.Duration) error
	Msg(msg *proxy.Msg)
	MsgByUser(f func(userKey interface{}, data interface{}, delay proxy.Delay, curRound, maxRound uint32, pMgr *pmgr.PMgr, extend map[string]interface{}))
	Owner(userKey interface{})
	PlayerMsg(msg proxy.PlayerMsg)
	Plugin(p *Plugin)
	RoundBeginPolicy(policy RoundBeginPolicy)
	LogSetting(path string, level log.Level) error
	Log() *log.Logger
}

func New

func New(ctx context.Context, maxRound uint32, game proxy.Game, extend map[string]interface{}) Happy

type Plugin

type Plugin struct {
	PlayerExitDisband   func(userKey interface{}, ownerUserKey interface{}, extend map[string]interface{}) bool
	DisbandMinAgreeNum  func(num int) int
	DisbandDeadlinePass func(extend map[string]interface{}) bool
	QuickMinAgreeNum    func(num int) int
	QuickDeadlinePass   func(extend map[string]interface{}) bool
	LocationDistance    func(origin *player.Location, des ...*player.Location) ([]int, error)
}

type RoundBeginPolicy

type RoundBeginPolicy int
const (
	RoundBeginPolicyAllPlayerReady RoundBeginPolicy = iota // 所有玩家准备
	RoundBeginPolicyFullPlayer                             // 满员
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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