This commit is contained in:
liwei1dao 2023-11-03 21:34:19 +08:00
commit bc01685ba4
3 changed files with 23 additions and 13 deletions

View File

@ -516,6 +516,7 @@ const (
EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件 EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件
EventCloseRoom core.Event_Key = "EventCloseRoom" //
//EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32) //EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32)
) )

View File

@ -6,6 +6,7 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/event"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"sync" "sync"
@ -28,6 +29,11 @@ func (this *gameMgrComp) Init(service core.IService, module core.IModule, comp c
this.rooms = make(map[string]*Room) this.rooms = make(map[string]*Room)
return return
} }
func (this *gameMgrComp) Start() (err error) {
event.RegisterGO(comm.EventCloseRoom, this.CloseRoom)
return
}
// 通过房间ID 加入房间 // 通过房间ID 加入房间
func (this *gameMgrComp) JoinMasterRoom(roomid string, p *pb.PlayerData) (room *Room, err error) { func (this *gameMgrComp) JoinMasterRoom(roomid string, p *pb.PlayerData) (room *Room, err error) {

View File

@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/event"
"go_dreamfactory/lego/sys/timewheel" "go_dreamfactory/lego/sys/timewheel"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
@ -221,7 +222,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
case "operator": // 操作消息 case "operator": // 操作消息
var ( var (
curScore int32 // 该次操作的得分 curScore int32 // 该次操作的得分
AIOperator bool //AIOperator bool
oid1 int32 // 唯一id oid1 int32 // 唯一id
oid2 int32 oid2 int32
color int32 // 校验消除的颜色 color int32 // 校验消除的颜色
@ -380,9 +381,9 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
if this.player1.Ps <= 0 { if this.player1.Ps <= 0 {
this.NexPower = this.player2.Userinfo.Uid this.NexPower = this.player2.Userinfo.Uid
if len(this.szSession) == 1 { // 校验2号玩家是不是AI // if len(this.szSession) == 1 { // 校验2号玩家是不是AI
AIOperator = true // AIOperator = true
} // }
this.player2.Ps = MaxPs this.player2.Ps = MaxPs
} }
} else { // this.curPower == this.player2.Uid } 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 this.curPower = this.NexPower
if AIOperator { // AI操作 // if AIOperator { // AI操作
this.AiOperator() // this.AiOperator()
} // }
case "ready": case "ready":
var bStartGame bool // 可以开始游戏 var bStartGame bool // 可以开始游戏
this.NexPower = this.player1.Userinfo.Uid this.NexPower = this.player1.Userinfo.Uid
@ -491,7 +492,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
} else { } else {
this.MaxTime = this.module.ModuleTools.GetGlobalConf().ConsumePvpTime this.MaxTime = this.module.ModuleTools.GetGlobalConf().ConsumePvpTime
} }
this.MaxTime = 10 this.MaxTime = 30 // 测试用 后面走配置
this.Status = 1 this.Status = 1
this.round = 1 this.round = 1
@ -677,6 +678,8 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
Reward: atno, Reward: atno,
Box: box, Box: box,
}, this.szSession...) }, this.szSession...)
event.TriggerEvent(comm.EventCloseRoom, this.Id)
return return
} }