From 0ca938652b1e39dd2531fc9dc43b368033db84d2 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 11:00:23 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/api_create.go | 5 ++-- modules/entertainment/api_joinroom.go | 5 ++-- modules/entertainment/api_match.go | 5 ++-- modules/entertainment/match.go | 10 ++++--- modules/entertainment/room.go | 38 +++++++++++++++++++------ modules/entertainment/xxlPlat.go | 39 ++++++++++++++------------ pb/entertain_db.pb.go | 40 ++++++++++++++++++++------- 7 files changed, 96 insertions(+), 46 deletions(-) diff --git a/modules/entertainment/api_create.go b/modules/entertainment/api_create.go index b8111bea4..182098934 100644 --- a/modules/entertainment/api_create.go +++ b/modules/entertainment/api_create.go @@ -63,8 +63,9 @@ func (this *apiComp) CreateRoom(session comm.IUserSession, req *pb.EntertainCrea return } p1 := &pb.PlayerData{ - Userinfo: comm.GetUserBaseInfo(user), - Cardid: req.Idcard, + Userinfo: comm.GetUserBaseInfo(user), + Cardid: req.Idcard, + Consumeexp: user.Consumeexp, } if room, err = this.module.gameMgr.CreateMasterRoom(p1); err != nil { errdata = &pb.ErrorData{ diff --git a/modules/entertainment/api_joinroom.go b/modules/entertainment/api_joinroom.go index a9a55ba44..a41d108c0 100644 --- a/modules/entertainment/api_joinroom.go +++ b/modules/entertainment/api_joinroom.go @@ -61,8 +61,9 @@ func (this *apiComp) JoinRoom(session comm.IUserSession, req *pb.EntertainJoinRo return } p := &pb.PlayerData{ - Userinfo: comm.GetUserBaseInfo(user), - Cardid: req.Idcard, + Userinfo: comm.GetUserBaseInfo(user), + Cardid: req.Idcard, + Consumeexp: user.Consumeexp, } if _, err = this.module.gameMgr.JoinMasterRoom(req.Roomid, p); err != nil { diff --git a/modules/entertainment/api_match.go b/modules/entertainment/api_match.go index dd6645f8c..83fcaae72 100644 --- a/modules/entertainment/api_match.go +++ b/modules/entertainment/api_match.go @@ -58,8 +58,9 @@ func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq) } this.module.match.MatchReq(&pb.DBXXLMatch{ - Userinfo: comm.GetUserBaseInfo(user), - Cardid: req.Idcard, + Userinfo: comm.GetUserBaseInfo(user), + Cardid: req.Idcard, + Consumeexp: user.Consumeexp, }) session.SendMsg(string(this.module.GetType()), "match", &pb.EntertainMatchResp{ diff --git a/modules/entertainment/match.go b/modules/entertainment/match.go index e7c0b0996..d27bf9800 100644 --- a/modules/entertainment/match.go +++ b/modules/entertainment/match.go @@ -68,13 +68,15 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) { for pos, v := range playerSlice { if pos == 0 { p1 = &pb.PlayerData{ - Userinfo: v.Userinfo, - Cardid: v.Cardid, + Userinfo: v.Userinfo, + Cardid: v.Cardid, + Consumeexp: v.Consumeexp, } } else if pos == 1 { p2 = &pb.PlayerData{ - Userinfo: v.Userinfo, - Cardid: v.Cardid, + Userinfo: v.Userinfo, + Cardid: v.Cardid, + Consumeexp: v.Consumeexp, } } else { break diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index a19b1726a..b187580a8 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -55,7 +55,7 @@ func (this *Room) RandomPlayType() (itype int32) { weight = append(weight, v.Weight) } itype = list[comm.GetRandW(weight)].Key - + //itype = 4 return } @@ -139,13 +139,13 @@ func (this *Room) AiOperator() { ChangeType: 1, }) } - for _, v := range szMap { // - curScore += v.CurSocre - this.player2.Score += v.CurSocre - v.CurSocre = this.player2.Score - this.player2.Energy += v.CurEnergy - v.CurEnergy = this.player2.Energy - } + // for _, v := range szMap { // + // curScore += v.CurSocre + // this.player2.Score += v.CurSocre + // v.CurSocre = this.player2.Score + // this.player2.Energy += v.CurEnergy + // v.CurEnergy = this.player2.Energy + // } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -381,6 +381,18 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr this.round++ } + for _, v := range szMap { // + fmt.Printf("================\n") + var v1 int + for index := Width - 1; index >= 0; index-- { + for j := 0; j < Height; j++ { + v1 = index + j*7 + fmt.Printf("%d ", v.Data[v1].Cid) + + } + fmt.Printf("\n") + } + } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -568,7 +580,15 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) { if conf, err := this.module.configure.GetGameConsumeintegral(user.Consumeexp); err == nil { //res = append(res, conf.Onereward...) 这奖励手动领取 res = append(res, conf.Rewards...) - + for _, v := range res { + if v.A == "attr" && v.T == "consumeexp" { + if winner == this.player1 { + this.player1.Score += v.N + } else { + this.player2.Score += v.N + } + } + } if errdata, atno = this.module.DispenseAtno(this.szSession[winindex], res, true); errdata != nil { return } diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 35f711217..052e493e4 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -117,7 +117,7 @@ func (this *MapData) InitMap(module *Entertainment, iType int32) { this.SetIndelibilityPlat() this.Plat = this.GetPalatData() - // this.SetMap() // 方便测试固定地图 + //this.SetMap() // 方便测试固定地图 } // 交换之前先判断是不是特殊元素的交换 @@ -740,26 +740,29 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, func (this *MapData) SetMap() { sz2 := []int32{ - 3, 3, 2, 2, 1, 3, 1, - 5, 1, 3, 3, 1, 2, 2, - 3, 2, 1, 4, 3, 1, 6, - 1, 4, 3, 4, 2, 3, 6, + 3, 1, 2, 2, 1, 3, 1, + 5, 1, 2, 3, 1, 2, 2, + 2, 42, 3, 4, 3, 1, 6, + 1, 3, 3, 4, 2, 3, 6, 1, 5, 6, 5, 6, 1, 4, - 6, 6, 3, 6, 3, 1, 3, - 3, 3, 1, 3, 3, 2, 5, - // 1, 4, 2, 5, 4, 5, 2, - // 3, 2, 3, 5, 2, 1, 4, - // 2, 5, 5, 4, 5, 4, 1, - // 3, 1, 3, 5, 2, 6, 3, - // 4, 5, 4, 2, 4, 1, 1, - // 5, 3, 1, 5, 3, 3, 4, - // 4, 2, 4, 1, 2, 3, 4, + 6, 6, 3, 6, 3, 48, 3, + 3, 3, 1, 3, 5, 2, 5, } var pos int for index := Width - 1; index >= 0; index-- { for j := 0; j < Height; j++ { - this.Plat[index+j*Height].Color = sz2[pos] - this.Plat[index+j*Height].Cid = sz2[pos] + Color := sz2[pos] + Cid := sz2[pos] + if sz2[pos] > 6 { + conf, err := this.module.configure.GetGameBlockByKey(sz2[pos]) + if err == nil { + Color = conf.Color + Cid = conf.Key + this.Plat[index+j*Height].Special = conf.Type + } + } + this.Plat[index+j*Height].Color = Color + this.Plat[index+j*Height].Cid = Cid pos++ } } @@ -1128,7 +1131,9 @@ func (this *MapData) GetBoomElem(pos int) (elem []int) { func (this *MapData) GetFireBoom(pos int, itype int32) (elem []int) { x := int(pos / Width) y := int(pos % Height) - + if itype == FireUp || itype == FireDown || itype == FireLeft || itype == FireRight { + elem = append(elem, pos) + } switch itype { case FireUp: //上烟火 for i := 0; i < Height; i++ { diff --git a/pb/entertain_db.pb.go b/pb/entertain_db.pb.go index b56baf19e..c71331730 100644 --- a/pb/entertain_db.pb.go +++ b/pb/entertain_db.pb.go @@ -177,11 +177,12 @@ type PlayerData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"` - Score int32 `protobuf:"varint,2,opt,name=score,proto3" json:"score"` // 积分 - Ps int32 `protobuf:"varint,3,opt,name=ps,proto3" json:"ps"` // 体力 - Cardid string `protobuf:"bytes,4,opt,name=cardid,proto3" json:"cardid"` // 出战的英雄卡 - Energy int32 `protobuf:"varint,5,opt,name=energy,proto3" json:"energy"` // 能量进度 + Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"` + Score int32 `protobuf:"varint,2,opt,name=score,proto3" json:"score"` // 本局战斗得分 + Ps int32 `protobuf:"varint,3,opt,name=ps,proto3" json:"ps"` // 体力 + Cardid string `protobuf:"bytes,4,opt,name=cardid,proto3" json:"cardid"` // 出战的英雄卡 + Energy int32 `protobuf:"varint,5,opt,name=energy,proto3" json:"energy"` // 能量进度 + Consumeexp int32 `protobuf:"varint,6,opt,name=consumeexp,proto3" json:"consumeexp"` // 消消乐积分 } func (x *PlayerData) Reset() { @@ -251,14 +252,22 @@ func (x *PlayerData) GetEnergy() int32 { return 0 } +func (x *PlayerData) GetConsumeexp() int32 { + if x != nil { + return x.Consumeexp + } + 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 + Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"` + Cardid string `protobuf:"bytes,2,opt,name=cardid,proto3" json:"cardid"` // 选择的卡片ID + Consumeexp int32 `protobuf:"varint,3,opt,name=consumeexp,proto3" json:"consumeexp"` // 消消乐积分 } func (x *DBXXLMatch) Reset() { @@ -307,6 +316,13 @@ func (x *DBXXLMatch) GetCardid() string { return "" } +func (x *DBXXLMatch) GetConsumeexp() int32 { + if x != nil { + return x.Consumeexp + } + return 0 +} + type BoxData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -495,7 +511,7 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{ 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, 0x8d, 0x01, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79, + 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x22, 0xad, 0x01, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 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, @@ -504,12 +520,16 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{ 0x01, 0x28, 0x05, 0x52, 0x02, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x22, 0x4f, 0x0a, 0x0a, 0x44, 0x42, 0x58, 0x58, 0x4c, + 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x73, 0x75, + 0x6d, 0x65, 0x65, 0x78, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, 0x6e, + 0x73, 0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x22, 0x6f, 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, 0x22, 0x3b, 0x0a, 0x07, 0x42, 0x6f, 0x78, 0x44, + 0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x73, + 0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, + 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x22, 0x3b, 0x0a, 0x07, 0x42, 0x6f, 0x78, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6f, 0x78, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x6f, 0x78, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6f, 0x70, 0x65, From 67e4b39a7865a34ab4894acdfee2d215e18dfe18 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 11:06:58 +0800 Subject: [PATCH 2/8] update --- modules/entertainment/room.go | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index b187580a8..b51dcd623 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -139,13 +139,13 @@ func (this *Room) AiOperator() { ChangeType: 1, }) } - // for _, v := range szMap { // - // curScore += v.CurSocre - // this.player2.Score += v.CurSocre - // v.CurSocre = this.player2.Score - // this.player2.Energy += v.CurEnergy - // v.CurEnergy = this.player2.Energy - // } + for _, v := range szMap { // + curScore += v.CurSocre + this.player2.Score += v.CurSocre + v.CurSocre = this.player2.Score + this.player2.Energy += v.CurEnergy + v.CurEnergy = this.player2.Energy + } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -381,18 +381,18 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr this.round++ } - for _, v := range szMap { // - fmt.Printf("================\n") - var v1 int - for index := Width - 1; index >= 0; index-- { - for j := 0; j < Height; j++ { - v1 = index + j*7 - fmt.Printf("%d ", v.Data[v1].Cid) + // for _, v := range szMap { // + // fmt.Printf("================\n") + // var v1 int + // for index := Width - 1; index >= 0; index-- { + // for j := 0; j < Height; j++ { + // v1 = index + j*7 + // fmt.Printf("%d ", v.Data[v1].Cid) - } - fmt.Printf("\n") - } - } + // } + // fmt.Printf("\n") + // } + // } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, From 336b60f3f8fe5b7409c5ee558464e7f56b694518 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 11:27:54 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=88=90=E9=BE=99=20=E5=8A=A0=E9=80=9F?= =?UTF-8?q?=E6=A7=BD=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dragon/api_train.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/dragon/api_train.go b/modules/dragon/api_train.go index accfd8b74..1694aac10 100644 --- a/modules/dragon/api_train.go +++ b/modules/dragon/api_train.go @@ -145,6 +145,7 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e dragon.Property["sprint"] = c.Sprint dragon.Property["acceleration"] = c.Acceleration dragon.Property["deceleration"] = c.Deceleration + dragon.Property["energyrecover"] = c.Energyrecover dragon.Property["caddtime"] = c.Caddtime dragon.Property["csubtime"] = c.Csubtime update["property"] = dragon.Property // 更新属性 From 5bf499430cecd8edd28905d94d8da103080becdc Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 11:52:28 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E9=BE=99=E5=B1=9E=E6=80=A7=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dragon/model_dragon.go | 1 + modules/dragon/module.go | 2 ++ modules/entertainment/room.go | 36 ++++++++++++++++++++----------- modules/entertainment/xxlPlat.go | 33 ---------------------------- modules/entertainment/xxl_test.go | 2 +- 5 files changed, 27 insertions(+), 47 deletions(-) diff --git a/modules/dragon/model_dragon.go b/modules/dragon/model_dragon.go index f21eb490e..defb82a84 100644 --- a/modules/dragon/model_dragon.go +++ b/modules/dragon/model_dragon.go @@ -115,6 +115,7 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str dragon.Property["sprint"] = c.Sprint dragon.Property["acceleration"] = c.Acceleration dragon.Property["deceleration"] = c.Deceleration + dragon.Property["energyrecover"] = c.Energyrecover dragon.Property["caddtime"] = c.Caddtime dragon.Property["csubtime"] = c.Csubtime } diff --git a/modules/dragon/module.go b/modules/dragon/module.go index 517b5af14..b1b07698b 100644 --- a/modules/dragon/module.go +++ b/modules/dragon/module.go @@ -94,6 +94,7 @@ func (this *Dragon) CreateRobotDragon(dragonid string, lv int32) (dragon *pb.DBD dragon.Property["sprint"] = c.Sprint dragon.Property["acceleration"] = c.Acceleration dragon.Property["deceleration"] = c.Deceleration + dragon.Property["energyrecover"] = c.Energyrecover // dragon.Property["itemsprint"] = c.Itemsprint dragon.Property["caddtime"] = c.Caddtime dragon.Property["csubtime"] = c.Csubtime @@ -186,6 +187,7 @@ func (this *Dragon) GMModifyDragonLv(uid string, cid string, lv int32) (dragon * dragon.Property["sprint"] = c.Sprint dragon.Property["acceleration"] = c.Acceleration dragon.Property["deceleration"] = c.Deceleration + dragon.Property["energyrecover"] = c.Energyrecover dragon.Property["caddtime"] = c.Caddtime dragon.Property["csubtime"] = c.Csubtime update["property"] = dragon.Property diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index b51dcd623..d392c236a 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -146,6 +146,17 @@ func (this *Room) AiOperator() { this.player2.Energy += v.CurEnergy v.CurEnergy = this.player2.Energy } + for _, v := range szMap { // + fmt.Printf("================\n") + var v1 int + for index := Width - 1; index >= 0; index-- { + for j := 0; j < Height; j++ { + v1 = index + j*7 + fmt.Printf("%d:%d ", v.Data[v1].Oid, v.Data[v1].Cid) + } + fmt.Printf("\n") + } + } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -381,18 +392,17 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr this.round++ } - // for _, v := range szMap { // - // fmt.Printf("================\n") - // var v1 int - // for index := Width - 1; index >= 0; index-- { - // for j := 0; j < Height; j++ { - // v1 = index + j*7 - // fmt.Printf("%d ", v.Data[v1].Cid) - - // } - // fmt.Printf("\n") - // } - // } + for _, v := range szMap { // + fmt.Printf("================\n") + var v1 int + for index := Width - 1; index >= 0; index-- { + for j := 0; j < Height; j++ { + v1 = index + j*7 + fmt.Printf("%d:%d ", v.Data[v1].Oid, v.Data[v1].Cid) + } + fmt.Printf("\n") + } + } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -582,7 +592,7 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) { res = append(res, conf.Rewards...) for _, v := range res { if v.A == "attr" && v.T == "consumeexp" { - if winner == this.player1 { + if winner.Userinfo.Uid == this.player1.Userinfo.Uid { this.player1.Score += v.N } else { this.player2.Score += v.N diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 052e493e4..885b060aa 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -738,39 +738,6 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, return } -func (this *MapData) SetMap() { - sz2 := []int32{ - 3, 1, 2, 2, 1, 3, 1, - 5, 1, 2, 3, 1, 2, 2, - 2, 42, 3, 4, 3, 1, 6, - 1, 3, 3, 4, 2, 3, 6, - 1, 5, 6, 5, 6, 1, 4, - 6, 6, 3, 6, 3, 48, 3, - 3, 3, 1, 3, 5, 2, 5, - } - var pos int - for index := Width - 1; index >= 0; index-- { - for j := 0; j < Height; j++ { - Color := sz2[pos] - Cid := sz2[pos] - if sz2[pos] > 6 { - conf, err := this.module.configure.GetGameBlockByKey(sz2[pos]) - if err == nil { - Color = conf.Color - Cid = conf.Key - this.Plat[index+j*Height].Special = conf.Type - } - } - this.Plat[index+j*Height].Color = Color - this.Plat[index+j*Height].Cid = Cid - pos++ - } - } - this.CheckAndRefreshPlat() - // this.SetIndelibilityPlat() - -} - // 校验当前地图 有没有能消除的 func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { bEliminate = false diff --git a/modules/entertainment/xxl_test.go b/modules/entertainment/xxl_test.go index 2b32ad14a..c56e789d8 100644 --- a/modules/entertainment/xxl_test.go +++ b/modules/entertainment/xxl_test.go @@ -91,7 +91,7 @@ func Test_Main(t *testing.T) { m.InitMap(nil, 1) //m.SkillUp(24, 1, 3, 7, true) - m.SetMap() + b := m.GetFireBoom(1, 7) fmt.Printf("xxxx %d\n", b) var vids int From b2386a3a3e5709b7e466f6579beb51ebf5f9649d Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 13:36:25 +0800 Subject: [PATCH 5/8] update --- modules/entertainment/xxlPlat.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 885b060aa..8cedd2224 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -548,12 +548,12 @@ func (this *MapData) DropGirde() bool { } } if len(mp) < 2 { - for { + ilen := 2 - len(mp) + mp = make(map[int]struct{}, ilen) + for i := 0; i < ilen; i++ { n1, _ := rand.Int(rand.Reader, big.NewInt(int64(len(fill)))) mp[fill[n1.Int64()]] = struct{}{} - if len(mp) >= 2 { - break - } + } if this.iType == 3 { sp = 4 From d88d719560dbf005b4d07453cd8c8f29215d0a77 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 14:46:51 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E8=83=9C=E5=88=A9?= =?UTF-8?q?=E8=8E=B7=E5=BE=97=E7=A7=AF=E5=88=86=E5=90=8C=E6=AD=A5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index d392c236a..737819f15 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -593,9 +593,9 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) { for _, v := range res { if v.A == "attr" && v.T == "consumeexp" { if winner.Userinfo.Uid == this.player1.Userinfo.Uid { - this.player1.Score += v.N + this.player1.Consumeexp += v.N } else { - this.player2.Score += v.N + this.player2.Consumeexp += v.N } } } From 7e31b04d5127ec11e2c8712b40ce64283370bc96 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 17:26:36 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=B8=89=E6=B6=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/configure.go | 21 ++++++++++++++ modules/entertainment/room.go | 46 +++++++++++++++--------------- modules/entertainment/xxlPlat.go | 45 ++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 27 deletions(-) diff --git a/modules/entertainment/configure.go b/modules/entertainment/configure.go index 950a9d559..c3e06537c 100644 --- a/modules/entertainment/configure.go +++ b/modules/entertainment/configure.go @@ -251,3 +251,24 @@ func (this *configureComp) GetGameBlockByKey(key int32) (conf *cfg.GameBlockData err = comm.NewNotFoundConfErr(moduleName, game_block, key) return } + +// 通过权重获取一个普通元素 +func (this *configureComp) GetGameNormalElem() (rd int32) { + var ( + v interface{} + szWeight []int32 + err error + ) + if v, err = this.GetConfigure(game_block); err == nil { + if configure, ok := v.(*cfg.GameBlock); ok { + for _, v := range configure.GetDataList() { + if v.Key > 6 { + break + } + szWeight = append(szWeight, v.Weight) + } + } + } + rd = comm.GetRandW(szWeight) + 1 + return +} diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 737819f15..446643c55 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -55,7 +55,7 @@ func (this *Room) RandomPlayType() (itype int32) { weight = append(weight, v.Weight) } itype = list[comm.GetRandW(weight)].Key - //itype = 4 + itype = 3 return } @@ -146,17 +146,17 @@ func (this *Room) AiOperator() { this.player2.Energy += v.CurEnergy v.CurEnergy = this.player2.Energy } - for _, v := range szMap { // - fmt.Printf("================\n") - var v1 int - for index := Width - 1; index >= 0; index-- { - for j := 0; j < Height; j++ { - v1 = index + j*7 - fmt.Printf("%d:%d ", v.Data[v1].Oid, v.Data[v1].Cid) - } - fmt.Printf("\n") - } - } + // for _, v := range szMap { // + // fmt.Printf("================\n") + // var v1 int + // for index := Width - 1; index >= 0; index-- { + // for j := 0; j < Height; j++ { + // v1 = index + j*7 + // fmt.Printf("%d:%d ", v1, v.Data[v1].Cid) + // } + // fmt.Printf("\n") + // } + // } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -392,17 +392,17 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr this.round++ } - for _, v := range szMap { // - fmt.Printf("================\n") - var v1 int - for index := Width - 1; index >= 0; index-- { - for j := 0; j < Height; j++ { - v1 = index + j*7 - fmt.Printf("%d:%d ", v.Data[v1].Oid, v.Data[v1].Cid) - } - fmt.Printf("\n") - } - } + // for _, v := range szMap { // + // fmt.Printf("================\n") + // var v1 int + // for index := Width - 1; index >= 0; index-- { + // for j := 0; j < Height; j++ { + // v1 = index + j*7 + // fmt.Printf("%d:%d ", v1, v.Data[v1].Cid) + // } + // fmt.Printf("\n") + // } + // } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 8cedd2224..a13bc0428 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -45,9 +45,7 @@ type MapData struct { // 1~6随机一个数 func (this *MapData) GetRandType() int32 { - - n, _ := rand.Int(rand.Reader, big.NewInt(6)) - return int32(n.Int64() + 1) + return this.module.configure.GetGameNormalElem() // 权重随机 } // 玩法带入 @@ -80,6 +78,39 @@ func (this *MapData) CreateGride(count int) (girdes []*pb.GirdeData) { return } +// 生成自定义地图 +func (this *MapData) SetMap() { + sz2 := []int32{ + 3, 1, 2, 2, 1, 3, 1, + 5, 1, 2, 3, 1, 2, 2, + 2, 4, 3, 4, 3, 1, 6, + 1, 3, 3, 4, 2, 3, 6, + 1, 5, 2, 5, 6, 1, 4, + 6, 6, 3, 26, 3, 1, 3, + 3, 3, 1, 3, 3, 2, 5, + } + var pos int + for index := Width - 1; index >= 0; index-- { + for j := 0; j < Height; j++ { + Color := sz2[pos] + Cid := sz2[pos] + if sz2[pos] > 6 { // 特殊元素 + conf, err := this.module.configure.GetGameBlockByKey(sz2[pos]) + if err == nil { + Color = conf.Color + Cid = conf.Key + this.Plat[index+j*Height].Special = conf.Type + } + } + this.Plat[index+j*Height].Color = Color + this.Plat[index+j*Height].Cid = Cid + pos++ + } + } + this.CheckAndRefreshPlat() + // this.SetIndelibilityPlat() +} + // 初始化地图数据 func (this *MapData) InitMap(module *Entertainment, iType int32) { this.module = module @@ -136,6 +167,7 @@ func (this *MapData) CheckSpecialElemChange(oldId, newId int32, color int32) (bS this.Plat[oldId] = tmp this.operElem = append(this.operElem, newId) this.operElem = append(this.operElem, oldId) + x = this.SpecialElem(int(oldId), this.Plat[oldId].Special) xc := this.SpecialElem(int(newId), this.Plat[newId].Special) for k := range xc { @@ -1137,6 +1169,9 @@ func (this *MapData) GetFireBoom(pos int, itype int32) (elem []int) { // 特殊类型元素 统一处理 func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) { + if s <= 0 { + return + } x = make(map[int]struct{}) if s == FourUType { // 4消上下类型 @@ -1155,6 +1190,7 @@ func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) { x[v] = struct{}{} } } + } else if s == BoomType { // 炸弹类型 带走周围一圈+ 上下左右 for _, key := range this.GetBoomElem(id) { x[key] = struct{}{} @@ -1164,7 +1200,8 @@ func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) { x[key] = struct{}{} } } - + this.Plat[id].Special = 0 + x[id] = struct{}{} for k := range x { if k == id { continue From 7c368f7a41c2f6008c78103696285af7a4a99b6d Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 8 Nov 2023 17:28:00 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 446643c55..f77512152 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -55,7 +55,7 @@ func (this *Room) RandomPlayType() (itype int32) { weight = append(weight, v.Weight) } itype = list[comm.GetRandW(weight)].Key - itype = 3 + return } @@ -146,17 +146,7 @@ func (this *Room) AiOperator() { this.player2.Energy += v.CurEnergy v.CurEnergy = this.player2.Energy } - // for _, v := range szMap { // - // fmt.Printf("================\n") - // var v1 int - // for index := Width - 1; index >= 0; index-- { - // for j := 0; j < Height; j++ { - // v1 = index + j*7 - // fmt.Printf("%d:%d ", v1, v.Data[v1].Cid) - // } - // fmt.Printf("\n") - // } - // } + // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, @@ -392,17 +382,6 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr this.round++ } - // for _, v := range szMap { // - // fmt.Printf("================\n") - // var v1 int - // for index := Width - 1; index >= 0; index-- { - // for j := 0; j < Height; j++ { - // v1 = index + j*7 - // fmt.Printf("%d:%d ", v1, v.Data[v1].Cid) - // } - // fmt.Printf("\n") - // } - // } // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap,