From a0c6b5485e149cf9f953386c7ee4f461cfd49459 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 25 Oct 2023 11:10:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AF=B9=E6=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 122 +++++++++++++++++++++--------- modules/entertainment/xxlPlat.go | 41 +++++----- modules/entertainment/xxl_test.go | 2 +- pb/entertain_db.pb.go | 51 +++++++------ 4 files changed, 134 insertions(+), 82 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index dc665fe1f..aa23da666 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -28,10 +28,11 @@ type Room struct { module *Entertainment round int32 // 轮数 operatetimer *timewheel.Task //操作倒计时定时器 - //aiTimer *timewheel.Task //AI操作随机做个延时 - curPower string // 当前操作的玩家 - NexPower string // 下一个操作的玩家 - MaxRound int32 + curPower string // 当前操作的玩家 + NexPower string // 下一个操作的玩家 + MaxRound int32 + rd1 bool + rd2 bool } func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) { @@ -111,9 +112,9 @@ func (this *Room) AiOperator() { var ( curScore int32 szMap []*pb.MapData - - oid1 int32 - oid2 int32 + bAddPs bool + oid1 int32 + oid2 int32 ) this.module.Debugf("AI 操作\n") @@ -124,16 +125,22 @@ func (this *Room) AiOperator() { this.player1.Ps = MaxPs // 交换元素 - curScore, szMap, oid1, oid2 = this.chessboard.AiSwapGirde() + curScore, szMap, oid1, oid2, bAddPs = this.chessboard.AiSwapGirde() if this.NexPower != this.curPower { this.round++ } for _, v := range szMap { // - if v.Xgrid > 0 { - this.player2.Energy += v.Xgrid + if v.CurEnergy > 0 { + this.player2.Energy += v.CurEnergy } } + if bAddPs { + this.player2.Ps++ + if this.player2.Ps > MaxPs { + this.player2.Ps = MaxPs + } + } this.player2.Score += curScore // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ @@ -169,6 +176,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr oid1 int32 // 唯一id oid2 int32 color int32 // 校验消除的颜色 + bAddPs bool ) var szMap []*pb.MapData req := msg.(*pb.EntertainOperatorReq) @@ -209,6 +217,36 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } this.player1.Score += curScore + } else { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_EntertainNoEnergy, + Title: pb.ErrorCode_EntertainNoEnergy.ToString(), + } + return + } + this.NexPower = this.curPower + } else { + conf, err := this.module.configure.GetGameConsumeHero(this.player2.Cardid) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_EntertainNoHeroSkill, + Title: pb.ErrorCode_EntertainNoHeroSkill.ToString(), + } + return + } + if this.player2.Energy >= conf.Skillload { + this.player2.Energy = 0 // 清零 + + if score, m := this.chessboard.SkillUp(conf.Skilleffect, conf.Skillvalue); score > 0 { + curScore += score + szMap = append(szMap, m...) + } else { + szMap = append(szMap, &pb.MapData{ + Data: this.chessboard.GetPalatData(), + }) + } + this.player2.Score += curScore + } else { errdata = &pb.ErrorData{ Code: pb.ErrorCode_EntertainNoEnergy, @@ -245,9 +283,10 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr return } - if score, m := this.chessboard.CheckMap(color); score > 0 { + if score, m, b := this.chessboard.CheckMap(color); score > 0 { curScore += score szMap = append(szMap, m...) + bAddPs = b } else { // 不能消除 this.chessboard.SwapGirde(req.Targetid, req.Curid) // 换到原来的位置 errdata = &pb.ErrorData{ @@ -260,30 +299,30 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr if this.curPower == this.player1.Uid { //权限校验 this.player1.Score += curScore this.player1.Ps-- - // if curScore >= 4 { - // this.player1.Ps++ - // if this.player1.Ps > MaxPs { - // this.player1.Ps = MaxPs - // } - // } + if bAddPs { + this.player1.Ps++ + if this.player1.Ps > MaxPs { + this.player1.Ps = MaxPs + } + } this.player2.Ps = MaxPs } else { // this.curPower == this.player2.Uid this.player2.Score += curScore this.player2.Ps-- - // if curScore >= 4 { - // this.player2.Ps++ - // if this.player2.Ps > MaxPs { - // this.player2.Ps = MaxPs - // } - // } + if bAddPs { + this.player2.Ps++ + if this.player2.Ps > MaxPs { + this.player2.Ps = MaxPs + } + } this.player1.Ps = MaxPs } for _, v := range szMap { // - if v.Xgrid > 0 { + if v.CurEnergy > 0 { if color == 1 { - this.player1.Energy += v.Xgrid + this.player1.Energy += v.CurEnergy } else { - this.player2.Energy += v.Xgrid + this.player2.Energy += v.CurEnergy } } } @@ -304,15 +343,6 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } } - // for _, v := range szMap { - // fmt.Printf("======szMap=======\n") - // for index := Width - 1; index >= 0; index-- { - // for j := 0; j < Height; j++ { - // fmt.Printf("%d:%d ", v.Data[index+j*Height].Oid, v.Data[index+j*Height].Color) - // } - // fmt.Printf("\n") - // } - // } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -349,12 +379,30 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr Mpadata: &pb.MapData{Data: this.chessboard.Plat}, Power: this.NexPower, Round: this.round, - Roomid: "", + Roomid: this.Id, // 房间ID }, this.szSession...); err != nil { this.Errorln(err) } - this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut) + } else { + if this.player1.Uid == session.GetUserId() { + this.rd1 = true + } else if this.player2.Uid == session.GetUserId() { + this.rd2 = true + } + if this.rd1 && this.rd2 { // 两个玩家都准备好了 那么就开始游戏 + if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "startgame", &pb.EntertainStartGamePush{ + User1: this.player1, + User2: this.player2, + Mpadata: &pb.MapData{Data: this.chessboard.Plat}, + Power: this.NexPower, + Round: this.round, + Roomid: this.Id, + }, this.szSession...); err != nil { + this.Errorln(err) + } + this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut) + } } } diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index f265e6dd2..d0c2b64cc 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -79,8 +79,7 @@ func (this *MapData) SwapGirde(oldId, newId int32) (bSwap bool) { this.operElem = append(this.operElem, newId) this.operElem = append(this.operElem, oldId) } - this.Debugf() - //this.CheckMap(color) + //this.Debugf() return } @@ -89,10 +88,10 @@ func (this *MapData) SetMap() { 1, 1, 2, 5, 1, 5, 2, 3, 2, 3, 1, 2, 4, 4, 2, 1, 1, 3, 6, 4, 1, - 1, 3, 1, 4, 3, 6, 3, - 1, 3, 3, 5, 1, 6, 1, - 5, 1, 2, 5, 1, 3, 1, - 1, 1, 5, 1, 2, 1, 4, + 4, 1, 1, 4, 3, 6, 3, + 4, 3, 4, 5, 1, 6, 1, + 5, 4, 2, 5, 1, 3, 1, + 4, 1, 5, 1, 2, 1, 4, } var pos int for index := Width - 1; index >= 0; index-- { @@ -440,33 +439,36 @@ func (this *MapData) Check3X(color int32) (bEliminate bool, score int32, count i } // 校验地图可消除的 判断各组上面2个和右边两个是否三个相等 -func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData) { +// xc 判断用来是否加体力 +func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData, xc bool) { var curScore int32 for { curScore = 0 - var count int32 + var energy int32 if bRet, s, c := this.Check5X(color); bRet { fmt.Printf("=====检测消除5x===========\n") curScore += s - count += c + energy += c + xc = true // 只要有 4x 5x 就标记ture } if bRet, s, c := this.Check4X(color); bRet { fmt.Printf("=====检测消除4x===========\n") curScore += s - count += c + energy += c + xc = true } if bRet, s, c := this.Check3X(color); bRet { fmt.Printf("=====检测消除3x===========\n") curScore += s - count += c + energy += c } score += curScore // 总分 if this.DropGirde() { szMap = append(szMap, &pb.MapData{ - Data: this.GetPalatData(), - CurSocre: curScore, - Xgrid: count, + Data: this.GetPalatData(), + CurSocre: curScore, + CurEnergy: energy, }) } @@ -522,7 +524,7 @@ func (this *MapData) GetPalatData() (data []*pb.GirdeData) { } // ai操作 -func (this *MapData) AiSwapGirde() (score int32, szMap []*pb.MapData, oid1 int32, oid2 int32) { +func (this *MapData) AiSwapGirde() (score int32, szMap []*pb.MapData, oid1 int32, oid2 int32, bAddPs bool) { for pos := 0; pos < Total; pos++ { y := pos % Height @@ -530,7 +532,7 @@ func (this *MapData) AiSwapGirde() (score int32, szMap []*pb.MapData, oid1 int32 if b := this.SwapGirde(int32(pos), int32(pos+1)); b { oid1 = this.Plat[pos+1].Oid oid2 = this.Plat[pos].Oid - if s, m := this.CheckMap(2); s == 0 { + if s, m, b := this.CheckMap(2); s == 0 { this.SwapGirde(int32(pos+1), int32(pos)) this.operElem = []int32{} oid1 = 0 @@ -538,7 +540,7 @@ func (this *MapData) AiSwapGirde() (score int32, szMap []*pb.MapData, oid1 int32 } else { score += s szMap = append(szMap, m...) - + bAddPs = b break } } @@ -547,7 +549,7 @@ func (this *MapData) AiSwapGirde() (score int32, szMap []*pb.MapData, oid1 int32 if b := this.SwapGirde(int32(pos), int32(pos+Width)); b { oid1 = this.Plat[pos+Width].Oid oid2 = this.Plat[pos].Oid - if s, m := this.CheckMap(2); s == 0 { + if s, m, b := this.CheckMap(2); s == 0 { this.SwapGirde(int32(pos+Width), int32(pos)) this.operElem = []int32{} oid1 = 0 @@ -555,6 +557,7 @@ func (this *MapData) AiSwapGirde() (score int32, szMap []*pb.MapData, oid1 int32 } else { szMap = append(szMap, m...) score += s + bAddPs = b break } } @@ -571,7 +574,7 @@ func (this *MapData) SkillUp(skillid int32, value int32) (score int32, szMap []* this.Plat[id] = &pb.GirdeData{} } if this.DropGirde() { - score, szMap = this.CheckMap(1) + score, szMap, _ = this.CheckMap(1) } } diff --git a/modules/entertainment/xxl_test.go b/modules/entertainment/xxl_test.go index ae1fa316f..2c45bf19c 100644 --- a/modules/entertainment/xxl_test.go +++ b/modules/entertainment/xxl_test.go @@ -96,7 +96,7 @@ func Test_Main(t *testing.T) { m.DropGirde() - if score, m := m.CheckMap(1); score > 0 { + if score, m, _ := m.CheckMap(1); score > 0 { szMap = append(szMap, m...) } diff --git a/pb/entertain_db.pb.go b/pb/entertain_db.pb.go index 7455d917f..d36278282 100644 --- a/pb/entertain_db.pb.go +++ b/pb/entertain_db.pb.go @@ -26,9 +26,9 @@ type MapData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data []*GirdeData `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` // 地图数据 - CurSocre int32 `protobuf:"varint,2,opt,name=curSocre,proto3" json:"curSocre"` // 本轮得分 - Xgrid int32 `protobuf:"varint,3,opt,name=xgrid,proto3" json:"xgrid"` // 本次掉落消除的格子(客户端不用) + Data []*GirdeData `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` // 地图数据 + CurSocre int32 `protobuf:"varint,2,opt,name=curSocre,proto3" json:"curSocre"` // 本次地图更新得分 + CurEnergy int32 `protobuf:"varint,3,opt,name=curEnergy,proto3" json:"curEnergy"` // 本次掉落获得的能量 } func (x *MapData) Reset() { @@ -77,9 +77,9 @@ func (x *MapData) GetCurSocre() int32 { return 0 } -func (x *MapData) GetXgrid() int32 { +func (x *MapData) GetCurEnergy() int32 { if x != nil { - return x.Xgrid + return x.CurEnergy } return 0 } @@ -255,30 +255,31 @@ var File_entertain_entertain_db_proto protoreflect.FileDescriptor var file_entertain_entertain_db_proto_rawDesc = []byte{ 0x0a, 0x1c, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x2f, 0x65, 0x6e, 0x74, 0x65, - 0x72, 0x74, 0x61, 0x69, 0x6e, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, + 0x72, 0x74, 0x61, 0x69, 0x6e, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x63, 0x0a, 0x07, 0x4d, 0x61, 0x70, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x47, 0x69, 0x72, 0x64, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x75, 0x72, 0x53, 0x6f, 0x63, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x75, 0x72, - 0x53, 0x6f, 0x63, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x78, 0x67, 0x72, 0x69, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x78, 0x67, 0x72, 0x69, 0x64, 0x22, 0x75, 0x0a, 0x09, 0x47, - 0x69, 0x72, 0x64, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6f, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, - 0x6c, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, - 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, - 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x70, 0x65, 0x63, - 0x69, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x70, 0x65, 0x63, 0x69, - 0x61, 0x6c, 0x22, 0x88, 0x01, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x61, 0x74, - 0x61, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x0e, 0x0a, - 0x02, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x70, 0x73, 0x12, 0x16, 0x0a, - 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, - 0x61, 0x72, 0x64, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x53, 0x6f, 0x63, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x75, 0x72, 0x45, 0x6e, 0x65, 0x72, + 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x75, 0x72, 0x45, 0x6e, 0x65, + 0x72, 0x67, 0x79, 0x22, 0x75, 0x0a, 0x09, 0x47, 0x69, 0x72, 0x64, 0x65, 0x44, 0x61, 0x74, 0x61, + 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6f, + 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, + 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x22, 0x88, 0x01, 0x0a, 0x0a, 0x50, + 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x02, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x65, + 0x6e, 0x65, 0x72, 0x67, 0x79, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From a4046331659add8f9f7c7c18bd762f7bdbdcd9c1 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 25 Oct 2023 13:41:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/api_match.go | 2 +- modules/entertainment/configure.go | 14 +++ modules/entertainment/match.go | 125 ++++++++++++++++++++++++ modules/entertainment/module.go | 7 +- modules/entertainment/xxlPlat.go | 3 +- pb/entertain_db.pb.go | 148 ++++++++++++++++++++++------- 6 files changed, 260 insertions(+), 39 deletions(-) create mode 100644 modules/entertainment/match.go diff --git a/modules/entertainment/api_match.go b/modules/entertainment/api_match.go index e5227ef3f..98edbdd9c 100644 --- a/modules/entertainment/api_match.go +++ b/modules/entertainment/api_match.go @@ -18,7 +18,7 @@ func (this *apiComp) MatchCheck(session comm.IUserSession, req *pb.EntertainMatc } func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq) (errdata *pb.ErrorData) { - // 随便找个在线的人 + var ( //bMatch bool s2 comm.IUserSession diff --git a/modules/entertainment/configure.go b/modules/entertainment/configure.go index 2a3dcdaf9..52cdec2ae 100644 --- a/modules/entertainment/configure.go +++ b/modules/entertainment/configure.go @@ -107,3 +107,17 @@ func (this *configureComp) GetGameConsumeintegral(key int32) (conf *cfg.GameInte err = comm.NewNotFoundConfErr(moduleName, game_consumehero, key) return } + +func (this *configureComp) GetRobotGameConsumeHero() (cardid string) { + + if v, err := this.GetConfigure(game_consumehero); err == nil { + if configure, ok := v.(*cfg.GameConsumeHero); ok { + for _, v := range configure.GetDataList() { + cardid = v.Key + break + } + } + } + + return +} diff --git a/modules/entertainment/match.go b/modules/entertainment/match.go new file mode 100644 index 000000000..3ab124114 --- /dev/null +++ b/modules/entertainment/match.go @@ -0,0 +1,125 @@ +package entertainment + +import ( + "context" + "go_dreamfactory/comm" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + + "go_dreamfactory/lego/core" + + "google.golang.org/protobuf/types/known/anypb" +) + +/* +匹配组件 +*/ +type matchComp struct { + modules.MCompMatch + service core.IService + module *Entertainment +} + +//组件初始化接口 +func (this *matchComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompMatch.Init(service, module, comp, options) + this.module = module.(*Entertainment) + this.service = service + this.PoolName = "entertain" + return +} + +func (this *matchComp) Start() (err error) { + err = this.MCompMatch.Start() + return +} + +func (this *matchComp) MatchReq(v *pb.DBXXLMatch) (err error) { + data, _ := anypb.New(v) + this.module.service.Destroy() + err = this.module.service.RpcCall( + context.Background(), + comm.Service_Mainte, + string(comm.RPC_JoinMatchPools), + &pb.JoinMatchPoolReq{ + Poolname: this.PoolName, + Uid: v.Userinfo.Uid, + Data: data, + Matchnum: 2, // 匹配数量2 + Timeout: 10, + }, + &pb.JoinMatchPoolResp{}) + if err != nil { + this.module.Errorln(err) + return + } + return +} + +func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) { + var ( + playerSlice []*pb.DBXXLMatch + p1 *pb.PlayerData + p2 *pb.PlayerData + ) + playerSlice = make([]*pb.DBXXLMatch, 0, len(players)) + for _, v := range players { + playerSlice = append(playerSlice, v.(*pb.DBXXLMatch)) + } + for pos, v := range playerSlice { + if pos == 0 { + p1 = &pb.PlayerData{ + Uid: v.Userinfo.Uid, + Name: v.Userinfo.Name, + Score: 0, + Cardid: v.Cardid, + } + } else if pos == 1 { + p2 = &pb.PlayerData{ + Uid: v.Userinfo.Uid, + Name: v.Userinfo.Name, + Score: 0, + Cardid: v.Cardid, + } + } else { + break + } + } + if p1 == nil { + return + } + if p2 == nil { // 玩家2 是空 那么构建一个AI 对象 + if robots, err := this.module.ModuleTools.RandRobotConfig(1); err == nil { + if len(robots) > 0 { + p2 = &pb.PlayerData{ + Uid: "999", // AI uid 暂定 + Name: robots[0].Name, + Score: 0, + Ps: 0, + Cardid: this.module.configure.GetRobotGameConsumeHero(), // 机器人临时数据 + } + } + } + } + // roomid := this.module.gameMgr.CreateRoom(session, s2, p1, p2) + + // if leftnum > 0 { + // if ais, err = this.module.parkourComp.matcheAI(dan, leftnum); err != nil { + // this.module.Error("matcheAI err!", log.Field{Key: "key", Value: err.Error()}) + // return + // } + + // if len(red) < 3 { + // n = 3 - int32(len(red)) + // red = append(red, ais[0:n]...) + // ais = ais[n:] + // } + // if len(bule) < 3 { + // bule = append(bule, ais[0:3-len(bule)]...) + // } + // } + // if err = this.module.createbattle(red, bule); err != nil { + // this.module.Error("createbattle err!", log.Field{Key: "key", Value: err.Error()}) + // } + return +} diff --git a/modules/entertainment/module.go b/modules/entertainment/module.go index c0cf03f95..104519d67 100644 --- a/modules/entertainment/module.go +++ b/modules/entertainment/module.go @@ -2,6 +2,7 @@ package entertainment import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -14,12 +15,13 @@ func NewModule() core.IModule { type Entertainment struct { modules.ModuleBase - service core.IService + service base.IRPCXService api *apiComp configure *configureComp model *modelComp gameMgr *gameMgrComp //room *Room + match *matchComp } // 模块名 @@ -32,7 +34,7 @@ func (this *Entertainment) Init(service core.IService, module core.IModule, opti if err = this.ModuleBase.Init(service, module, options); err != nil { return } - this.service = service + this.service = service.(base.IRPCXService) return } @@ -44,6 +46,7 @@ func (this *Entertainment) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.gameMgr = this.RegisterComp(new(gameMgrComp)).(*gameMgrComp) //this.room = this.RegisterComp(new(Room)).(*Room) + this.match = this.RegisterComp(new(matchComp)).(*matchComp) } func (this *Entertainment) Start() (err error) { diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index d0c2b64cc..3cd065f93 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -442,9 +442,10 @@ func (this *MapData) Check3X(color int32) (bEliminate bool, score int32, count i // xc 判断用来是否加体力 func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData, xc bool) { var curScore int32 + var energy int32 for { curScore = 0 - var energy int32 + energy = 0 if bRet, s, c := this.Check5X(color); bRet { fmt.Printf("=====检测消除5x===========\n") curScore += s diff --git a/pb/entertain_db.pb.go b/pb/entertain_db.pb.go index d36278282..25f3a3011 100644 --- a/pb/entertain_db.pb.go +++ b/pb/entertain_db.pb.go @@ -251,35 +251,97 @@ func (x *PlayerData) GetEnergy() int32 { return 0 } +// 消消乐匹配数据 +type DBXXLMatch struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"` + Cardid string `protobuf:"bytes,2,opt,name=cardid,proto3" json:"cardid"` // 选择的卡片ID +} + +func (x *DBXXLMatch) Reset() { + *x = DBXXLMatch{} + if protoimpl.UnsafeEnabled { + mi := &file_entertain_entertain_db_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBXXLMatch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBXXLMatch) ProtoMessage() {} + +func (x *DBXXLMatch) ProtoReflect() protoreflect.Message { + mi := &file_entertain_entertain_db_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DBXXLMatch.ProtoReflect.Descriptor instead. +func (*DBXXLMatch) Descriptor() ([]byte, []int) { + return file_entertain_entertain_db_proto_rawDescGZIP(), []int{3} +} + +func (x *DBXXLMatch) GetUserinfo() *BaseUserInfo { + if x != nil { + return x.Userinfo + } + return nil +} + +func (x *DBXXLMatch) GetCardid() string { + if x != nil { + return x.Cardid + } + return "" +} + var File_entertain_entertain_db_proto protoreflect.FileDescriptor var file_entertain_entertain_db_proto_rawDesc = []byte{ 0x0a, 0x1c, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x2f, 0x65, 0x6e, 0x74, 0x65, - 0x72, 0x74, 0x61, 0x69, 0x6e, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x63, - 0x0a, 0x07, 0x4d, 0x61, 0x70, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x47, 0x69, 0x72, 0x64, 0x65, 0x44, - 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x75, 0x72, - 0x53, 0x6f, 0x63, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x75, 0x72, - 0x53, 0x6f, 0x63, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x75, 0x72, 0x45, 0x6e, 0x65, 0x72, - 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x75, 0x72, 0x45, 0x6e, 0x65, - 0x72, 0x67, 0x79, 0x22, 0x75, 0x0a, 0x09, 0x47, 0x69, 0x72, 0x64, 0x65, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6f, - 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, - 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x22, 0x88, 0x01, 0x0a, 0x0a, 0x50, - 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x02, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x12, 0x16, 0x0a, - 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x65, - 0x6e, 0x65, 0x72, 0x67, 0x79, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x74, 0x61, 0x69, 0x6e, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, + 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x63, 0x0a, 0x07, 0x4d, 0x61, + 0x70, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x47, 0x69, 0x72, 0x64, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x75, 0x72, 0x53, 0x6f, 0x63, 0x72, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x75, 0x72, 0x53, 0x6f, 0x63, 0x72, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x75, 0x72, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x75, 0x72, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x22, + 0x75, 0x0a, 0x09, 0x47, 0x69, 0x72, 0x64, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, + 0x6f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6f, 0x69, 0x64, 0x12, 0x14, + 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, + 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, + 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x22, 0x88, 0x01, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, + 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, + 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x70, + 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x65, + 0x72, 0x67, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, + 0x79, 0x22, 0x4f, 0x0a, 0x0a, 0x44, 0x42, 0x58, 0x58, 0x4c, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, + 0x29, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, + 0x72, 0x64, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x72, 0x64, + 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -294,19 +356,22 @@ func file_entertain_entertain_db_proto_rawDescGZIP() []byte { return file_entertain_entertain_db_proto_rawDescData } -var file_entertain_entertain_db_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_entertain_entertain_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_entertain_entertain_db_proto_goTypes = []interface{}{ - (*MapData)(nil), // 0: MapData - (*GirdeData)(nil), // 1: GirdeData - (*PlayerData)(nil), // 2: PlayerData + (*MapData)(nil), // 0: MapData + (*GirdeData)(nil), // 1: GirdeData + (*PlayerData)(nil), // 2: PlayerData + (*DBXXLMatch)(nil), // 3: DBXXLMatch + (*BaseUserInfo)(nil), // 4: BaseUserInfo } var file_entertain_entertain_db_proto_depIdxs = []int32{ 1, // 0: MapData.data:type_name -> GirdeData - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 4, // 1: DBXXLMatch.userinfo:type_name -> BaseUserInfo + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_entertain_entertain_db_proto_init() } @@ -314,6 +379,7 @@ func file_entertain_entertain_db_proto_init() { if File_entertain_entertain_db_proto != nil { return } + file_comm_proto_init() if !protoimpl.UnsafeEnabled { file_entertain_entertain_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MapData); i { @@ -351,6 +417,18 @@ func file_entertain_entertain_db_proto_init() { return nil } } + file_entertain_entertain_db_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBXXLMatch); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -358,7 +436,7 @@ func file_entertain_entertain_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_entertain_entertain_db_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, From 86ea90004b5083276fdc07a459fb96d92f3db3fd Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 25 Oct 2023 13:48:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8A=80=E8=83=BD=E8=83=BD=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index aa23da666..845a4f269 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -129,10 +129,9 @@ func (this *Room) AiOperator() { if this.NexPower != this.curPower { this.round++ } - for _, v := range szMap { // - if v.CurEnergy > 0 { - this.player2.Energy += v.CurEnergy - } + + if len(szMap) > 0 { + this.player2.Energy += szMap[len(szMap)-1].CurEnergy } if bAddPs { @@ -317,13 +316,11 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } this.player1.Ps = MaxPs } - for _, v := range szMap { // - if v.CurEnergy > 0 { - if color == 1 { - this.player1.Energy += v.CurEnergy - } else { - this.player2.Energy += v.CurEnergy - } + if len(szMap) > 0 { + if color == 1 { + this.player1.Energy += szMap[len(szMap)-1].CurEnergy + } else { + this.player2.Energy += szMap[len(szMap)-1].CurEnergy } } if this.player1.Ps <= 0 { // 权限给下一个人 From f406d53316254c17d5b1ccb78fc9e9de509244fc Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 25 Oct 2023 14:15:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B6=88=E9=99=A4=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E6=94=B9=E7=B4=AF=E8=AE=A1=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/api_match.go | 16 ---------------- modules/entertainment/match.go | 20 +------------------- modules/entertainment/room.go | 3 +++ modules/entertainment/xxlPlat.go | 10 ++++------ 4 files changed, 8 insertions(+), 41 deletions(-) diff --git a/modules/entertainment/api_match.go b/modules/entertainment/api_match.go index 98edbdd9c..eeb8d4e32 100644 --- a/modules/entertainment/api_match.go +++ b/modules/entertainment/api_match.go @@ -48,22 +48,6 @@ func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq) } } - // if users, err := this.module.ModuleUser.UserOnlineList(); err == nil { - // if len(users) > 0 { - // bMatch = true - // s2, bMatch = this.module.GetUserSession(users[0].Uid) - // p2 = &pb.PlayerData{ - // Uid: s2.GetUserId(), - // Name: "", - // Score: 0, - // Ps: 0, - // Cardid: req.Idcard, - // } - // } else { // 测试用 - - // } - // - // } roomid = this.module.gameMgr.CreateRoom(session, s2, p1, p2) session.SendMsg(string(this.module.GetType()), "match", &pb.EntertainMatchResp{ Maych: true, diff --git a/modules/entertainment/match.go b/modules/entertainment/match.go index 3ab124114..ae9f3f679 100644 --- a/modules/entertainment/match.go +++ b/modules/entertainment/match.go @@ -101,25 +101,7 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) { } } } - // roomid := this.module.gameMgr.CreateRoom(session, s2, p1, p2) + //roomid := this.module.gameMgr.CreateRoom(p1, p2) - // if leftnum > 0 { - // if ais, err = this.module.parkourComp.matcheAI(dan, leftnum); err != nil { - // this.module.Error("matcheAI err!", log.Field{Key: "key", Value: err.Error()}) - // return - // } - - // if len(red) < 3 { - // n = 3 - int32(len(red)) - // red = append(red, ais[0:n]...) - // ais = ais[n:] - // } - // if len(bule) < 3 { - // bule = append(bule, ais[0:3-len(bule)]...) - // } - // } - // if err = this.module.createbattle(red, bule); err != nil { - // this.module.Error("createbattle err!", log.Field{Key: "key", Value: err.Error()}) - // } return } diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 845a4f269..8d34868de 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -132,6 +132,7 @@ func (this *Room) AiOperator() { if len(szMap) > 0 { this.player2.Energy += szMap[len(szMap)-1].CurEnergy + this.player2.Score += szMap[len(szMap)-1].CurSocre } if bAddPs { @@ -319,8 +320,10 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr if len(szMap) > 0 { if color == 1 { this.player1.Energy += szMap[len(szMap)-1].CurEnergy + this.player1.Score += szMap[len(szMap)-1].CurSocre } else { this.player2.Energy += szMap[len(szMap)-1].CurEnergy + this.player2.Score += szMap[len(szMap)-1].CurSocre } } if this.player1.Ps <= 0 { // 权限给下一个人 diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 3cd065f93..8015d93b8 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -445,21 +445,20 @@ func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData, xc var energy int32 for { curScore = 0 - energy = 0 if bRet, s, c := this.Check5X(color); bRet { - fmt.Printf("=====检测消除5x===========\n") + //fmt.Printf("=====检测消除5x===========\n") curScore += s energy += c xc = true // 只要有 4x 5x 就标记ture } if bRet, s, c := this.Check4X(color); bRet { - fmt.Printf("=====检测消除4x===========\n") + //fmt.Printf("=====检测消除4x===========\n") curScore += s energy += c xc = true } if bRet, s, c := this.Check3X(color); bRet { - fmt.Printf("=====检测消除3x===========\n") + //fmt.Printf("=====检测消除3x===========\n") curScore += s energy += c } @@ -468,7 +467,7 @@ func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData, xc if this.DropGirde() { szMap = append(szMap, &pb.MapData{ Data: this.GetPalatData(), - CurSocre: curScore, + CurSocre: score, CurEnergy: energy, }) } @@ -479,7 +478,6 @@ func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData, xc break } } - return }