From 97b1328fa4aa403fcbd6e584c877b9dc8b98602b Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 20 Dec 2023 19:13:21 +0800 Subject: [PATCH] =?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 --- comm/imodule.go | 2 - modules/entertainment/api_create.go | 6 +-- modules/entertainment/api_getreward.go | 4 +- modules/entertainment/api_joinroom.go | 6 +-- modules/entertainment/api_match.go | 2 +- modules/entertainment/room.go | 38 +++++++++++------- modules/entertainment/xxlPlat.go | 54 +++++++++++++++++--------- modules/user/model_user.go | 33 ---------------- modules/user/module.go | 7 +--- 9 files changed, 71 insertions(+), 81 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index d25bf80e4..53dfede47 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -210,8 +210,6 @@ type ( ChangeUserMoonLv(session IUserSession, lv int32) (errdata *pb.ErrorData) //GM创号 GMCreatePlayer(session IUserSession, req *pb.UserCreateReq) (errdata *pb.ErrorData) - // 清除玩家赛季积分 ---需要清除 - CleanUserConsumeexp(session IUserSession) (err error) } //武器模块 IEquipment interface { diff --git a/modules/entertainment/api_create.go b/modules/entertainment/api_create.go index 47a005451..cdd0a489f 100644 --- a/modules/entertainment/api_create.go +++ b/modules/entertainment/api_create.go @@ -66,9 +66,9 @@ func (this *apiComp) CreateRoom(session comm.IUserSession, req *pb.EntertainCrea return } p1 := &pb.PlayerData{ - Userinfo: comm.GetUserBaseInfo(user), - Cardid: req.Idcard, - Consumeexp: user.Consumeexp, + 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_getreward.go b/modules/entertainment/api_getreward.go index 86e861ba5..d3d7638fe 100644 --- a/modules/entertainment/api_getreward.go +++ b/modules/entertainment/api_getreward.go @@ -33,10 +33,10 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.EntertainRewardRe return } - user, err := this.module.ModuleUser.GetUser(session.GetUserId()) + //user, err := this.module.ModuleUser.GetUser(session.GetUserId()) if err == nil { if conf, err := this.module.configure.GetGameConsumeintegralReward(req.Key); err == nil { - if user.Consumeexp < conf.Key { + if list.Consumeexp < conf.Key { errdata = &pb.ErrorData{ Code: pb.ErrorCode_UserRepeadReward, Title: pb.ErrorCode_UserRepeadReward.ToString(), diff --git a/modules/entertainment/api_joinroom.go b/modules/entertainment/api_joinroom.go index c1fcf80a8..d1e376a88 100644 --- a/modules/entertainment/api_joinroom.go +++ b/modules/entertainment/api_joinroom.go @@ -64,9 +64,9 @@ func (this *apiComp) JoinRoom(session comm.IUserSession, req *pb.EntertainJoinRo return } p := &pb.PlayerData{ - Userinfo: comm.GetUserBaseInfo(user), - Cardid: req.Idcard, - Consumeexp: user.Consumeexp, + 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 adf91b895..5e36e338c 100644 --- a/modules/entertainment/api_match.go +++ b/modules/entertainment/api_match.go @@ -85,7 +85,7 @@ func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq) this.module.match.MatchReq(&pb.DBXXLMatch{ Userinfo: comm.GetUserBaseInfo(user), Cardid: req.Idcard, - Consumeexp: user.Consumeexp, + Consumeexp: list.Consumeexp, Skill: mySkill, }) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index ed27b0acf..7e05a2f22 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -583,18 +583,20 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { if list, err = this.module.model.getEntertainmList(winner.Userinfo.Uid); err == nil { return } - if user, err := this.module.ModuleUser.GetUser(winner.Userinfo.Uid); err == nil { - if conf, err := this.module.configure.GetGameConsumeintegral(user.Consumeexp); err == nil { - res = append(res, conf.Rewards...) - for _, v := range res { - if v.A == "attr" && v.T == "consumeexp" { - this.player2.Consumeexp += v.N - list.Consumeexp += v.N - update["consumeexp"] = list.Consumeexp - } + if conf, err := this.module.configure.GetGameConsumeintegral(list.Consumeexp); err == nil { + for _, v := range conf.Rewards { + if v.A == "attr" && v.T == "consumeexp" { + list.Consumeexp += v.N + update["consumeexp"] = list.Consumeexp + winner.Consumeexp = list.Consumeexp + } else { + res = append(res, v) } - this.szSession[winindex].Push() } + if errdata, atno = this.module.DispenseAtno(this.szSession[winindex], res, true); errdata != nil { + return + } + this.szSession[winindex].Push() } // 修改连胜 @@ -609,7 +611,6 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { } list.Box = append(list.Box, box) update["box"] = list.Box - } } } @@ -617,9 +618,8 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { } if lostPlayer.Userinfo.Uid != "999" { if conf, err := this.module.configure.GetGameConsumeHero(lostPlayer.Cardid); err == nil { - + update := map[string]interface{}{} if list, err := this.module.model.getEntertainmList(lostPlayer.Userinfo.Uid); err == nil { - update := map[string]interface{}{} if list.Liansheng != 0 { list.Liansheng = 0 // 修改连胜 update["liansheng"] = list.Liansheng @@ -631,6 +631,18 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { update["card"] = list.Card } } + if conf, err := this.module.configure.GetGameConsumeintegral(list.Consumeexp); err == nil { // 战败扣除积分 + for _, v := range conf.Rewards { + if v.A == "attr" && v.T == "consumeexp" { + list.Consumeexp -= v.N + if list.Consumeexp <= 0 { + list.Consumeexp = 0 + } + lostPlayer.Consumeexp = list.Consumeexp + update["consumeexp"] = list.Consumeexp + } + } + } if len(update) > 0 { this.module.model.modifyEntertainmList(lostPlayer.Userinfo.Uid, update) } diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 588091053..5a03e5f85 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -173,14 +173,7 @@ func (this *MapData) CheckSpecialElemChange(oldId, newId int32, color int32) (bS } var energy int32 var curScore int32 - for id := range x { - if this.Plat[id].Color == color { - energy++ - } - curScore += this.Plat[id].Score - this.Plat[id] = &pb.GirdeData{} - this.operElem = append(this.operElem, int32(id)) - } + for id := range x { if this.Plat[id].Color == color { energy++ @@ -190,7 +183,6 @@ func (this *MapData) CheckSpecialElemChange(oldId, newId int32, color int32) (bS this.operElem = append(this.operElem, int32(id)) } if this.DropGirde() { - szMap = append(szMap, &pb.MapData{ Data: this.GetPalatData(), CurSocre: curScore, @@ -1283,17 +1275,41 @@ func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) { return } func (this *MapData) HitElem(color int32, curid int32) (szMap []*pb.MapData) { - this.Plat[curid] = &pb.GirdeData{} - if this.DropGirde() { - szMap = append(szMap, &pb.MapData{ - Data: this.GetPalatData(), - CurSocre: 0, - CurEnergy: 0, - }) + var energy int32 + var curScore int32 + if this.Plat[curid].Special == 0 { + if this.Plat[curid].Color == color { + energy++ + } + curScore = this.Plat[curid].Score + this.Plat[curid] = &pb.GirdeData{} + if this.DropGirde() { + szMap = append(szMap, &pb.MapData{ + Data: this.GetPalatData(), + CurSocre: curScore, + CurEnergy: 0, + }) + } + sz, _ := this.CheckMap(color, false) + szMap = append(szMap, sz...) + } else { + x := this.SpecialElem(int(curid), this.Plat[curid].Special) + for id := range x { + if this.Plat[id].Color == color { + energy++ + } + curScore += this.Plat[id].Score + this.Plat[id] = &pb.GirdeData{} + this.operElem = append(this.operElem, int32(id)) + } + if this.DropGirde() { + szMap = append(szMap, &pb.MapData{ + Data: this.GetPalatData(), + CurSocre: curScore, + CurEnergy: energy, + }) + } } - sz, _ := this.CheckMap(color, false) - szMap = append(szMap, sz...) - return } diff --git a/modules/user/model_user.go b/modules/user/model_user.go index da33f1366..e53313387 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -353,39 +353,6 @@ func (this *ModelUser) CleanUserMerchantmoney(session comm.IUserSession) (err er return } -func (this *ModelUser) CleanUserConsumeexp(session comm.IUserSession) (err error) { - var ( - model *db.DBModel - update map[string]interface{} - uid string - ) - - uid = session.GetUserId() - user := &pb.DBUser{} - update = make(map[string]interface{}, 0) - update["consumeexp"] = 0 - - if db.IsCross() { - if model, err = this.module.GetDBModelByUid(uid, this.TableName); err == nil { - if err := this.Get(uid, user); err == nil { - err = model.Change(uid, update) - } else { - this.module.Errorf("err:%v", err) - } - } else { - this.module.Errorln(err) - } - } else { - if err := this.Get(uid, user); err == nil { - err = this.Change(uid, update) - } else { - this.module.Errorf("err:%v", err) - } - } - - return -} - ///资源自动恢复 func (this *ModelUser) ResAutoReplies(session comm.IUserSession, resreplies map[int32]int64) { var ( diff --git a/modules/user/module.go b/modules/user/module.go index b788b0c0e..8f36e87a4 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -527,8 +527,8 @@ func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atn Integral: user.Integral, Profit: user.Profit, Deposit: user.Deposit, - Consumeexp: user.Consumeexp, - Consumemoney: user.Consumemoney, + + Consumemoney: user.Consumemoney, } atno = make([]*pb.UserAtno, 0, len(attrs)) for attr, add := range attrs { @@ -1517,6 +1517,3 @@ func (this *User) GMCreatePlayer(session comm.IUserSession, req *pb.UserCreateRe errdata = this.api.Create(session, req) return } -func (this *User) CleanUserConsumeexp(session comm.IUserSession) (err error) { - return this.modelUser.CleanUserConsumeexp(session) -}