竞技馆招募功能
This commit is contained in:
parent
9f35e077f0
commit
848d7485a7
|
@ -1467,6 +1467,78 @@ func CSTouchTypeHandler(s *netlib.Session, packetId int, data interface{}, sid i
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CSRoomRecruitHandler(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSRoomRecruitHandler Process recv ", data)
|
||||||
|
msg, ok := data.(*gamehall.CSRoomRecruit)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()))
|
||||||
|
if scene == nil || !scene.IsCustom() || scene.creator != p.SnId {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 标记招募状态
|
||||||
|
scene.IsRecruit = true
|
||||||
|
scene.RecruitTimes++
|
||||||
|
|
||||||
|
pack := &gamehall.SCRoomRecruit{
|
||||||
|
RoomId: msg.GetRoomId(),
|
||||||
|
On: 1,
|
||||||
|
}
|
||||||
|
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomRecruit), pack)
|
||||||
|
logger.Logger.Tracef("SCRoomRecruit: %v", pack)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CSInviteJoinRoomHandler(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSInviteJoinRoomHandler Process recv ", data)
|
||||||
|
_, ok := data.(*gamehall.CSInviteJoinRoom)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := &gamehall.SCInviteJoinRoom{}
|
||||||
|
|
||||||
|
scene := SceneMgrSingleton.FindCustomInviteRoom(p)
|
||||||
|
if scene != nil {
|
||||||
|
pack.RoomId = int32(scene.sceneId)
|
||||||
|
pack.IsSystem = scene.creator == 0
|
||||||
|
pack.SnId = scene.creator
|
||||||
|
if scene.creator > 0 {
|
||||||
|
player := PlayerMgrSington.GetPlayerBySnId(scene.creator)
|
||||||
|
if player != nil {
|
||||||
|
pack.Name = player.GetName()
|
||||||
|
pack.UseRoleId = player.Roles.ModId
|
||||||
|
}
|
||||||
|
cfg := PlatformMgrSingleton.GetConfig(p.Platform).RoomConfig[scene.CustomParam.GetRoomConfigId()]
|
||||||
|
if cfg != nil {
|
||||||
|
pack.RoomName = cfg.GetName()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cfg := PlatformMgrSingleton.GetConfig(p.Platform).RoomConfig[scene.RoomConfigSystem.GetRoomConfigId()]
|
||||||
|
if cfg != nil {
|
||||||
|
pack.RoomName = cfg.GetName()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCInviteJoinRoom), pack)
|
||||||
|
logger.Logger.Tracef("SCInviteJoinRoom: %v", pack)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 返回房间
|
// 返回房间
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomHandler{})
|
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomHandler{})
|
||||||
|
@ -1506,4 +1578,8 @@ func init() {
|
||||||
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_GETPRIVATEROOMLIST), &gamehall.CSGetPrivateRoomList{}, CSGetPrivateRoomListHandler)
|
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_GETPRIVATEROOMLIST), &gamehall.CSGetPrivateRoomList{}, CSGetPrivateRoomListHandler)
|
||||||
// 保持刷新
|
// 保持刷新
|
||||||
common.Register(int(gamehall.GameHallPacketID_PACKET_CSTouchType), &gamehall.CSTouchType{}, CSTouchTypeHandler)
|
common.Register(int(gamehall.GameHallPacketID_PACKET_CSTouchType), &gamehall.CSTouchType{}, CSTouchTypeHandler)
|
||||||
|
// 设置招募状态
|
||||||
|
common.Register(int(gamehall.GameHallPacketID_PACKET_CSRoomRecruit), &gamehall.CSRoomRecruit{}, CSRoomRecruitHandler)
|
||||||
|
// 推荐房间
|
||||||
|
common.Register(int(gamehall.GameHallPacketID_PACKET_CSInviteJoinRoom), &gamehall.CSInviteJoinRoom{}, CSInviteJoinRoomHandler)
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,6 +298,7 @@ func (c *CustomRoomMgr) UpdateCreate(plt string, configId int32, mustCreate bool
|
||||||
Voice: cfg.GetVoice(),
|
Voice: cfg.GetVoice(),
|
||||||
},
|
},
|
||||||
RoomConfigSystem: cfg,
|
RoomConfigSystem: cfg,
|
||||||
|
IsRecruit: true,
|
||||||
})
|
})
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
logger.Logger.Tracef("竞技馆系统房间创建成功 roomId:%v", scene.sceneId)
|
logger.Logger.Tracef("竞技馆系统房间创建成功 roomId:%v", scene.sceneId)
|
||||||
|
|
|
@ -62,14 +62,18 @@ type Scene struct {
|
||||||
BaseScore int32 // 游戏底分,优先级,创建参数>本地配置>场次配置
|
BaseScore int32 // 游戏底分,优先级,创建参数>本地配置>场次配置
|
||||||
SceneState int32 // 房间当前状态
|
SceneState int32 // 房间当前状态
|
||||||
Channel []string // 客户端类型
|
Channel []string // 客户端类型
|
||||||
|
csp *CoinScenePool // 所在场景池
|
||||||
|
hp *HundredSceneMgr // 百人场房间池
|
||||||
|
|
||||||
|
// 以下为自定义字段
|
||||||
|
|
||||||
|
CloseCtrl bool // 调控开关
|
||||||
*serverproto.CustomParam // 房卡场参数
|
*serverproto.CustomParam // 房卡场参数
|
||||||
*serverproto.MatchParam // 比赛场参数
|
*serverproto.MatchParam // 比赛场参数
|
||||||
*webapiproto.RoomConfigSystem // 系统竞技馆房间
|
*webapiproto.RoomConfigSystem // 系统竞技馆房间
|
||||||
CloseCtrl bool // 调控开关
|
|
||||||
CustomWinSnId int32 // 房卡场胜利者
|
CustomWinSnId int32 // 房卡场胜利者
|
||||||
|
IsRecruit bool // 招募中
|
||||||
csp *CoinScenePool // 所在场景池
|
RecruitTimes int // 招募次数
|
||||||
hp *HundredSceneMgr // 百人场房间池
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewScene 创建房间
|
// NewScene 创建房间
|
||||||
|
@ -108,6 +112,7 @@ func NewScene(args *CreateSceneParam) *Scene {
|
||||||
CustomParam: args.CustomParam,
|
CustomParam: args.CustomParam,
|
||||||
MatchParam: args.MatchParam,
|
MatchParam: args.MatchParam,
|
||||||
RoomConfigSystem: args.RoomConfigSystem,
|
RoomConfigSystem: args.RoomConfigSystem,
|
||||||
|
IsRecruit: args.IsRecruit,
|
||||||
}
|
}
|
||||||
// 最大房间人数
|
// 最大房间人数
|
||||||
if s.playerNum <= 0 {
|
if s.playerNum <= 0 {
|
||||||
|
@ -648,6 +653,10 @@ func (this *Scene) GetPlayerCnt() int {
|
||||||
return len(this.players)
|
return len(this.players)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Scene) GetMaxPlayerNum() int {
|
||||||
|
return this.playerNum
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Scene) GetAudienceCnt() int {
|
func (this *Scene) GetAudienceCnt() int {
|
||||||
return len(this.audiences)
|
return len(this.audiences)
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,6 +371,64 @@ func (m *SceneMgr) FindRoomList(args *FindRoomParam) []*Scene {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindCustomInviteRoom 竞技馆房间推荐
|
||||||
|
func (m *SceneMgr) FindCustomInviteRoom(p *Player) *Scene {
|
||||||
|
// 无密码,未满人,未开始
|
||||||
|
// 玩家房间 > 系统房间
|
||||||
|
// 人数 > 招募次数 > 创建时间
|
||||||
|
var ret []*Scene
|
||||||
|
for _, v := range m.scenes {
|
||||||
|
if v.deleting || v.force || v.closed {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !v.IsCustom() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if v.GetPassword() != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if v.IsFull() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !v.IsRecruit {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(v.Channel) > 0 && !slices.Contains(v.Channel, p.AppChannel) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ret = append(ret, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(ret, func(i, j int) bool {
|
||||||
|
if ret[i].creator > 0 && ret[j].creator == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if ret[i].creator == 0 && ret[j].creator > 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
iN, jN := ret[i].GetMaxPlayerNum()-ret[i].GetPlayerCnt(), ret[j].GetMaxPlayerNum()-ret[j].GetPlayerCnt()
|
||||||
|
if iN > jN {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if iN < jN {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if ret[i].RecruitTimes > ret[j].RecruitTimes {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if ret[i].RecruitTimes < ret[j].RecruitTimes {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return ret[i].createTime.Unix() < ret[j].createTime.Unix()
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(ret) > 0 {
|
||||||
|
return ret[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type CreateSceneParam struct {
|
type CreateSceneParam struct {
|
||||||
CreateId int32 // 创建者id
|
CreateId int32 // 创建者id
|
||||||
RoomId int // 房间id
|
RoomId int // 房间id
|
||||||
|
@ -387,6 +445,7 @@ type CreateSceneParam struct {
|
||||||
*serverproto.CustomParam // 房卡场参数
|
*serverproto.CustomParam // 房卡场参数
|
||||||
*serverproto.MatchParam // 比赛场参数
|
*serverproto.MatchParam // 比赛场参数
|
||||||
*webapiproto.RoomConfigSystem // 竞技管系统房参数
|
*webapiproto.RoomConfigSystem // 竞技管系统房参数
|
||||||
|
IsRecruit bool // 是否招募
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateScene 创建房间
|
// CreateScene 创建房间
|
||||||
|
|
|
@ -86,6 +86,8 @@ func (spd *ScenePolicyData) OnSceneState(s *Scene, state int) {
|
||||||
}
|
}
|
||||||
LotteryMgrInst.AddCostRoomCard(s.platform.IdStr, s.creator, int64(n))
|
LotteryMgrInst.AddCostRoomCard(s.platform.IdStr, s.creator, int64(n))
|
||||||
}
|
}
|
||||||
|
s.IsRecruit = false
|
||||||
|
s.RecruitTimes = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
case common.SceneStateEnd:
|
case common.SceneStateEnd:
|
||||||
|
|
Loading…
Reference in New Issue