package main

import (
	"mongo.games.com/game/protocol/gamehall"
)

var coinScenePools = map[int32]ICoinScenePool{}

// RegisterCoinScenePool 注册游戏匹配规则
func RegisterCoinScenePool(gameId int32, policy ICoinScenePool) {
	coinScenePools[gameId] = policy
}

func GetCoinScenePool(gameId int32) ICoinScenePool {
	return coinScenePools[gameId]
}

type ICoinScenePool interface {
	New() interface{}
	CanEnter(pool *CoinScenePool, p *Player) gamehall.OpResultCode
	CanAudienceEnter(pool *CoinScenePool, p *Player) gamehall.OpResultCode

	PlayerEnter(pool *CoinScenePool, p *Player, exclude []int32, ischangeroom bool) (ret gamehall.OpResultCode, scene *Scene)
	AudienceEnter(pool *CoinScenePool, p *Player, exclude []int32, ischangeroom bool) (ret gamehall.OpResultCode, scene *Scene)
	OnPlayerEnter(pool *CoinScenePool, p *Player, scene *Scene)

	PlayerLeave(pool *CoinScenePool, p *Player, reason int) bool
	AudienceLeave(pool *CoinScenePool, p *Player, reason int) bool
	OnPlayerLeave(pool *CoinScenePool, s *Scene, p *Player)

	NewScene(pool *CoinScenePool, p *Player) *Scene
	NewPreCreateScene(pool *CoinScenePool) *Scene

	OnDestroyScene(pool *CoinScenePool, sceneId int)
}
