diff --git a/comm/const.go b/comm/const.go index 0d1852e6c..997779a08 100644 --- a/comm/const.go +++ b/comm/const.go @@ -516,6 +516,7 @@ const ( EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件 + EventCloseRoom core.Event_Key = "EventCloseRoom" // //EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32) ) diff --git a/modules/entertainment/gamemgr.go b/modules/entertainment/gamemgr.go index 70fa38f43..84bfcfc9a 100644 --- a/modules/entertainment/gamemgr.go +++ b/modules/entertainment/gamemgr.go @@ -6,6 +6,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" + "go_dreamfactory/lego/sys/event" "go_dreamfactory/pb" "sync" @@ -28,6 +29,11 @@ func (this *gameMgrComp) Init(service core.IService, module core.IModule, comp c this.rooms = make(map[string]*Room) return } +func (this *gameMgrComp) Start() (err error) { + + event.RegisterGO(comm.EventCloseRoom, this.CloseRoom) + return +} // 通过房间ID 加入房间 func (this *gameMgrComp) JoinMasterRoom(roomid string, p *pb.PlayerData) (room *Room, err error) { diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 4fcc09ae3..8e90d3f22 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/timewheel" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" @@ -220,12 +221,12 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr switch stype { case "operator": // 操作消息 var ( - curScore int32 // 该次操作的得分 - AIOperator bool - oid1 int32 // 唯一id - oid2 int32 - color int32 // 校验消除的颜色 - bAddPs bool + curScore int32 // 该次操作的得分 + //AIOperator bool + oid1 int32 // 唯一id + oid2 int32 + color int32 // 校验消除的颜色 + bAddPs bool ) var szMap []*pb.MapData req := msg.(*pb.EntertainOperatorReq) @@ -380,9 +381,9 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr if this.player1.Ps <= 0 { this.NexPower = this.player2.Userinfo.Uid - if len(this.szSession) == 1 { // 校验2号玩家是不是AI - AIOperator = true - } + // if len(this.szSession) == 1 { // 校验2号玩家是不是AI + // AIOperator = true + // } this.player2.Ps = MaxPs } } else { // this.curPower == this.player2.Uid @@ -453,9 +454,9 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } // 变更权限 this.curPower = this.NexPower - if AIOperator { // AI操作 - this.AiOperator() - } + // if AIOperator { // AI操作 + // this.AiOperator() + // } case "ready": var bStartGame bool // 可以开始游戏 this.NexPower = this.player1.Userinfo.Uid @@ -491,7 +492,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } else { this.MaxTime = this.module.ModuleTools.GetGlobalConf().ConsumePvpTime } - this.MaxTime = 10 + this.MaxTime = 30 // 测试用 后面走配置 this.Status = 1 this.round = 1 @@ -677,6 +678,8 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) { Reward: atno, Box: box, }, this.szSession...) + + event.TriggerEvent(comm.EventCloseRoom, this.Id) return }