From f94b9d6117d6217716cd8ddaa99311986a47c5c2 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 19 Dec 2022 18:14:34 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=8A=A0=E6=96=B0=E7=9A=84=E6=88=98?= =?UTF-8?q?=E6=96=97=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/enchant/api_buy.go | 4 +-- modules/enchant/api_challenge.go | 2 +- modules/enchant/api_challengeover.go | 39 ++++++++++++++-------------- pb/battle_db.pb.go | 20 ++++++++------ 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/modules/enchant/api_buy.go b/modules/enchant/api_buy.go index 5f00a207b..f7d956e63 100644 --- a/modules/enchant/api_buy.go +++ b/modules/enchant/api_buy.go @@ -88,8 +88,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.EnchantBuyReq) (code list.RecoveryTime = 0 } addCount += req.Count - if amount+addCount > conf.VikingNum { - code = pb.ErrorCode_VikingBuyMaxCount + if amount+addCount > conf.EnchantbossMax { + code = pb.ErrorCode_EnchantBuyMaxCount return } mapData["recoveryTime"] = list.RecoveryTime diff --git a/modules/enchant/api_challenge.go b/modules/enchant/api_challenge.go index 1b5476809..2e29dd6f4 100644 --- a/modules/enchant/api_challenge.go +++ b/modules/enchant/api_challenge.go @@ -56,7 +56,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.EnchantChallen } code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{ - Ptype: pb.PlayType_hunting, + Ptype: pb.PlayType_enchant, Title: "", Format: &pb.BattleFormation{ Leadpos: req.Leadpos, diff --git a/modules/enchant/api_challengeover.go b/modules/enchant/api_challengeover.go index 58e4bcf28..5716fac18 100644 --- a/modules/enchant/api_challengeover.go +++ b/modules/enchant/api_challengeover.go @@ -3,6 +3,7 @@ package enchant import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "google.golang.org/protobuf/proto" @@ -21,7 +22,8 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Encha func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantChallengeOverReq) (code pb.ErrorCode, data proto.Message) { var ( mapData map[string]interface{} - bWin bool // 战斗是否胜利 + bWin bool // 战斗是否胜利 + score int32 // 通关获得分数 ) mapData = make(map[string]interface{}, 0) // reward = make([]*cfg.Gameatn, 0) @@ -67,30 +69,29 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha return } - //amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 + amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 - // if amount < conf.EnchantNum { - // enchant.RecoveryTime = configure.Now().Unix() - // mapData["recoveryTime"] = enchant.RecoveryTime - // } + if amount < conf.EnchantbossMax { // 挑战卷 小于副本最大存储数的时候开始恢复 + enchant.RecoveryTime = configure.Now().Unix() + mapData["recoveryTime"] = enchant.RecoveryTime + } if bWin { this.module.CheckRank(session.GetUserId(), req.BossType, enchant, req.Report, 0) } - // 耗时校验 当前战斗胜利时间消耗小于之前刷新数据 - + enchant.Boss[req.BossType] = score // 获得的积分 // 发放通关随机奖励 - // reward = this.module.configure.GetDropReward(cfgEnchant.) // 获取掉落奖励 - // if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success { - // return - // } - // if newChallenge && bWin { // 新关卡挑战通过 发放首通奖励 - // if code = this.module.DispenseRes(session, cfgEnchant.Firstprize, true); code != pb.ErrorCode_Success { - // return - // } - // enchant.Boss[req.BossType] += 1 - // mapData["boss"] = enchant.Boss + for _, v := range cfgEnchant { + if score >= v.ScoreLow && score <= v.ScoreUp { + for _, v1 := range v.RewardDrop { + reward := this.module.configure.GetDropReward(v1) // 获取掉落奖励 + if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success { + return + } + } + + } + } - // } mapData["challengeTime"] = enchant.BossTime mapData["boss"] = enchant.Boss code = this.module.ModifyEnchantData(session.GetUserId(), mapData) diff --git a/pb/battle_db.pb.go b/pb/battle_db.pb.go index 71ae306ca..2b7a6f648 100644 --- a/pb/battle_db.pb.go +++ b/pb/battle_db.pb.go @@ -90,6 +90,7 @@ const ( PlayType_academy PlayType = 8 //联盟学院 PlayType_heroteaching PlayType = 9 //英雄教学 PlayType_combat PlayType = 10 //新关卡 + PlayType_enchant PlayType = 11 // 附魔副本 ) // Enum value maps for PlayType. @@ -106,6 +107,7 @@ var ( 8: "academy", 9: "heroteaching", 10: "combat", + 11: "enchant", } PlayType_value = map[string]int32{ "null": 0, @@ -119,6 +121,7 @@ var ( "academy": 8, "heroteaching": 9, "combat": 10, + "enchant": 11, } ) @@ -672,7 +675,7 @@ var file_battle_battle_db_proto_rawDesc = []byte{ 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x6e, 0x69, 0x6c, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x70, 0x76, 0x65, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x70, 0x76, 0x70, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x70, 0x76, 0x62, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x65, 0x76, 0x65, 0x10, 0x04, 0x2a, - 0x99, 0x01, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, + 0xa6, 0x01, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x6d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x70, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x68, @@ -681,13 +684,14 @@ var file_battle_battle_db_proto_rawDesc = []byte{ 0x61, 0x73, 0x79, 0x10, 0x06, 0x12, 0x09, 0x0a, 0x05, 0x61, 0x72, 0x65, 0x6e, 0x61, 0x10, 0x07, 0x12, 0x0b, 0x0a, 0x07, 0x61, 0x63, 0x61, 0x64, 0x65, 0x6d, 0x79, 0x10, 0x08, 0x12, 0x10, 0x0a, 0x0c, 0x68, 0x65, 0x72, 0x6f, 0x74, 0x65, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x10, 0x09, 0x12, - 0x0a, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x62, 0x61, 0x74, 0x10, 0x0a, 0x2a, 0x1f, 0x0a, 0x0c, 0x42, - 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x69, - 0x6e, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x10, 0x02, 0x2a, 0x2b, 0x0a, 0x0c, - 0x44, 0x42, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x12, 0x08, 0x0a, 0x04, - 0x64, 0x72, 0x61, 0x77, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x72, 0x65, 0x64, 0x10, 0x01, 0x12, - 0x08, 0x0a, 0x04, 0x62, 0x75, 0x6c, 0x65, 0x10, 0x02, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x62, 0x61, 0x74, 0x10, 0x0a, 0x12, 0x0b, 0x0a, 0x07, 0x65, + 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x10, 0x0b, 0x2a, 0x1f, 0x0a, 0x0c, 0x42, 0x42, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x69, 0x6e, 0x10, 0x00, + 0x12, 0x07, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x10, 0x02, 0x2a, 0x2b, 0x0a, 0x0c, 0x44, 0x42, 0x42, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x12, 0x08, 0x0a, 0x04, 0x64, 0x72, 0x61, + 0x77, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x72, 0x65, 0x64, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, + 0x62, 0x75, 0x6c, 0x65, 0x10, 0x02, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 5917f78e37e90f5a8a4bd2fecd0e3fe4e32cd667 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 19 Dec 2022 20:30:41 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/enchant/api_challengeover.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/enchant/api_challengeover.go b/modules/enchant/api_challengeover.go index 5716fac18..3bafdab5b 100644 --- a/modules/enchant/api_challengeover.go +++ b/modules/enchant/api_challengeover.go @@ -76,9 +76,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha mapData["recoveryTime"] = enchant.RecoveryTime } if bWin { - this.module.CheckRank(session.GetUserId(), req.BossType, enchant, req.Report, 0) + this.module.CheckRank(session.GetUserId(), req.BossType, enchant, req.Report, req.Score) } - enchant.Boss[req.BossType] = score // 获得的积分 + enchant.Boss[req.BossType] = req.Score // 获得的积分 // 发放通关随机奖励 for _, v := range cfgEnchant { if score >= v.ScoreLow && score <= v.ScoreUp { @@ -88,7 +88,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha return } } - } } From 7924d07a301395952bf411ca7297ee1a5a5b89cc Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 19 Dec 2022 20:30:50 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/enchant/model_enchant.go | 2 +- modules/enchant/model_rank.go | 2 +- modules/enchant/module.go | 6 ++-- pb/enchant_db.pb.go | 22 ++++++++++---- pb/enchant_msg.pb.go | 50 +++++++++++++++++++------------- 5 files changed, 52 insertions(+), 30 deletions(-) diff --git a/modules/enchant/model_enchant.go b/modules/enchant/model_enchant.go index 78b582f14..fd90439a3 100644 --- a/modules/enchant/model_enchant.go +++ b/modules/enchant/model_enchant.go @@ -37,7 +37,7 @@ func (this *modelEnchant) getEnchantList(uid string) (result *pb.DBEnchant, err result = &pb.DBEnchant{ Id: primitive.NewObjectID().Hex(), Uid: uid, - Boss: make(map[int32]int32), + Boss: make(map[int32]int64), BossTime: make(map[int32]int32), } if err = this.Get(uid, result); err != nil && mgo.MongodbNil != err { diff --git a/modules/enchant/model_rank.go b/modules/enchant/model_rank.go index 463c0abd1..2d8f8353c 100644 --- a/modules/enchant/model_rank.go +++ b/modules/enchant/model_rank.go @@ -56,7 +56,7 @@ func (this *ModelRank) getEnchantRankListByBossType(uid string, bossType int32) } // 排行数据写跨服 -func (this *ModelRank) SetRankListData(tableName string, score int32, uid string) { +func (this *ModelRank) SetRankListData(tableName string, score int64, uid string) { if !db.IsCross() { if conn, err := db.Cross(); err == nil { var ( diff --git a/modules/enchant/module.go b/modules/enchant/module.go index 0f0b58a8a..f6119d912 100644 --- a/modules/enchant/module.go +++ b/modules/enchant/module.go @@ -76,12 +76,12 @@ func (this *Enchant) CheckUserBaseEnchantInfo(uid string) (data []*pb.DBEnchantR } return } -func (this *Enchant) CheckRank(uid string, boosID int32, Enchant *pb.DBEnchant, report *pb.BattleReport, score int32) { +func (this *Enchant) CheckRank(uid string, boosID int32, Enchant *pb.DBEnchant, report *pb.BattleReport, score int64) { costTime := report.Costtime if Enchant.BossTime[boosID] > costTime || Enchant.BossTime[boosID] == 0 { // 刷新记录 Enchant.BossTime[boosID] = costTime - szLine := make([]*pb.LineUp, 5) + szLine := make([]*pb.LineUp, 0) Leadpos := 0 if report != nil && report.Info != nil && len(report.Info.Redflist) > 0 { costTime = report.Costtime @@ -108,6 +108,7 @@ func (this *Enchant) CheckRank(uid string, boosID int32, Enchant *pb.DBEnchant, mapRankData["Leadpos"] = Leadpos mapRankData["line"] = szLine mapRankData["costTime"] = costTime + mapRankData["score"] = score conn_, _ := db.Cross() dbModel := db.NewDBModel(comm.TableEnchantRank, time.Hour, conn_) dbModel.ChangeList(uid, v.Id, mapRankData) @@ -127,6 +128,7 @@ func (this *Enchant) CheckRank(uid string, boosID int32, Enchant *pb.DBEnchant, Leadpos: int32(Leadpos), Line: szLine, CostTime: costTime, + Score: score, } objID = new.Id conn_, _ := db.Cross() diff --git a/pb/enchant_db.pb.go b/pb/enchant_db.pb.go index 5194be760..b5d0a89f5 100644 --- a/pb/enchant_db.pb.go +++ b/pb/enchant_db.pb.go @@ -27,7 +27,7 @@ type DBEnchant struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - Boss map[int32]int32 `protobuf:"bytes,3,rep,name=boss,proto3" json:"boss" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key boss 类型 value 积分 + Boss map[int32]int64 `protobuf:"bytes,3,rep,name=boss,proto3" json:"boss" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key boss 类型 value 积分 BuyCount int32 `protobuf:"varint,4,opt,name=buyCount,proto3" json:"buyCount" bson:"buyCount"` //购买次数 CTime int64 `protobuf:"varint,5,opt,name=cTime,proto3" json:"cTime" bson:"cTime"` //修改时间 BossTime map[int32]int32 `protobuf:"bytes,6,rep,name=bossTime,proto3" json:"bossTime" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"bossTime"` // @@ -80,7 +80,7 @@ func (x *DBEnchant) GetUid() string { return "" } -func (x *DBEnchant) GetBoss() map[int32]int32 { +func (x *DBEnchant) GetBoss() map[int32]int64 { if x != nil { return x.Boss } @@ -129,6 +129,7 @@ type DBEnchantRank struct { Leadpos int32 `protobuf:"varint,6,opt,name=leadpos,proto3" json:"leadpos"` //队长位置 Line []*LineUp `protobuf:"bytes,7,rep,name=line,proto3" json:"line"` // 阵容数据 CostTime int32 `protobuf:"varint,8,opt,name=costTime,proto3" json:"costTime" bson:"costTime"` //闯关耗时 单位s + Score int64 `protobuf:"varint,9,opt,name=score,proto3" json:"score" bson:"score"` } func (x *DBEnchantRank) Reset() { @@ -219,6 +220,13 @@ func (x *DBEnchantRank) GetCostTime() int32 { return 0 } +func (x *DBEnchantRank) GetScore() int64 { + if x != nil { + return x.Score + } + return 0 +} + var File_enchant_enchant_db_proto protoreflect.FileDescriptor var file_enchant_enchant_db_proto_rawDesc = []byte{ @@ -242,12 +250,12 @@ var file_enchant_enchant_db_proto_rawDesc = []byte{ 0x6f, 0x76, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x1a, 0x37, 0x0a, 0x09, 0x42, 0x6f, 0x73, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3b, 0x0a, 0x0d, 0x42, 0x6f, 0x73, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0xcc, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, + 0xe2, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6f, 0x73, 0x73, 0x74, 0x79, 0x70, 0x65, 0x18, @@ -259,8 +267,10 @@ var file_enchant_enchant_db_proto_rawDesc = []byte{ 0x61, 0x64, 0x70, 0x6f, 0x73, 0x12, 0x1b, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x4c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x06, - 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, + 0x63, 0x6f, 0x72, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/enchant_msg.pb.go b/pb/enchant_msg.pb.go index 5a81ce4df..4284242b0 100644 --- a/pb/enchant_msg.pb.go +++ b/pb/enchant_msg.pb.go @@ -231,6 +231,7 @@ type EnchantChallengeOverReq struct { BossType int32 `protobuf:"varint,1,opt,name=bossType,proto3" json:"bossType"` // boos 类型 Report *BattleReport `protobuf:"bytes,2,opt,name=report,proto3" json:"report"` //战报 + Score int64 `protobuf:"varint,3,opt,name=score,proto3" json:"score"` //获得积分 或伤害 } func (x *EnchantChallengeOverReq) Reset() { @@ -279,6 +280,13 @@ func (x *EnchantChallengeOverReq) GetReport() *BattleReport { return nil } +func (x *EnchantChallengeOverReq) GetScore() int64 { + if x != nil { + return x.Score + } + return 0 +} + // 客户端通知服务器打赢了 type EnchantChallengeOverResp struct { state protoimpl.MessageState @@ -549,31 +557,33 @@ var file_enchant_enchant_msg_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6f, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x6f, 0x73, - 0x73, 0x54, 0x79, 0x70, 0x65, 0x22, 0x5c, 0x0a, 0x17, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, + 0x73, 0x54, 0x79, 0x70, 0x65, 0x22, 0x72, 0x0a, 0x17, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6f, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x6f, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x22, 0x3a, 0x0a, 0x18, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x43, 0x68, - 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, - 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, - 0x44, 0x42, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, - 0x25, 0x0a, 0x0d, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, - 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x30, 0x0a, 0x0e, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, - 0x74, 0x42, 0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x45, 0x6e, 0x63, 0x68, 0x61, - 0x6e, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x48, 0x0a, 0x12, 0x45, 0x6e, 0x63, 0x68, - 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1a, - 0x0a, 0x08, 0x62, 0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x08, 0x62, 0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x66, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x13, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, - 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x05, 0x72, 0x61, 0x6e, - 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x45, 0x6e, 0x63, - 0x68, 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x3a, 0x0a, 0x18, 0x45, 0x6e, 0x63, + 0x68, 0x61, 0x6e, 0x74, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x25, 0x0a, 0x0d, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, + 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x30, 0x0a, 0x0e, + 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x42, 0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, + 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, + 0x42, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x48, + 0x0a, 0x12, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x06, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x13, 0x45, 0x6e, 0x63, 0x68, + 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, + 0x24, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, + 0x2e, 0x44, 0x42, 0x45, 0x6e, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05, + 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 178a325df95b700894552a5760be652661bd7d5a Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 19 Dec 2022 21:00:26 +0800 Subject: [PATCH 4/6] update --- modules/rtask/updateHandle.go | 4 +- modules/task/api_activereceive.go | 65 +++++++++++++++---------------- modules/task/api_receive.go | 19 +++++++-- modules/task/model_active.go | 10 +++++ modules/task/model_task.go | 12 ++++-- 5 files changed, 69 insertions(+), 41 deletions(-) diff --git a/modules/rtask/updateHandle.go b/modules/rtask/updateHandle.go index 96c9c46dd..97f89f82b 100644 --- a/modules/rtask/updateHandle.go +++ b/modules/rtask/updateHandle.go @@ -64,7 +64,7 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond } } log.Debug("覆盖数值更新", log.Fields{"uid": uid, "condiId": cfg.Id, "params": vals, "updated": record.Vals[cfg.Id]}) - this.listenTask(uid, cfg.Id) + // this.listenTask(uid, cfg.Id) return } @@ -112,7 +112,7 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData } log.Debug("累计次数更新", log.Fields{"uid": uid, "condiId": cfg.Id, "params": vals, "updated": record.Vals[cfg.Id]}) - this.listenTask(uid, cfg.Id) + // this.listenTask(uid, cfg.Id) return } diff --git a/modules/task/api_activereceive.go b/modules/task/api_activereceive.go index b002b5e93..f21f61f36 100644 --- a/modules/task/api_activereceive.go +++ b/modules/task/api_activereceive.go @@ -36,49 +36,48 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive return } var rewards []*cfg.Gameatn + var flag bool + update := map[string]interface{}{} // 玩家的 - activeList := this.moduleTask.modelTaskActive.getActiveListByTag(uid, comm.TaskTag(req.TaskTag)) - var activityData *pb.ActivityData + activeList := this.moduleTask.modelTaskActive.getActiveList(uid) + // var activityData *pb.ActivityData for _, v := range activeList { if v.TaskId == req.Id { - activityData = v + if v.Received != 1 { + conf := this.moduleTask.configure.getTaskActiveById(v.TaskId) + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + if req.TaskTag == int32(comm.TASK_DAILY) { + if ue.Activeday < conf.Active { + code = pb.ErrorCode_TaskActiveNoenough + return + } + } else if req.TaskTag == int32(comm.TASK_WEEKLY) { + if ue.Activeweek < conf.Active { + code = pb.ErrorCode_TaskActiveNoenough + return + } + } + + v.Received = 1 + flag = true + rewards = append(rewards, conf.Reword...) + } break } } - if activityData == nil { - code = pb.ErrorCode_TaskNotFound - return - } + if flag { + update["activityList"] = activeList - if activityData.Received != 1 { //未领取 - conf := this.moduleTask.configure.getTaskActiveById(activityData.TaskId) - if conf == nil { - code = pb.ErrorCode_ConfigNoFound + if err := this.moduleTask.modelTaskActive.Change(session.GetUserId(), update); err != nil { + this.moduleTask.Errorf("updateReceive err %v", err) + code = pb.ErrorCode_DBError return } - - update := make(map[string]interface{}) - if req.TaskTag == int32(comm.TASK_DAILY) { - if ue.Activeday < conf.Active { - code = pb.ErrorCode_TaskActiveNoenough - return - } - } else if req.TaskTag == int32(comm.TASK_WEEKLY) { - if ue.Activeweek < conf.Active { - code = pb.ErrorCode_TaskActiveNoenough - return - } - } - update["received"] = 1 - if len(update) > 0 { - if err := this.moduleTask.modelTaskActive.updateReceive(session.GetUserId(), update); err != nil { - this.moduleTask.Errorf("updateReceive err %v", err) - code = pb.ErrorCode_DBError - return - } - } - rewards = append(rewards, conf.Reword...) } if len(rewards) > 0 { diff --git a/modules/task/api_receive.go b/modules/task/api_receive.go index 15e681099..b62120ddb 100644 --- a/modules/task/api_receive.go +++ b/modules/task/api_receive.go @@ -104,10 +104,23 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) } //更新用户领取状态 - update := map[string]interface{}{ - "received": 1, + for _, v := range taskDataList { + if v.TaskId == req.Id { + v.Received = 1 + break + } } - if err := this.moduleTask.modelTask.modifyUserTask(session.GetUserId(), taskData.TaskId, update); err != nil { + update := map[string]interface{}{} + switch req.TaskTag { + case int32(comm.TASK_DAILY): + update["dayList"] = taskDataList + case int32(comm.TASK_WEEKLY): + update["weekList"] = taskDataList + case int32(comm.TASK_ACHIEVE): + update["achieveList"] = taskDataList + } + + if err := this.moduleTask.modelTask.Change(session.GetUserId(), update); err != nil { code = pb.ErrorCode_DBError return } diff --git a/modules/task/model_active.go b/modules/task/model_active.go index 9fb0f1dea..2b11bb3fe 100644 --- a/modules/task/model_active.go +++ b/modules/task/model_active.go @@ -62,6 +62,16 @@ func (this *ModelTaskActive) initActiveReward(uid string, taskTag comm.TaskTag) } } +func (this *ModelTaskActive) getActiveList(uid string) (list []*pb.ActivityData) { + task := &pb.DBActivity{} + if err := this.Get(uid, task); err != nil { + this.moduleTask.Errorf("getTaskList err %v", err) + return + } + + return task.ActivityList +} + //获取玩家活跃度列表 func (this *ModelTaskActive) getActiveListByTag(uid string, taskTag comm.TaskTag) (list []*pb.ActivityData) { task := &pb.DBActivity{} diff --git a/modules/task/model_task.go b/modules/task/model_task.go index 3b0e212d8..fab1a51e7 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -82,6 +82,7 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB return nil } + update := map[string]interface{}{} var dataList []*pb.TaskData if taskTag == comm.TASK_DAILY { dataList = task.DayList @@ -90,7 +91,6 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB } // 筛选出指定tag的任务 - update := map[string]interface{}{} var flag bool for _, v := range dataList { oldVal := v.Progress @@ -112,8 +112,13 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB } } if flag { - update["dayList"] = task.DayList - if err := this.moduleTask.modelTask.Change("uid", update); err != nil { + if taskTag == comm.TASK_DAILY { + update["dayList"] = dataList + } else if taskTag == comm.TASK_WEEKLY { + update["weekList"] = dataList + } + + if err := this.moduleTask.modelTask.Change(uid, update); err != nil { log.Error("更新每日任务", log.Fields{"uid": uid}) } } @@ -325,6 +330,7 @@ func (this *ModelTask) checkTask(uid string, taskId int32) (*pb.TaskData, bool) } //更改用户任务 +// Deprecated func (this *ModelTask) modifyUserTask(uid string, taskId int32, data map[string]interface{}) error { var task *pb.DBTask if err := this.GetList(uid, &task); err != nil { From d1fb30e587210ff8b673586a307952c88f619188 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 20 Dec 2022 11:50:34 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8E=BB=E6=8E=89debug=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gourmet/api_getlist.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/gourmet/api_getlist.go b/modules/gourmet/api_getlist.go index 689bd9416..3b2d90080 100644 --- a/modules/gourmet/api_getlist.go +++ b/modules/gourmet/api_getlist.go @@ -32,11 +32,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListRe // 任务统计 this.module.ModuleRtask.SendToRtask(session, comm.Rtype136, _gourmet.TotalTime) - resp := &pb.GourmetCreateOrderReq{} - resp.Order = append(resp.Order, &pb.OrderCook{ - FoodType: 1001, - FoodCount: 10, - }) - this.CreateOrder(session, resp) + return } From 2589c198a9ac3d05a86e89e32924c3757c3c7660 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 20 Dec 2022 12:52:55 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/rtask/updateHandle.go | 2 +- modules/task/model_task.go | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/rtask/updateHandle.go b/modules/rtask/updateHandle.go index c1b4cb014..8a6aa4cd0 100644 --- a/modules/rtask/updateHandle.go +++ b/modules/rtask/updateHandle.go @@ -89,7 +89,7 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData //查找任务数据 if v, ok := record.Vals[cfg.Id]; ok { newArr := make([]int32, len(vals)) - newArr = vals + copy(newArr, vals) srcCount := v.Data[0] newArr[0] = srcCount + vals[0] v.Data = toMap(newArr...) diff --git a/modules/task/model_task.go b/modules/task/model_task.go index e4fc19854..a42bd5de7 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -119,7 +119,7 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB } if err := this.moduleTask.modelTask.Change(uid, update); err != nil { - + this.moduleTask.Error("change err", log.Field{Key: "uid", Value: uid}) } } @@ -147,6 +147,7 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB // 成就列表 var achieveList []*pb.TaskData + var bflag bool if taskTag == comm.TASK_ACHIEVE { for _, v := range task.AchieveList { if curTask := this.moduleTask.configure.getTaskById(v.TaskId); curTask != nil { @@ -170,6 +171,32 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB } } } + + for _, v := range achieveList { + oldVal := v.Progress + var newVal int32 + if p, ok := dr.Vals[v.TypeId]; ok { + if len(p.Data) == 0 { + continue + } + newVal = p.Data[0] + if code := this.moduleTask.ModuleRtask.CheckCondi(uid, v.TypeId); code == pb.ErrorCode_Success { + v.Progress = p.Data[0] + v.Status = 1 + } else { + v.Progress = p.Data[0] + } + } + if oldVal != newVal { + bflag = true + } + } + if bflag { + update["achieveList"] = achieveList + if err := this.moduleTask.modelTask.Change(uid, update); err != nil { + log.Error("err", log.Field{Key: "uid", Value: uid}) + } + } task.AchieveList = achieveList }